blob: 7418e698682e24bd45c66cbc3e153efe2b83d3b0 [file] [log] [blame]
Guido van Rossumfa7fcb91994-01-12 09:55:11 +00001# Testing rgbimg module
2
3import rgbimg, os
4
5error = 'test_rgbimg.error'
6
7print 'RGBimg test suite:'
8
9def testimg(rgb_file, raw_file):
10 width, height = rgbimg.sizeofimage(rgb_file)
11 rgb = rgbimg.longimagedata(rgb_file)
12 if len(rgb) != width * height * 4:
13 raise error, 'bad image length'
14 raw = open(raw_file, 'r').read()
15 if rgb != raw:
16 raise error, 'images don\'t match for '+rgb_file+' and '+raw_file
17 for depth in [1, 3, 4]:
18 rgbimg.longstoimage(rgb, width, height, depth, '@.rgb')
19 os.unlink('@.rgb')
20
21ttob = rgbimg.ttob(0)
22if ttob != 0:
23 raise error, 'ttob should start out as zero'
24
25testimg('test.rgb', 'test.rawimg')
26
27ttob = rgbimg.ttob(1)
28if ttob != 0:
29 raise error, 'ttob should be zero'
30
31testimg('test.rgb', 'test.rawimg.rev')
32
33ttob = rgbimg.ttob(0)
34if ttob != 1:
35 raise error, 'ttob should be one'
36
37ttob = rgbimg.ttob(0)
38if ttob != 0:
39 raise error, 'ttob should be zero'