Guido van Rossum | fa7fcb9 | 1994-01-12 09:55:11 +0000 | [diff] [blame^] | 1 | # Testing rgbimg module |
| 2 | |
| 3 | import rgbimg, os |
| 4 | |
| 5 | error = 'test_rgbimg.error' |
| 6 | |
| 7 | print 'RGBimg test suite:' |
| 8 | |
| 9 | def 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 | |
| 21 | ttob = rgbimg.ttob(0) |
| 22 | if ttob != 0: |
| 23 | raise error, 'ttob should start out as zero' |
| 24 | |
| 25 | testimg('test.rgb', 'test.rawimg') |
| 26 | |
| 27 | ttob = rgbimg.ttob(1) |
| 28 | if ttob != 0: |
| 29 | raise error, 'ttob should be zero' |
| 30 | |
| 31 | testimg('test.rgb', 'test.rawimg.rev') |
| 32 | |
| 33 | ttob = rgbimg.ttob(0) |
| 34 | if ttob != 1: |
| 35 | raise error, 'ttob should be one' |
| 36 | |
| 37 | ttob = rgbimg.ttob(0) |
| 38 | if ttob != 0: |
| 39 | raise error, 'ttob should be zero' |