| 1 | package rssscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/ |
| 2 | |
| 3 | import ( |
| 4 | "reflectscip-go gomod github.com/golang/go/src go1.17 reflect/" |
| 5 | "testingscip-go gomod github.com/golang/go/src go1.17 testing/" |
| 6 | |
| 7 | "github.com/makiuchi-d/gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/" |
| 8 | "github.com/makiuchi-d/gozxing/testutilscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/testutil`/" |
| 9 | ) |
| 10 | |
| 11 | func TestRSS14Reader_addOrTallyscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/TestRSS14Reader_addOrTally().(t *testingscip-go gomod github.com/golang/go/src go1.17 testing/.Tscip-go gomod github.com/golang/go/src go1.17 testing/T#) { |
| 12 | reader := NewRSS14Readerscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/NewRSS14Reader().().(*rss14Readerscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/rss14Reader#) |
| 13 | pairs := []*Pairscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/Pair#{} |
| 14 | |
| 15 | pairs = reader.addOrTallyscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/rss14Reader#addOrTally().(pairs, nil) |
| 16 | if l := len(pairs); l != 0 { |
| 17 | t.Fatalfscip-go gomod github.com/golang/go/src go1.17 testing/common#Fatalf().("addOrTally length = %v, wants 0", l) |
| 18 | } |
| 19 | |
| 20 | p1 := NewPairscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/NewPair().(60, 5000, NewFinderPatternscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/NewFinderPattern().(2, []int{178, 247}, 178, 247, 154)) |
| 21 | p2 := NewPairscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/NewPair().(97250, 19572, NewFinderPatternscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/NewFinderPattern().(5, []int{178, 247}, 178, 247, 154)) |
| 22 | p3 := NewPairscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/NewPair().(60, 5000, NewFinderPatternscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/NewFinderPattern().(2, []int{178, 247}, 178, 247, 154)) |
| 23 | |
| 24 | pairs = reader.addOrTallyscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/rss14Reader#addOrTally().(pairs, p1) |
| 25 | if l := len(pairs); l != 1 { |
| 26 | t.Fatalfscip-go gomod github.com/golang/go/src go1.17 testing/common#Fatalf().("addOrTally length = %v, wants 1", l) |
| 27 | } |
| 28 | if pairs[0] != p1 { |
| 29 | t.Fatalfscip-go gomod github.com/golang/go/src go1.17 testing/common#Fatalf().("addOrTally [0] = %v, wants %v", pairs[0], p1) |
| 30 | } |
| 31 | if c := pairs[0].GetCountscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/Pair#GetCount().(); c != 0 { |
| 32 | t.Fatalfscip-go gomod github.com/golang/go/src go1.17 testing/common#Fatalf().("addOrTally [0].GetCount = %v, wants 0", c) |
| 33 | } |
| 34 | |
| 35 | pairs = reader.addOrTallyscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/rss14Reader#addOrTally().(pairs, p2) |
| 36 | if l := len(pairs); l != 2 { |
| 37 | t.Fatalfscip-go gomod github.com/golang/go/src go1.17 testing/common#Fatalf().("addOrTally length = %v, wants 2", l) |
| 38 | } |
| 39 | if pairs[0] != p1 { |
| 40 | t.Fatalfscip-go gomod github.com/golang/go/src go1.17 testing/common#Fatalf().("addOrTally [0] = %v, wants %v", pairs[0], p1) |
| 41 | } |
| 42 | if pairs[1] != p2 { |
| 43 | t.Fatalfscip-go gomod github.com/golang/go/src go1.17 testing/common#Fatalf().("addOrTally [1] = %v, wants %v", pairs[1], p2) |
| 44 | } |
| 45 | |
| 46 | pairs = reader.addOrTallyscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/rss14Reader#addOrTally().(pairs, p3) |
| 47 | if l := len(pairs); l != 2 { |
| 48 | t.Fatalfscip-go gomod github.com/golang/go/src go1.17 testing/common#Fatalf().("addOrTally length = %v, wants 2", l) |
| 49 | } |
| 50 | if c := pairs[0].GetCountscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/Pair#GetCount().(); c != 1 { |
| 51 | t.Fatalfscip-go gomod github.com/golang/go/src go1.17 testing/common#Fatalf().("addOrTally [0].GetCount = %v, wants 1", c) |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | func TestRSS14Reader_findFinderPatternscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/TestRSS14Reader_findFinderPattern().(t *testingscip-go gomod github.com/golang/go/src go1.17 testing/.Tscip-go gomod github.com/golang/go/src go1.17 testing/T#) { |
| 56 | reader := NewRSS14Readerscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/NewRSS14Reader().().(*rss14Readerscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/rss14Reader#) |
| 57 | |
| 58 | tests := []struct { |
| 59 | row string |
| 60 | right bool |
| 61 | wants []int |
| 62 | }{ |
| 63 | {"00011000", false, nil}, |
| 64 | {"00100011100000001011", false, []int{6, 18}}, |
| 65 | {"00100000111111101000", true, []int{3, 17}}, |
| 66 | } |
| 67 | |
| 68 | for _, test := range tests { |
| 69 | row := testutilscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/testutil`/.NewBitArrayFromStringscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/testutil`/NewBitArrayFromString().(test.row) |
| 70 | r, e := reader.findFinderPatternscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/rss14Reader#findFinderPattern().(row, test.right) |
| 71 | |
| 72 | if test.wants == nil { |
| 73 | 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 { |
| 74 | t.Fatalfscip-go gomod github.com/golang/go/src go1.17 testing/common#Fatalf().("findFinderPattern(%v,%v) must NotFoundException, %T", test.row, test.right, e) |
| 75 | } |
| 76 | continue |
| 77 | } |
| 78 | |
| 79 | if !reflectscip-go gomod github.com/golang/go/src go1.17 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.17 reflect/DeepEqual().(r, test.wants) { |
| 80 | t.Fatalfscip-go gomod github.com/golang/go/src go1.17 testing/common#Fatalf().("findFinderPattern(%v,%v) = %v, wants %v", test.row, test.right, r, test.wants) |
| 81 | } |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | func TestRSS14Reader_parseFoundFinderPatternscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/TestRSS14Reader_parseFoundFinderPattern().(t *testingscip-go gomod github.com/golang/go/src go1.17 testing/.Tscip-go gomod github.com/golang/go/src go1.17 testing/T#) { |
| 86 | reader := NewRSS14Readerscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/NewRSS14Reader().().(*rss14Readerscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/rss14Reader#) |
| 87 | |
| 88 | tests := []struct { |
| 89 | row string |
| 90 | right bool |
| 91 | wants *FinderPatternscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/FinderPattern# |
| 92 | }{ |
| 93 | {"0101111100000101", false, nil}, |
| 94 | {"00100011100000001011", false, NewFinderPatternscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/NewFinderPattern().(2, []int{3, 18}, 3, 18, 0)}, |
| 95 | {"0010000011111110100000000", true, NewFinderPatternscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/NewFinderPattern().(7, []int{2, 17}, 22, 7, 0)}, |
| 96 | } |
| 97 | |
| 98 | for _, test := range tests { |
| 99 | row := testutilscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/testutil`/.NewBitArrayFromStringscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/testutil`/NewBitArrayFromString().(test.row) |
| 100 | startEnd, e := reader.findFinderPatternscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/rss14Reader#findFinderPattern().(row, test.right) |
| 101 | if e != nil { |
| 102 | t.Fatalfscip-go gomod github.com/golang/go/src go1.17 testing/common#Fatalf().("findFinderPattern(%v) error: %v", test.row, e) |
| 103 | } |
| 104 | |
| 105 | r, e := reader.parseFoundFinderPatternscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/rss14Reader#parseFoundFinderPattern().(row, 0, test.right, startEnd) |
| 106 | if test.wants == nil { |
| 107 | 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 { |
| 108 | t.Fatalfscip-go gomod github.com/golang/go/src go1.17 testing/common#Fatalf().("parseFoundFinderPattern(%v) must NotFoundException: %T", test.row, e) |
| 109 | } |
| 110 | continue |
| 111 | } |
| 112 | |
| 113 | if !reflectscip-go gomod github.com/golang/go/src go1.17 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.17 reflect/DeepEqual().(*r, *test.wants) { |
| 114 | t.Fatalfscip-go gomod github.com/golang/go/src go1.17 testing/common#Fatalf().("parseFoundFinderPattern(%v) = %v, wants %v", test.row, r, test.wants) |
| 115 | } |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | func TestRSS14Reader_adjustOddEvenCountsscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/TestRSS14Reader_adjustOddEvenCounts().(t *testingscip-go gomod github.com/golang/go/src go1.17 testing/.Tscip-go gomod github.com/golang/go/src go1.17 testing/T#) { |
| 120 | reader := NewRSS14Readerscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/NewRSS14Reader().().(*rss14Readerscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/rss14Reader#) |
| 121 | |
| 122 | tests := []struct { |
| 123 | outside bool |
| 124 | oddCounts []int |
| 125 | oddErrors []float64 |
| 126 | oddWants []int |
| 127 | evenCounts []int |
| 128 | evenErrors []float64 |
| 129 | evenWants []int |
| 130 | }{ |
| 131 | { // mismatch=-2 |
| 132 | false, |
| 133 | []int{2, 2, 2, 1}, []float64{0, 0, 0, 0}, nil, |
| 134 | []int{2, 2, 1, 1}, []float64{0, 0, 0, 0}, nil, |
| 135 | }, |
| 136 | { // inc&decOdd error: incOdd & decEven, mismatch=1 oddParityBad & !evenParityBad |
| 137 | false, |
| 138 | []int{1, 1, 1, 1}, []float64{0, 0, 0, 0}, nil, |
| 139 | []int{3, 3, 3, 3}, []float64{0, 0, 0, 0}, nil, |
| 140 | }, |
| 141 | { // inc&decEven error: decOdd & incEven, mismatch=1 !oddParityBad & evenParityBad |
| 142 | false, |
| 143 | []int{3, 3, 3, 4}, []float64{0, 0, 0, 0}, nil, |
| 144 | []int{1, 1, 1, 0}, []float64{0, 0, 0, 0}, nil, |
| 145 | }, |
| 146 | { // decOdd & incEven: mismatch=0 |
| 147 | true, |
| 148 | []int{3, 3, 3, 5}, []float64{0.3, 0.1, 0, -0.1}, []int{3, 3, 3, 4}, |
| 149 | []int{1, 1, 0, 0}, []float64{0, -0.1, 0.2, 0.1}, []int{1, 1, 1, 0}, |
| 150 | }, |
| 151 | { // incOdd & decEven: mismatch=0 |
| 152 | true, |
| 153 | []int{1, 1, 0, 0}, []float64{0, -0.1, 0.2, 0.1}, []int{1, 1, 1, 0}, |
| 154 | []int{3, 3, 3, 5}, []float64{0.3, 0.1, 0, -0.1}, []int{3, 3, 3, 4}, |
| 155 | }, |
| 156 | { //decOdd: mismatch=1 oddParityBad |
| 157 | false, |
| 158 | []int{2, 2, 2, 2}, []float64{0.2, 0.4, -0.2, 0}, []int{2, 2, 1, 2}, |
| 159 | []int{2, 2, 2, 2}, []float64{0, 0, 0, 0}, []int{2, 2, 2, 2}, |
| 160 | }, |
| 161 | { //decEven: mismatch=1 evenParityBad |
| 162 | true, |
| 163 | []int{2, 2, 2, 2}, []float64{0, 0, 0, 0}, []int{2, 2, 2, 2}, |
| 164 | []int{2, 2, 2, 3}, []float64{0.2, 0.4, -0.2, 0}, []int{2, 2, 1, 3}, |
| 165 | }, |
| 166 | { //decOdd: mismatch=-1 oddParityBad |
| 167 | false, |
| 168 | []int{2, 2, 1, 1}, []float64{0.2, 0.4, -0.2, 0}, []int{2, 3, 1, 1}, |
| 169 | []int{2, 2, 2, 2}, []float64{0, 0, 0, 0}, []int{2, 2, 2, 2}, |
| 170 | }, |
| 171 | { //incEven: mismatch=-1 evenParityBad |
| 172 | true, |
| 173 | []int{2, 2, 1, 1}, []float64{0, 0, 0, 0}, []int{2, 2, 1, 1}, |
| 174 | []int{2, 2, 2, 3}, []float64{0.2, 0.4, -0.2, 0}, []int{2, 3, 2, 3}, |
| 175 | }, |
| 176 | { // mismatch=0 bothBad, odd>even |
| 177 | false, |
| 178 | []int{2, 2, 2, 2}, []float64{-0.1, 0, 0.1, 0.2}, []int{1, 2, 2, 2}, |
| 179 | []int{2, 2, 2, 1}, []float64{0.2, 0.4, -0.2, 0}, []int{2, 3, 2, 1}, |
| 180 | }, |
| 181 | { // mismatch=0 bothBad, even>odd |
| 182 | false, |
| 183 | []int{2, 2, 1, 1}, []float64{-0.1, 0, 0.1, 0.2}, []int{2, 2, 1, 2}, |
| 184 | []int{2, 2, 2, 3}, []float64{0.2, 0.4, -0.2, 0}, []int{2, 2, 1, 3}, |
| 185 | }, |
| 186 | } |
| 187 | |
| 188 | for i, test := range tests { |
| 189 | reader.oddCountsscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/AbstractRSSReader#oddCounts. = test.oddCounts |
| 190 | reader.evenCountsscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/AbstractRSSReader#evenCounts. = test.evenCounts |
| 191 | reader.oddRoundingErrorsscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/AbstractRSSReader#oddRoundingErrors. = test.oddErrors |
| 192 | reader.evenRoundingErrorsscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/AbstractRSSReader#evenRoundingErrors. = test.evenErrors |
| 193 | numModules := 15 |
| 194 | if test.outside { |
| 195 | numModules = 16 |
| 196 | } |
| 197 | |
| 198 | e := reader.adjustOddEvenCountsscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/rss14Reader#adjustOddEvenCounts().(test.outside, numModules) |
| 199 | |
| 200 | if test.oddWants == nil && test.evenWants == nil { |
| 201 | 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 { |
| 202 | t.Fatalfscip-go gomod github.com/golang/go/src go1.17 testing/common#Fatalf().("adjustOddEvenCounts[%v] must NotFoundException, %T", i, e) |
| 203 | } |
| 204 | continue |
| 205 | } |
| 206 | if e != nil { |
| 207 | t.Fatalfscip-go gomod github.com/golang/go/src go1.17 testing/common#Fatalf().("adjustOddEvenCounts[%v] error: %v", i, e) |
| 208 | } |
| 209 | if !reflectscip-go gomod github.com/golang/go/src go1.17 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.17 reflect/DeepEqual().(reader.oddCountsscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/AbstractRSSReader#oddCounts., test.oddWants) { |
| 210 | t.Fatalfscip-go gomod github.com/golang/go/src go1.17 testing/common#Fatalf().("adjustOddEvenCounts[%v] odd: %v, wants %v", i, reader.oddCountsscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/AbstractRSSReader#oddCounts., test.oddWants) |
| 211 | } |
| 212 | if !reflectscip-go gomod github.com/golang/go/src go1.17 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.17 reflect/DeepEqual().(reader.evenCountsscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/AbstractRSSReader#evenCounts., test.evenWants) { |
| 213 | t.Fatalfscip-go gomod github.com/golang/go/src go1.17 testing/common#Fatalf().("adjustOddEvenCounts[%v] even: %v, wants %v", i, reader.evenCountsscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/AbstractRSSReader#evenCounts., test.evenWants) |
| 214 | } |
| 215 | } |
| 216 | } |
| 217 | |
| 218 | func TestRSS14Reader_decodeDataCharacterscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/TestRSS14Reader_decodeDataCharacter().(t *testingscip-go gomod github.com/golang/go/src go1.17 testing/.Tscip-go gomod github.com/golang/go/src go1.17 testing/T#) { |
| 219 | reader := NewRSS14Readerscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/NewRSS14Reader().().(*rss14Readerscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/rss14Reader#) |
| 220 | |
| 221 | // error in adjustOddEvenCounts (odd[1,1,0,0]even[9,4,0,0]) |
| 222 | row := testutilscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/testutil`/.NewBitArrayFromStringscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/testutil`/NewBitArrayFromString().("00001" + "000111111110010" + "1000000000100001") |
| 223 | pattern := NewFinderPatternscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/NewFinderPattern().(0, []int{5, 20}, 5, 20, 0) |
| 224 | _, e := reader.decodeDataCharacterscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/rss14Reader#decodeDataCharacter().(row, pattern, false) |
| 225 | 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 { |
| 226 | t.Fatalfscip-go gomod github.com/golang/go/src go1.17 testing/common#Fatalf().("decodeDataCharacter must NotFoundException: %T", e) |
| 227 | } |
| 228 | |
| 229 | // outside: odd[1,2,2,1] even[1,5,1,3] |
| 230 | // inside: odd[1,2,3,1] even[3,1,1,3] |
| 231 | row = testutilscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/testutil`/.NewBitArrayFromStringscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/testutil`/NewBitArrayFromString().( |
| 232 | "10100111110010111" + "000111111110010" + "1110100010011101") |
| 233 | pattern = NewFinderPatternscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/NewFinderPattern().(0, []int{17, 32}, 17, 32, 0) |
| 234 | |
| 235 | // outside |
| 236 | r, e := reader.decodeDataCharacterscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/rss14Reader#decodeDataCharacter().(row, pattern, true) |
| 237 | if e != nil { |
| 238 | t.Fatalfscip-go gomod github.com/golang/go/src go1.17 testing/common#Fatalf().("decodeDataCharacter error: %v", e) |
| 239 | } |
| 240 | if v, wants := r.GetValuescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/DataCharacter#GetValue().(), 2315; v != wants { |
| 241 | t.Fatalfscip-go gomod github.com/golang/go/src go1.17 testing/common#Fatalf().("decodeDataCharacter(outside) value = %v, wants %v", v, wants) |
| 242 | } |
| 243 | if c, wants := r.GetChecksumPortionscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/DataCharacter#GetChecksumPortion().(), 7852; c != wants { |
| 244 | t.Fatalfscip-go gomod github.com/golang/go/src go1.17 testing/common#Fatalf().("decodeDataCharacter(outside) checksumPotion = %v, wants %v", c, wants) |
| 245 | } |
| 246 | |
| 247 | // inside |
| 248 | r, e = reader.decodeDataCharacterscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/rss14Reader#decodeDataCharacter().(row, pattern, false) |
| 249 | if e != nil { |
| 250 | t.Fatalfscip-go gomod github.com/golang/go/src go1.17 testing/common#Fatalf().("decodeDataCharacter error: %v", e) |
| 251 | } |
| 252 | if v, wants := r.GetValuescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/DataCharacter#GetValue().(), 842; v != wants { |
| 253 | t.Fatalfscip-go gomod github.com/golang/go/src go1.17 testing/common#Fatalf().("decodeDataCharacter(inside) value = %v, wants %v", v, wants) |
| 254 | } |
| 255 | if c, wants := r.GetChecksumPortionscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/DataCharacter#GetChecksumPortion().(), 7831; c != wants { |
| 256 | t.Fatalfscip-go gomod github.com/golang/go/src go1.17 testing/common#Fatalf().("decodeDataCharacter(inside) checksumPotion = %v, wants %v", c, wants) |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | func TestRSS14Reader_decodePairscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/TestRSS14Reader_decodePair().(t *testingscip-go gomod github.com/golang/go/src go1.17 testing/.Tscip-go gomod github.com/golang/go/src go1.17 testing/T#) { |
| 261 | reader := NewRSS14Readerscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/NewRSS14Reader().().(*rss14Readerscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/rss14Reader#) |
| 262 | |
| 263 | // error on findFinderPattern |
| 264 | row := testutilscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/testutil`/.NewBitArrayFromStringscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/testutil`/NewBitArrayFromString().("00011000") |
| 265 | if p := reader.decodePairscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/rss14Reader#decodePair().(row, false, 0, nil); p != nil { |
| 266 | t.Fatalfscip-go gomod github.com/golang/go/src go1.17 testing/common#Fatalf().("decodePair must be nil, %v", p) |
| 267 | } |
| 268 | |
| 269 | // error on parseFoundFinderPattern |
| 270 | row = testutilscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/testutil`/.NewBitArrayFromStringscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/testutil`/NewBitArrayFromString().("0101111100000101") |
| 271 | if p := reader.decodePairscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/rss14Reader#decodePair().(row, false, 0, nil); p != nil { |
| 272 | t.Fatalfscip-go gomod github.com/golang/go/src go1.17 testing/common#Fatalf().("decodePair must be nil, %v", p) |
| 273 | } |
| 274 | |
| 275 | // error on decodeDataCharacter(outside) |
| 276 | row = testutilscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/testutil`/.NewBitArrayFromStringscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/testutil`/NewBitArrayFromString().("" + |
| 277 | "01011101111111111" + "000111111110010" + "1001100110011001") |
| 278 | if p := reader.decodePairscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/rss14Reader#decodePair().(row, false, 0, nil); p != nil { |
| 279 | t.Fatalfscip-go gomod github.com/golang/go/src go1.17 testing/common#Fatalf().("decodePair must be nil, %v", p) |
| 280 | } |
| 281 | |
| 282 | // error on decodeDataCharacter(inside) |
| 283 | row = testutilscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/testutil`/.NewBitArrayFromStringscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/testutil`/NewBitArrayFromString().( |
| 284 | "10011001100110011" + "000111111110010" + "1000000000100001") |
| 285 | if p := reader.decodePairscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/rss14Reader#decodePair().(row, false, 0, nil); p != nil { |
| 286 | t.Fatalfscip-go gomod github.com/golang/go/src go1.17 testing/common#Fatalf().("decodePair must be nil, %v", p) |
| 287 | } |
| 288 | |
| 289 | rps := make([]gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.ResultPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#, 0) |
| 290 | hints := map[gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.DecodeHintTypescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/DecodeHintType#]interface{}{ |
| 291 | gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.DecodeHintType_NEED_RESULT_POINT_CALLBACKscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/DecodeHintType_NEED_RESULT_POINT_CALLBACK.: gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.ResultPointCallbackscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPointCallback#( |
| 292 | func(rp gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.ResultPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#) { |
| 293 | rps = append(rps, rp) |
| 294 | }), |
| 295 | } |
| 296 | |
| 297 | // JIS X 0509 Annex F.1 |
| 298 | row = testutilscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/testutil`/.NewBitArrayFromStringscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/testutil`/NewBitArrayFromString().("" + |
| 299 | "01" + |
| 300 | "0001010111000111" + // 1: 31111333 |
| 301 | "011100000000010" + // check8: 13911 |
| 302 | "111010001001110" + // 2: 31131231 (rev) |
| 303 | "101101111001100" + // 4: 11214222 |
| 304 | "101111100000111" + // check1: 11553 (rev) |
| 305 | "0010011101110111" + // 3: 21231313 (rev) |
| 306 | "010") |
| 307 | |
| 308 | // left |
| 309 | p := reader.decodePairscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/rss14Reader#decodePair().(row, false, 0, hints) |
| 310 | if p == nil { |
| 311 | t.Fatalfscip-go gomod github.com/golang/go/src go1.17 testing/common#Fatalf().("decodePair(left) = nil") |
| 312 | } |
| 313 | if v, wants := p.GetValuescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/DataCharacter#GetValue().(), 2733309; v != wants { |
| 314 | t.Fatalfscip-go gomod github.com/golang/go/src go1.17 testing/common#Fatalf().("left value = %v, wants %v", v, wants) |
| 315 | } |
| 316 | if l, wants := len(rps), 1; l != wants { |
| 317 | t.Fatalfscip-go gomod github.com/golang/go/src go1.17 testing/common#Fatalf().("len(rps) = %v, wants %v", l, wants) |
| 318 | } |
| 319 | if x, y, wx, wy := rps[0].GetXscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetX.(), rps[0].GetYscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetY.(), 25.0, 0.0; x != wx || y != wy { |
| 320 | t.Fatalfscip-go gomod github.com/golang/go/src go1.17 testing/common#Fatalf().("rps[0] = (%v,%v), wants (%v,%v)", x, y, wx, wy) |
| 321 | } |
| 322 | |
| 323 | // right |
| 324 | row.Reversescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BitArray#Reverse().() |
| 325 | p = reader.decodePairscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/rss14Reader#decodePair().(row, true, 0, hints) |
| 326 | if p == nil { |
| 327 | t.Fatalfscip-go gomod github.com/golang/go/src go1.17 testing/common#Fatalf().("decodePair(right) = nil") |
| 328 | } |
| 329 | if v, wants := p.GetValuescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/DataCharacter#GetValue().(), 1170097; v != wants { |
| 330 | t.Fatalfscip-go gomod github.com/golang/go/src go1.17 testing/common#Fatalf().("right value = %v, wants %v", v, wants) |
| 331 | } |
| 332 | if l, wants := len(rps), 2; l != wants { |
| 333 | t.Fatalfscip-go gomod github.com/golang/go/src go1.17 testing/common#Fatalf().("len(rps) = %v, wants %v", l, wants) |
| 334 | } |
| 335 | if x, y, wx, wy := rps[1].GetXscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetX.(), rps[1].GetYscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetY.(), 70.0, 0.0; x != wx || y != wy { |
| 336 | t.Fatalfscip-go gomod github.com/golang/go/src go1.17 testing/common#Fatalf().("rps[0] = (%v,%v), wants (%v,%v)", x, y, wx, wy) |
| 337 | } |
| 338 | } |
| 339 | |
| 340 | func TestCheckChecksumscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/TestCheckChecksum().(t *testingscip-go gomod github.com/golang/go/src go1.17 testing/.Tscip-go gomod github.com/golang/go/src go1.17 testing/T#) { |
| 341 | left := NewPairscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/NewPair().(2733309, 40924, NewFinderPatternscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/NewFinderPattern().(8, []int{18, 33}, 18, 33, 0)) |
| 342 | right := NewPairscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/NewPair().(1170097, 32656, NewFinderPatternscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/NewFinderPattern().(1, []int{19, 34}, 77, 62, 0)) |
| 343 | |
| 344 | if !checkChecksumscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/checkChecksum().(left, right) { |
| 345 | t.Fatalfscip-go gomod github.com/golang/go/src go1.17 testing/common#Fatalf().("checkChecksum must true") |
| 346 | } |
| 347 | |
| 348 | left.checksumPortionscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/DataCharacter#checksumPortion.++ |
| 349 | if checkChecksumscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/checkChecksum().(left, right) { |
| 350 | t.Fatalfscip-go gomod github.com/golang/go/src go1.17 testing/common#Fatalf().("checkChecksum must false") |
| 351 | } |
| 352 | |
| 353 | left.checksumPortionscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/DataCharacter#checksumPortion.-- |
| 354 | right.checksumPortionscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/DataCharacter#checksumPortion.++ |
| 355 | if checkChecksumscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/checkChecksum().(left, right) { |
| 356 | t.Fatalfscip-go gomod github.com/golang/go/src go1.17 testing/common#Fatalf().("checkChecksum must false") |
| 357 | } |
| 358 | |
| 359 | right.checksumPortionscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/DataCharacter#checksumPortion.-- |
| 360 | left.finderPatternscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/Pair#finderPattern..valuescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/FinderPattern#value. = 2 |
| 361 | if checkChecksumscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/checkChecksum().(left, right) { |
| 362 | t.Fatalfscip-go gomod github.com/golang/go/src go1.17 testing/common#Fatalf().("checkChecksum must false") |
| 363 | } |
| 364 | |
| 365 | left.finderPatternscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/Pair#finderPattern..valuescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/FinderPattern#value. = 8 |
| 366 | right.finderPatternscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/Pair#finderPattern..valuescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/FinderPattern#value. = 2 |
| 367 | if checkChecksumscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/checkChecksum().(left, right) { |
| 368 | t.Fatalfscip-go gomod github.com/golang/go/src go1.17 testing/common#Fatalf().("checkChecksum must false") |
| 369 | } |
| 370 | } |
| 371 | |
| 372 | func TestConstructResultscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/TestConstructResult().(t *testingscip-go gomod github.com/golang/go/src go1.17 testing/.Tscip-go gomod github.com/golang/go/src go1.17 testing/T#) { |
| 373 | // 0123456789050 |
| 374 | // checkdigit: 0+1+6+3+12+5+18+7+24+9+0+5+0 mod 10 = 90 mod 10 = 0 |
| 375 | // Vleft= 27210(39476), Vright=2923880(30676) |
| 376 | // checksum=44+1, Cleft=5, Cright=0 |
| 377 | left := NewPairscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/NewPair().(27210, 39476, NewFinderPatternscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/NewFinderPattern().(5, []int{1, 3}, 13, 17, 10)) |
| 378 | right := NewPairscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/NewPair().(2923880, 30676, NewFinderPatternscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/NewFinderPattern().(0, []int{5, 7}, 31, 37, 20)) |
| 379 | |
| 380 | result := constructResultscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/constructResult().(left, right) |
| 381 | |
| 382 | if f, wants := result.GetBarcodeFormatscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/Result#GetBarcodeFormat().(), gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.BarcodeFormat_RSS_14scip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BarcodeFormat_RSS_14.; f != wants { |
| 383 | t.Fatalfscip-go gomod github.com/golang/go/src go1.17 testing/common#Fatalf().("result format = %v, wants %v", f, wants) |
| 384 | } |
| 385 | if txt, wants := result.GetTextscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/Result#GetText().(), "01234567890500"; txt != wants { |
| 386 | t.Fatalfscip-go gomod github.com/golang/go/src go1.17 testing/common#Fatalf().("result text = \"%v\", wants \"%v\"", txt, wants) |
| 387 | } |
| 388 | expectPoints := []gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.ResultPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#{ |
| 389 | gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.NewResultPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/NewResultPoint().(13, 10), |
| 390 | gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.NewResultPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/NewResultPoint().(17, 10), |
| 391 | gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.NewResultPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/NewResultPoint().(31, 20), |
| 392 | gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.NewResultPointscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/NewResultPoint().(37, 20), |
| 393 | } |
| 394 | if l, wants := len(result.GetResultPointsscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/Result#GetResultPoints().()), 4; l != wants { |
| 395 | t.Fatalfscip-go gomod github.com/golang/go/src go1.17 testing/common#Fatalf().("len(ResultPoints) = %v, wants %v", l, wants) |
| 396 | } |
| 397 | CHECKRESULTPOINTS: |
| 398 | for _, ep := range expectPoints { |
| 399 | ex := ep.GetXscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetX.() |
| 400 | ey := ep.GetYscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetY.() |
| 401 | for _, rp := range result.GetResultPointsscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/Result#GetResultPoints().() { |
| 402 | if x, y := rp.GetXscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetX.(), rp.GetYscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultPoint#GetY.(); x == ex && y == ey { |
| 403 | continue CHECKRESULTPOINTS |
| 404 | } |
| 405 | } |
| 406 | t.Fatalfscip-go gomod github.com/golang/go/src go1.17 testing/common#Fatalf().("ResultPoint must contains %v", ep) |
| 407 | } |
| 408 | } |
| 409 | |
| 410 | func TestRSS14Reader_DecodeRowscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/TestRSS14Reader_DecodeRow().(t *testingscip-go gomod github.com/golang/go/src go1.17 testing/.Tscip-go gomod github.com/golang/go/src go1.17 testing/T#) { |
| 411 | // 0123456789050 |
| 412 | // left: 123456789050 / 4537077 = 27210 |
| 413 | // right: 123456789050 % 4537077 = 2923880 |
| 414 | // left-out(1) = 27210 / 1597 = 17 |
| 415 | // group=1, odd=12,8, even=4,1, Teven=1 |
| 416 | // Vodd = 17 / 1 = 17, Veven = 17 % 1 = 0 |
| 417 | // odd:[1,3,3,5], even[1,1,1,1] |
| 418 | // left-in (2) = 27210 / 1597 = 61 |
| 419 | // group=1, odd=5,2 even=10,7 Todd=4 |
| 420 | // Vodd=61%4=1, Veven=61/4=15, |
| 421 | // odd[1,1,2,1], even[1,3,3,3] |
| 422 | // right-out(3) = 2923880 / 1597 = 1830 |
| 423 | // group=3, Gsum=961 odd=8,4 even=8,5, Teven=34 |
| 424 | // Vodd=(1830-961)/34=25, Veven=(1830-961)%34=19 |
| 425 | // odd[3,2,1,2], even[2,2,1,3] |
| 426 | // right-in (4) = 2923880 % 1597 = 1370 |
| 427 | // group=3, Gsum=1036, odd=9,6 even=6,3 Todd=48 |
| 428 | // Vodd=(1370-1036)%48=46 Veven=(1370-1036)/48=6 |
| 429 | // odd[4,2,2,1] even[2,1,1,2] |
| 430 | rowstr := "01" + |
| 431 | "0100010001000001" + // Cout=17(6376) |
| 432 | "001111100000010" + // pattern5 |
| 433 | "111011100111010" + // Cin=61(8275) |
| 434 | "111100110110100" + // Cin=1370(5563) |
| 435 | "101100000000111" + // pattern0 |
| 436 | "0001101001100111" + // Cout=1830(8424) |
| 437 | "01" |
| 438 | |
| 439 | reader := NewRSS14Readerscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/NewRSS14Reader().().(*rss14Readerscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/rss14Reader#) |
| 440 | |
| 441 | row := testutilscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/testutil`/.NewBitArrayFromStringscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/testutil`/NewBitArrayFromString().(rowstr[:50]) |
| 442 | _, e := reader.DecodeRowscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/rss14Reader#DecodeRow().(0, row, nil) |
| 443 | 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 { |
| 444 | t.Fatalfscip-go gomod github.com/golang/go/src go1.17 testing/common#Fatalf().("DecodeRow must NotFoundException, %T", e) |
| 445 | } |
| 446 | |
| 447 | row = testutilscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/testutil`/.NewBitArrayFromStringscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/testutil`/NewBitArrayFromString().(rowstr) |
| 448 | reader.DecodeRowscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/rss14Reader#DecodeRow().(0, row, nil) |
| 449 | reader.DecodeRowscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/rss14Reader#DecodeRow().(0, row, nil) |
| 450 | |
| 451 | row = testutilscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/testutil`/.NewBitArrayFromStringscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/testutil`/NewBitArrayFromString().(rowstr[30:]) |
| 452 | r, e := reader.DecodeRowscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/rss14Reader#DecodeRow().(2, row, nil) |
| 453 | if e != nil { |
| 454 | t.Fatalfscip-go gomod github.com/golang/go/src go1.17 testing/common#Fatalf().("DecodeRow error: %v", e) |
| 455 | } |
| 456 | if txt, wants := r.GetTextscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/Result#GetText().(), "01234567890500"; txt != wants { |
| 457 | t.Fatalfscip-go gomod github.com/golang/go/src go1.17 testing/common#Fatalf().("DecodeRow = \"%v\", wants \"%v\"", txt, wants) |
| 458 | } |
| 459 | |
| 460 | reader.Resetscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/rss14Reader#Reset().() |
| 461 | if left := reader.possibleLeftPairsscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/rss14Reader#possibleLeftPairs.; len(left) != 0 { |
| 462 | t.Fatalfscip-go gomod github.com/golang/go/src go1.17 testing/common#Fatalf().("Reset() failed: left=%v", left) |
| 463 | } |
| 464 | if right := reader.possibleRightPairsscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/rss14Reader#possibleRightPairs.; len(right) != 0 { |
| 465 | t.Fatalfscip-go gomod github.com/golang/go/src go1.17 testing/common#Fatalf().("Reset() failed: right=%v", right) |
| 466 | } |
| 467 | |
| 468 | _, e = reader.DecodeRowscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/rss14Reader#DecodeRow().(0, row, nil) |
| 469 | 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 { |
| 470 | t.Fatalfscip-go gomod github.com/golang/go/src go1.17 testing/common#Fatalf().("DecodeRow must NotFoundException, %T", e) |
| 471 | } |
| 472 | } |
| 473 | |
| 474 | func TestRSS14Readerscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/TestRSS14Reader().(t *testingscip-go gomod github.com/golang/go/src go1.17 testing/.Tscip-go gomod github.com/golang/go/src go1.17 testing/T#) { |
| 475 | // testdata from zxing core/src/test/resources/blackbox/rss14-[12]/ |
| 476 | reader := NewRSS14Readerscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing/oned/rss`/NewRSS14Reader().() |
| 477 | format := gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.BarcodeFormat_RSS_14scip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/BarcodeFormat_RSS_14. |
| 478 | harder := map[gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.DecodeHintTypescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/DecodeHintType#]interface{}{ |
| 479 | gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.DecodeHintType_TRY_HARDERscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/DecodeHintType_TRY_HARDER.: true, |
| 480 | } |
| 481 | |
| 482 | tests := []struct { |
| 483 | file string |
| 484 | wants string |
| 485 | hints map[gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.DecodeHintTypescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/DecodeHintType#]interface{} |
| 486 | metadata map[gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.ResultMetadataTypescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultMetadataType#]interface{} |
| 487 | }{ |
| 488 | // blackbox/rss14-1 |
| 489 | { |
| 490 | "testdata/1_1.png", "04412345678909", nil, |
| 491 | map[gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.ResultMetadataTypescip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultMetadataType#]interface{}{ |
| 492 | gozxingscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/.ResultMetadataType_SYMBOLOGY_IDENTIFIERscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/ResultMetadataType_SYMBOLOGY_IDENTIFIER.: "]e0", |
| 493 | }, |
| 494 | }, |
| 495 | {"testdata/1_2.png", "00821935106427", nil, nil}, |
| 496 | {"testdata/1_3.png", "00075678164125", nil, nil}, |
| 497 | {"testdata/1_4.png", "20012345678909", nil, nil}, |
| 498 | {"testdata/1_5.png", "00034567890125", nil, nil}, |
| 499 | {"testdata/1_6.png", "00012345678905", nil, nil}, |
| 500 | |
| 501 | // blackbox/rss14-2 |
| 502 | {"testdata/2_6.png", "02001234567893", harder, nil}, |
| 503 | {"testdata/2_7.png", "02001234567893", nil, nil}, |
| 504 | {"testdata/2_8.png", "02001234567893", nil, nil}, |
| 505 | {"testdata/2_13.png", "02001234567893", nil, nil}, |
| 506 | {"testdata/2_14.png", "02001234567893", harder, nil}, |
| 507 | {"testdata/2_20.png", "00012345678905", harder, nil}, |
| 508 | {"testdata/2_23.png", "00012345678905", harder, nil}, |
| 509 | {"testdata/2_24.png", "00012345678905", harder, nil}, |
| 510 | // original zxing could not read. |
| 511 | // {"testdata/2_1.png", "04412345678909", harder, nil}, |
| 512 | // {"testdata/2_2.png", "04412345678909", harder, nil}, |
| 513 | // {"testdata/2_3.png", "04412345678909", harder, nil}, |
| 514 | // {"testdata/2_4.png", "04412345678909", harder, nil}, |
| 515 | // {"testdata/2_5.png", "02001234567893", harder, nil}, |
| 516 | // {"testdata/2_9.png", "02001234567893", harder, nil}, |
| 517 | // {"testdata/2_10.png", "02001234567893", harder, nil}, |
| 518 | // {"testdata/2_11.png", "02001234567893", harder, nil}, |
| 519 | // {"testdata/2_12.png", "02001234567893", harder, nil}, |
| 520 | // {"testdata/2_15.png", "02001234567893", harder, nil}, |
| 521 | // {"testdata/2_16.png", "02001234567893", harder, nil}, |
| 522 | // {"testdata/2_17.png", "02001234567893", harder, nil}, |
| 523 | // {"testdata/2_18.png", "02001234567893", harder, nil}, |
| 524 | // {"testdata/2_19.png", "02001234567893", harder, nil}, |
| 525 | // {"testdata/2_21.png", "00012345678905", harder, nil}, |
| 526 | // {"testdata/2_22.png", "00012345678905", harder, nil}, |
| 527 | } |
| 528 | for _, test := range tests { |
| 529 | 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, test.hints, test.metadata) |
| 530 | reader.Resetscip-go gomod github.com/makiuchi-d/gozxing . `github.com/makiuchi-d/gozxing`/Reader#Reset.() |
| 531 | } |
| 532 | } |