-
Notifications
You must be signed in to change notification settings - Fork 0
/
bmp_test.go
65 lines (60 loc) · 1.77 KB
/
bmp_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// bmp_test.go (c) 2013 David Rook
// need to re-write so failure of notBMP.bmp doesn't cause test to fail
package bmp
import (
"fmt"
"image"
_ "image/jpeg"
"os"
"testing"
)
const testDir = "./testdata/"
var (
okImages = []string{
"bit1bw-rnr.bmp", // 1 bit per pixel, uncompressed, 2 entry color table - working with my code
"bit1color2.bmp", // working with my code
"bit4-test.bmp", // working with my code
"bit4comp-test.bmp", // RLE4 working with my code
"bit8-gray-rnr.bmp", // working with my code
"bit8comp-test.bmp", // RLE8 working with my code
"bit8comp-rnr.bmp", // RLE8 working with my code
"bit8-test.bmp", // working with my code - original failed to read header correctly
"bit24uncomp-marbles.bmp", // working large 24 bit uncompressed
"bit24uncomp-rnr.bmp", // 24 bit per pixel, uncompressed, working with original
"bit24-teststrip.bmp", // working 24 bit uncompressed
"whirlpool.jpg", // fails as required with bad magic if called with bmp.Decode(), ok with image.Decode()
//"bit24-test.bmp", // air-moz
//"bit16-test.bmp",
//"bit32-test.bmp",
}
failImages = []string{
"notBMP.bmp", //
}
)
func Test_0001(t *testing.T) {
fmt.Printf("Test_0001\n")
errCt := 0
for i := 0; i < len(testImages); i++ {
fname := testImages[i]
fmt.Printf("%d Working on %s...\n", i, fname)
bf, err := os.Open(testDir + fname)
if err != nil {
t.Errorf("%v\n", err)
}
img, _, err := image.Decode(bf)
img = img // LINT
if err != nil {
fmt.Printf("%s Failed\n", fname)
t.Errorf("%v\n", err)
errCt++
} else {
bf.Close()
fmt.Printf("%s Passed\n", fname)
}
}
if errCt == 0 {
fmt.Printf("Test_0001 Pass\n")
} else {
fmt.Printf("Test_0001 Fail\n")
}
}