(t *testing.T, txt, testResult string)
| 6 | ) |
| 7 | |
| 8 | func testEncode(t *testing.T, txt, testResult string) { |
| 9 | code, err := Encode(txt) |
| 10 | if err != nil || code == nil { |
| 11 | t.Error(err) |
| 12 | } else { |
| 13 | if code.Bounds().Max.X != len(testResult) { |
| 14 | t.Errorf("%v: length missmatch. Got %d expected %d", txt, code.Bounds().Max.X, len(testResult)) |
| 15 | } else { |
| 16 | encoded := "" |
| 17 | failed := false |
| 18 | for i, r := range testResult { |
| 19 | if code.At(i, 0) == color.Black { |
| 20 | encoded += "1" |
| 21 | } else { |
| 22 | encoded += "0" |
| 23 | } |
| 24 | |
| 25 | if (code.At(i, 0) == color.Black) != (r == '1') { |
| 26 | failed = true |
| 27 | t.Errorf("%v: code missmatch on position %d", txt, i) |
| 28 | } |
| 29 | } |
| 30 | if failed { |
| 31 | t.Log("Encoded: ", encoded) |
| 32 | } |
| 33 | } |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | func Test_EncodeFunctionChars(t *testing.T) { |
| 38 | encFNC1 := "11110101110" |
no test coverage detected