MCPcopy Create free account
hub / github.com/boombuler/barcode / testEncode

Function testEncode

code128/encode_test.go:8–35  ·  view source on GitHub ↗
(t *testing.T, txt, testResult string)

Source from the content-addressed store, hash-verified

6)
7
8func 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
37func Test_EncodeFunctionChars(t *testing.T) {
38 encFNC1 := "11110101110"

Callers 6

Test_EncodeFunction · 0.85
Test_EncodeFunction · 0.85
Test_EncodeFunctionCharsFunction · 0.85
Test_EncodeCTableFunction · 0.85
Test_Issue16Function · 0.85
Test_DatalogicFunction · 0.85

Calls 3

EncodeFunction · 0.70
BoundsMethod · 0.45
AtMethod · 0.45

Tested by

no test coverage detected