errorcorrection_test.go 575 B

12345678910111213141516171819202122232425262728
  1. package datamatrix
  2. import (
  3. "bytes"
  4. "testing"
  5. )
  6. func Test_CalcECC(t *testing.T) {
  7. data := []byte{142, 164, 186}
  8. var size *dmCodeSize = nil
  9. for _, s := range codeSizes {
  10. if s.DataCodewords() >= len(data) {
  11. size = s
  12. break
  13. }
  14. }
  15. if size == nil {
  16. t.Error("size not found")
  17. }
  18. if bytes.Compare(ec.calcECC(data, size), []byte{142, 164, 186, 114, 25, 5, 88, 102}) != 0 {
  19. t.Error("ECC Test 1 failed")
  20. }
  21. data = []byte{66, 129, 70}
  22. if bytes.Compare(ec.calcECC(data, size), []byte{66, 129, 70, 138, 234, 82, 82, 95}) != 0 {
  23. t.Error("ECC Test 2 failed")
  24. }
  25. }