@@ -96,7 +96,7 @@ func compare(t *testing.T, fileName string, img1, img2 image.Image) {
96
96
}
97
97
}
98
98
99
- func testFile (t * testing.T , fileName string , w , h int , inverse , align bool ) {
99
+ func testFile (t * testing.T , fileName string , mode , w , h int , inverse , align bool ) {
100
100
101
101
f , err := os .Open (fileName )
102
102
if err != nil {
@@ -105,8 +105,8 @@ func testFile(t *testing.T, fileName string, w, h int, inverse, align bool) {
105
105
}
106
106
defer f .Close ()
107
107
108
- // Read & decode CCITT Group 4 file into buf.
109
- r := NewReader (f , w , inverse , align )
108
+ // Read a CCITT encoded file and decode it into buf.
109
+ r := NewReader (f , mode , w , inverse , align )
110
110
buf , err := ioutil .ReadAll (r )
111
111
if err != nil {
112
112
t .Errorf ("%s: %v" , fileName , err )
@@ -126,32 +126,37 @@ func testFile(t *testing.T, fileName string, w, h int, inverse, align bool) {
126
126
return
127
127
}
128
128
129
- // Compare images
129
+ // Compare images.
130
130
compare (t , fnNoExt , img1 , img2 )
131
131
}
132
132
133
133
func TestCCITT (t * testing.T ) {
134
134
135
- // Test Group 4 encoding
136
-
137
135
for _ , tt := range []struct {
138
136
fileName string
137
+ mode int
139
138
w , h int
140
139
inverse bool
141
140
align bool
142
141
}{
143
- {"testdata/amt.gr4" , 43 , 38 , false , false },
144
- {"testdata/lc.gr4" , 154 , 154 , false , false },
145
- {"testdata/do.gr4" , 613 , 373 , true , false }, // <BlackIs1, true>
146
- {"testdata/t6diagram.gr4" , 1163 , 2433 , false , false },
147
- {"testdata/Wonderwall.gr4" , 2312 , 3307 , false , false }, // extracted from pdfcpu/pkg/api/testdata/Wonderwall.pdf
148
- {"testdata/hoare.gr4" , 2550 , 3300 , false , false },
149
- {"testdata/jphys.gr4" , 3440 , 5200 , false , false },
150
- {"testdata/hl.gr4" , 2548 , 3300 , false , true }, // <EncodedByteAlign, true> <EndOfLine, false>
151
- {"testdata/ho2.gr4" , 2040 , 2640 , false , false },
152
- {"testdata/sie.gr4" , 3310 , 8672 , false , false },
142
+
143
+ // Test Group 3 decoding
144
+ {"testdata/scan1.gr3" , Group3 , 2480 , 3508 , false , false },
145
+ {"testdata/scan2.gr3" , Group3 , 1656 , 2339 , false , false },
146
+
147
+ // // Test Group 4 decoding
148
+ {"testdata/amt.gr4" , Group4 , 43 , 38 , false , false },
149
+ {"testdata/lc.gr4" , Group4 , 154 , 154 , false , false },
150
+ {"testdata/do.gr4" , Group4 , 613 , 373 , true , false }, // <BlackIs1, true>
151
+ {"testdata/t6diagram.gr4" , Group4 , 1163 , 2433 , false , false },
152
+ {"testdata/Wonderwall.gr4" , Group4 , 2312 , 3307 , false , false },
153
+ {"testdata/hoare.gr4" , Group4 , 2550 , 3300 , false , false },
154
+ {"testdata/jphys.gr4" , Group4 , 3440 , 5200 , false , false },
155
+ {"testdata/hl.gr4" , Group4 , 2548 , 3300 , false , true }, // <EncodedByteAlign, true>
156
+ {"testdata/ho2.gr4" , Group4 , 2040 , 2640 , false , false },
157
+ {"testdata/sie.gr4" , Group4 , 3310 , 8672 , false , false },
153
158
} {
154
- testFile (t , tt .fileName , tt .w , tt .h , tt .inverse , tt .align )
159
+ testFile (t , tt .fileName , tt .mode , tt . w , tt .h , tt .inverse , tt .align )
155
160
}
156
161
157
162
}
0 commit comments