- commit
- f7be08535c03c5ad3c9d854ea682be2a7f95d12e
- parent
- f3168efedf8714b39ed1bb317c087505c8d4aaa6
- Author
- Tom Harwood <tfh@skip.org>
- Date
- 2014-04-18 17:26
Test data type optimisation close to the maximum encodable limit of 2953 bytes.
Diffstat
| M | encoder_test.go | 17 | ++++++++++++++++- |
| M | qrcode_test.go | 26 | ++++++++++++++++---------- |
2 files changed, 32 insertions, 11 deletions
diff --git a/encoder_test.go b/encoder_test.go
@@ -144,7 +144,6 @@ type testModeSegment struct {
144 144 }
145 145
146 146 func TestOptimiseEncoding(t *testing.T) {
147 -1
148 147 tests := []struct {
149 148 dataEncoderType dataEncoderType
150 149 actual []testModeSegment
@@ -221,6 +220,22 @@ func TestOptimiseEncoding(t *testing.T) {
221 220 {dataModeAlphanumeric, 26},
222 221 },
223 222 },
-1 223 {
-1 224 dataEncoderType27To40,
-1 225 []testModeSegment{
-1 226 {dataModeByte, 1},
-1 227 {dataModeNumeric, 1},
-1 228 {dataModeByte, 1},
-1 229 {dataModeNumeric, 1},
-1 230 {dataModeByte, 1},
-1 231 {dataModeNumeric, 1},
-1 232 {dataModeByte, 1},
-1 233 {dataModeNumeric, 1},
-1 234 },
-1 235 []testModeSegment{
-1 236 {dataModeByte, 8},
-1 237 },
-1 238 },
224 239 }
225 240
226 241 for _, test := range tests {
diff --git a/qrcode_test.go b/qrcode_test.go
@@ -14,37 +14,43 @@ func TestQRCodeMaxCapacity(t *testing.T) {
14 14 }
15 15
16 16 tests := []struct {
17 -1 char byte
18 -1 maxChars int
-1 17 string string
-1 18 numRepetitions int
19 19 }{
20 20 {
21 -1 '0',
-1 21 "0",
22 22 7089,
23 23 },
24 24 {
25 -1 'A',
-1 25 "A",
26 26 4296,
27 27 },
28 28 {
29 -1 '#',
-1 29 "#",
30 30 2953,
31 31 },
-1 32 // Alternate byte/numeric data types. Optimises to 2,952 bytes.
-1 33 {
-1 34 "#1",
-1 35 1476,
-1 36 },
32 37 }
33 38
34 39 for _, test := range tests {
35 -1 _, err := New(strings.Repeat(string(test.char), test.maxChars), Low)
-1 40 _, err := New(strings.Repeat(test.string, test.numRepetitions), Low)
36 41
37 42 if err != nil {
38 -1 t.Errorf("%d x '%c' got %s expected success", test.maxChars, test.char, err.Error())
-1 43 t.Errorf("%d x '%s' got %s expected success", test.numRepetitions,
-1 44 test.string, err.Error())
39 45 }
40 46 }
41 47
42 48 for _, test := range tests {
43 -1 _, err := New(strings.Repeat(string(test.char), test.maxChars+1), Low)
-1 49 _, err := New(strings.Repeat(test.string, test.numRepetitions+1), Low)
44 50
45 51 if err == nil {
46 -1 t.Errorf("%d x '%c' chars encodable, expected not encodable",
47 -1 test.maxChars+1, test.char)
-1 52 t.Errorf("%d x '%s' chars encodable, expected not encodable",
-1 53 test.numRepetitions+1, test.string)
48 54 }
49 55 }
50 56 }