| 1 | package onedscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned`/ |
| 2 | |
| 3 | import ( |
| 4 | "testingscip-go gomod github.com/golang/go/src go1.17 testing/" |
| 5 | |
| 6 | "github.com/makiuchi-d/gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/" |
| 7 | "github.com/makiuchi-d/gozxing/testutilscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/testutil`/" |
| 8 | ) |
| 9 | |
| 10 | func TestUPCEReader_decodeMiddlescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned`/TestUPCEReader_decodeMiddle().(t *testingscip-go gomod github.com/golang/go/src go1.17 testing/.Tscip-go gomod github.com/golang/go/src go1.17 testing/T#) { |
| 11 | reader := &upcEReaderscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned`/upcEReader#{ |
| 12 | decodeMiddleCountersscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned`/upcEReader#decodeMiddleCounters.: make([]int, 4), |
| 13 | } |
| 14 | result := make([]byte, 4) |
| 15 | startRange := []int{3, 6} |
| 16 | |
| 17 | row := gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.NewBitArrayscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/NewBitArray().(60) |
| 18 | |
| 19 | _, _, e := reader.decodeMiddlescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned`/upcEReader#decodeMiddle().(row, startRange, result[:0]) |
| 20 | if _, ok := e.(gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.NotFoundExceptionscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/NotFoundException#); !ok { |
| 21 | t.Fatalfscip-go gomod github.com/golang/go/src go1.17 testing/common#Fatalf().("decodeMiddle must be NotFoundException, %T", e) |
| 22 | } |
| 23 | |
| 24 | // 0-123453-1 |
| 25 | // 0-1 : GGLGLL |
| 26 | // [6-12] 1(G): 0110011 |
| 27 | row.Setscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitArray#Set().(7) |
| 28 | row.Setscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitArray#Set().(8) |
| 29 | row.Setscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitArray#Set().(11) |
| 30 | row.Setscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitArray#Set().(12) |
| 31 | // [13-19] 2(G): 0011011 |
| 32 | row.Setscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitArray#Set().(15) |
| 33 | row.Setscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitArray#Set().(16) |
| 34 | row.Setscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitArray#Set().(18) |
| 35 | row.Setscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitArray#Set().(19) |
| 36 | // [20-26] 3(L): 0111101 |
| 37 | row.Setscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitArray#Set().(21) |
| 38 | row.Setscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitArray#Set().(22) |
| 39 | row.Setscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitArray#Set().(23) |
| 40 | row.Setscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitArray#Set().(24) |
| 41 | row.Setscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitArray#Set().(26) |
| 42 | // [27-33] 4(G): 0011101 |
| 43 | row.Setscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitArray#Set().(29) |
| 44 | row.Setscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitArray#Set().(30) |
| 45 | row.Setscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitArray#Set().(31) |
| 46 | row.Setscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitArray#Set().(33) |
| 47 | // [34-40] 5(L): 0110001 |
| 48 | row.Setscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitArray#Set().(35) |
| 49 | row.Setscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitArray#Set().(36) |
| 50 | row.Setscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitArray#Set().(40) |
| 51 | // [41-47] 3(G, error): 0100001 |
| 52 | row.Setscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitArray#Set().(42) |
| 53 | row.Setscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitArray#Set().(47) |
| 54 | |
| 55 | _, _, e = reader.decodeMiddlescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned`/upcEReader#decodeMiddle().(row, startRange, result[:0]) |
| 56 | if _, ok := e.(gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.NotFoundExceptionscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/NotFoundException#); !ok { |
| 57 | t.Fatalfscip-go gomod github.com/golang/go/src go1.17 testing/common#Fatalf().("decodeMiddle must be NotFoundException, %T", e) |
| 58 | } |
| 59 | |
| 60 | // [41-47] 3(G): 0100001 |
| 61 | // [41-47] 3(L): 0111101 |
| 62 | row.Flipscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitArray#Flip().(43) |
| 63 | row.Flipscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitArray#Flip().(44) |
| 64 | row.Flipscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitArray#Flip().(45) |
| 65 | |
| 66 | offset, result, e := reader.decodeMiddlescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned`/upcEReader#decodeMiddle().(row, startRange, result[:0]) |
| 67 | if e != nil { |
| 68 | t.Fatalfscip-go gomod github.com/golang/go/src go1.17 testing/common#Fatalf().("decodeMiddle returns error, %v", e) |
| 69 | } |
| 70 | if offset != 48 { |
| 71 | t.Fatalfscip-go gomod github.com/golang/go/src go1.17 testing/common#Fatalf().("decodeMiddle offset = %v, expect 48", offset) |
| 72 | } |
| 73 | if str := string(result); str != "01234531" { |
| 74 | t.Fatalfscip-go gomod github.com/golang/go/src go1.17 testing/common#Fatalf().("decodeMiddle result = \"%v\", expect \"01234531\"", str) |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | func testConvertUPCEtoUPCAscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned`/testConvertUPCEtoUPCA().(t testingscip-go gomod github.com/golang/go/src go1.17 testing/.TBscip-go gomod github.com/golang/go/src go1.17 testing/TB#, upce, expect string) { |
| 79 | t.Helperscip-go gomod github.com/golang/go/src go1.17 testing/TB#Helper().() |
| 80 | upca := convertUPCEtoUPCAscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned`/convertUPCEtoUPCA().(upce) |
| 81 | if upca != expect { |
| 82 | t.Fatalfscip-go gomod github.com/golang/go/src go1.17 testing/TB#Fatalf().("UPCEtoUPCE: %s => %s, expect %s", upce, upca, expect) |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | func TestConvertUPCEtoUPCAscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned`/TestConvertUPCEtoUPCA().(t *testingscip-go gomod github.com/golang/go/src go1.17 testing/.Tscip-go gomod github.com/golang/go/src go1.17 testing/T#) { |
| 87 | testConvertUPCEtoUPCAscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned`/testConvertUPCEtoUPCA().(t, "0123450", "01200000345") |
| 88 | testConvertUPCEtoUPCAscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned`/testConvertUPCEtoUPCA().(t, "0123451", "01210000345") |
| 89 | testConvertUPCEtoUPCAscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned`/testConvertUPCEtoUPCA().(t, "0123452", "01220000345") |
| 90 | testConvertUPCEtoUPCAscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned`/testConvertUPCEtoUPCA().(t, "0123453", "01230000045") |
| 91 | testConvertUPCEtoUPCAscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned`/testConvertUPCEtoUPCA().(t, "0123454", "01234000005") |
| 92 | testConvertUPCEtoUPCAscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned`/testConvertUPCEtoUPCA().(t, "0123459", "01234500009") |
| 93 | testConvertUPCEtoUPCAscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned`/testConvertUPCEtoUPCA().(t, "01234531", "012300000451") |
| 94 | } |
| 95 | |
| 96 | func TestUPCEReaderscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned`/TestUPCEReader().(t *testingscip-go gomod github.com/golang/go/src go1.17 testing/.Tscip-go gomod github.com/golang/go/src go1.17 testing/T#) { |
| 97 | // testdata from zxing core/src/test/resources/blackbox/upce-1/ |
| 98 | reader := NewUPCEReaderscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned`/NewUPCEReader().() |
| 99 | format := gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.BarcodeFormat_UPC_Escip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BarcodeFormat_UPC_E. |
| 100 | |
| 101 | tests := []struct { |
| 102 | file string |
| 103 | wants string |
| 104 | }{ |
| 105 | {"testdata/upce/1.png", "01234565"}, |
| 106 | {"testdata/upce/2.png", "00123457"}, |
| 107 | {"testdata/upce/4.png", "01234531"}, |
| 108 | } |
| 109 | for _, test := range tests { |
| 110 | testutilscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/testutil`/.TestFilescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/testutil`/TestFile().(t, reader, test.file, test.wants, format, nil, nil) |
| 111 | } |
| 112 | } |