corrupted file tests
This commit is contained in:
parent
344063ddbc
commit
c0803c3336
2 changed files with 99 additions and 72 deletions
|
@ -1,73 +1,93 @@
|
||||||
const pngSuiteFiles* = [
|
# http://www.schaik.com/pngsuite/
|
||||||
# Basic
|
|
||||||
"basn0g01", # black & white
|
|
||||||
"basn0g02", # 2 bit (4 level) grayscale
|
|
||||||
"basn0g04", # 4 bit (16 level) grayscale
|
|
||||||
"basn0g08", # 8 bit (256 level) grayscale
|
|
||||||
# "basn0g16", # 16 bit (64k level) grayscale
|
|
||||||
"basn2c08", # 3x8 bits rgb color
|
|
||||||
# "basn2c16", # 3x16 bits rgb color
|
|
||||||
"basn3p01", # 1 bit (2 color) paletted
|
|
||||||
"basn3p02", # 2 bit (4 color) paletted
|
|
||||||
"basn3p04", # 4 bit (16 color) paletted
|
|
||||||
"basn3p08", # 8 bit (256 color) paletted
|
|
||||||
"basn4a08", # 8 bit grayscale + 8 bit alpha-channel
|
|
||||||
# "basn4a16", # 16 bit grayscale + 16 bit alpha-channel
|
|
||||||
"basn6a08", # 3x8 bits rgb color + 8 bit alpha-channel
|
|
||||||
# "basn6a16", # 3x16 bits rgb color + 16 bit alpha-channel
|
|
||||||
|
|
||||||
# Interlaced
|
const
|
||||||
# "basi0g01", # black & white
|
pngSuiteFiles* = [
|
||||||
# "basi0g02", # 2 bit (4 level) grayscale
|
# Basic
|
||||||
# "basi0g04", # 4 bit (16 level) grayscale
|
"basn0g01", # black & white
|
||||||
# "basi0g08", # 8 bit (256 level) grayscale
|
"basn0g02", # 2 bit (4 level) grayscale
|
||||||
# "basi0g16", # 16 bit (64k level) grayscale
|
"basn0g04", # 4 bit (16 level) grayscale
|
||||||
# "basi2c08", # 3x8 bits rgb color
|
"basn0g08", # 8 bit (256 level) grayscale
|
||||||
# "basi2c16", # 3x16 bits rgb color
|
# "basn0g16", # 16 bit (64k level) grayscale
|
||||||
# "basi3p01", # 1 bit (2 color) paletted
|
"basn2c08", # 3x8 bits rgb color
|
||||||
# "basi3p02", # 2 bit (4 color) paletted
|
# "basn2c16", # 3x16 bits rgb color
|
||||||
# "basi3p04", # 4 bit (16 color) paletted
|
"basn3p01", # 1 bit (2 color) paletted
|
||||||
# "basi3p08", # 8 bit (256 color) paletted
|
"basn3p02", # 2 bit (4 color) paletted
|
||||||
# "basi4a08", # 8 bit grayscale + 8 bit alpha-channel
|
"basn3p04", # 4 bit (16 color) paletted
|
||||||
# "basi4a16", # 16 bit grayscale + 16 bit alpha-channel
|
"basn3p08", # 8 bit (256 color) paletted
|
||||||
# "basi6a08", # 3x8 bits rgb color + 8 bit alpha-channel
|
"basn4a08", # 8 bit grayscale + 8 bit alpha-channel
|
||||||
# "basi6a16", # 3x16 bits rgb color + 16 bit alpha-channel
|
# "basn4a16", # 16 bit grayscale + 16 bit alpha-channel
|
||||||
|
"basn6a08", # 3x8 bits rgb color + 8 bit alpha-channel
|
||||||
|
# "basn6a16", # 3x16 bits rgb color + 16 bit alpha-channel
|
||||||
|
|
||||||
# Odd sizes
|
# Interlaced
|
||||||
# "s01i3p01", # 1x1 paletted file, interlaced
|
# "basi0g01", # black & white
|
||||||
"s01n3p01", # 1x1 paletted file, no interlacing
|
# "basi0g02", # 2 bit (4 level) grayscale
|
||||||
# "s02i3p01", # 2x2 paletted file, interlaced
|
# "basi0g04", # 4 bit (16 level) grayscale
|
||||||
"s02n3p01", # 2x2 paletted file, no interlacing
|
# "basi0g08", # 8 bit (256 level) grayscale
|
||||||
# "s03i3p01", # 3x3 paletted file, interlaced
|
# "basi0g16", # 16 bit (64k level) grayscale
|
||||||
"s03n3p01", # 3x3 paletted file, no interlacing
|
# "basi2c08", # 3x8 bits rgb color
|
||||||
# "s04i3p01", # 4x4 paletted file, interlaced
|
# "basi2c16", # 3x16 bits rgb color
|
||||||
"s04n3p01", # 4x4 paletted file, no interlacing
|
# "basi3p01", # 1 bit (2 color) paletted
|
||||||
# "s05i3p02", # 5x5 paletted file, interlaced
|
# "basi3p02", # 2 bit (4 color) paletted
|
||||||
"s05n3p02", # 5x5 paletted file, no interlacing
|
# "basi3p04", # 4 bit (16 color) paletted
|
||||||
# "s06i3p02", # 6x6 paletted file, interlaced
|
# "basi3p08", # 8 bit (256 color) paletted
|
||||||
"s06n3p02", # 6x6 paletted file, no interlacing
|
# "basi4a08", # 8 bit grayscale + 8 bit alpha-channel
|
||||||
# "s07i3p02", # 7x7 paletted file, interlaced
|
# "basi4a16", # 16 bit grayscale + 16 bit alpha-channel
|
||||||
"s07n3p02", # 7x7 paletted file, no interlacing
|
# "basi6a08", # 3x8 bits rgb color + 8 bit alpha-channel
|
||||||
# "s08i3p02", # 8x8 paletted file, interlaced
|
# "basi6a16", # 3x16 bits rgb color + 16 bit alpha-channel
|
||||||
"s08n3p02", # 8x8 paletted file, no interlacing
|
|
||||||
# "s09i3p02", # 9x9 paletted file, interlaced
|
# Odd sizes
|
||||||
"s09n3p02", # 9x9 paletted file, no interlacing
|
# "s01i3p01", # 1x1 paletted file, interlaced
|
||||||
# "s32i3p04", # 32x32 paletted file, interlaced
|
"s01n3p01", # 1x1 paletted file, no interlacing
|
||||||
"s32n3p04", # 32x32 paletted file, no interlacing
|
# "s02i3p01", # 2x2 paletted file, interlaced
|
||||||
# "s33i3p04", # 33x33 paletted file, interlaced
|
"s02n3p01", # 2x2 paletted file, no interlacing
|
||||||
"s33n3p04", # 33x33 paletted file, no interlacing
|
# "s03i3p01", # 3x3 paletted file, interlaced
|
||||||
# "s34i3p04", # 34x34 paletted file, interlaced
|
"s03n3p01", # 3x3 paletted file, no interlacing
|
||||||
"s34n3p04", # 34x34 paletted file, no interlacing
|
# "s04i3p01", # 4x4 paletted file, interlaced
|
||||||
# "s35i3p04", # 35x35 paletted file, interlaced
|
"s04n3p01", # 4x4 paletted file, no interlacing
|
||||||
"s35n3p04", # 35x35 paletted file, no interlacing
|
# "s05i3p02", # 5x5 paletted file, interlaced
|
||||||
# "s36i3p04", # 36x36 paletted file, interlaced
|
"s05n3p02", # 5x5 paletted file, no interlacing
|
||||||
"s36n3p04", # 36x36 paletted file, no interlacing
|
# "s06i3p02", # 6x6 paletted file, interlaced
|
||||||
# "s37i3p04", # 37x37 paletted file, interlaced
|
"s06n3p02", # 6x6 paletted file, no interlacing
|
||||||
"s37n3p04", # 37x37 paletted file, no interlacing
|
# "s07i3p02", # 7x7 paletted file, interlaced
|
||||||
# "s38i3p04", # 38x38 paletted file, interlaced
|
"s07n3p02", # 7x7 paletted file, no interlacing
|
||||||
"s38n3p04", # 38x38 paletted file, no interlacing
|
# "s08i3p02", # 8x8 paletted file, interlaced
|
||||||
# "s39i3p04", # 39x39 paletted file, interlaced
|
"s08n3p02", # 8x8 paletted file, no interlacing
|
||||||
"s39n3p04", # 39x39 paletted file, no interlacing
|
# "s09i3p02", # 9x9 paletted file, interlaced
|
||||||
# "s40i3p04", # 40x40 paletted file, interlaced
|
"s09n3p02", # 9x9 paletted file, no interlacing
|
||||||
"s40n3p04", # 40x40 paletted file, no interlacing
|
# "s32i3p04", # 32x32 paletted file, interlaced
|
||||||
]
|
"s32n3p04", # 32x32 paletted file, no interlacing
|
||||||
|
# "s33i3p04", # 33x33 paletted file, interlaced
|
||||||
|
"s33n3p04", # 33x33 paletted file, no interlacing
|
||||||
|
# "s34i3p04", # 34x34 paletted file, interlaced
|
||||||
|
"s34n3p04", # 34x34 paletted file, no interlacing
|
||||||
|
# "s35i3p04", # 35x35 paletted file, interlaced
|
||||||
|
"s35n3p04", # 35x35 paletted file, no interlacing
|
||||||
|
# "s36i3p04", # 36x36 paletted file, interlaced
|
||||||
|
"s36n3p04", # 36x36 paletted file, no interlacing
|
||||||
|
# "s37i3p04", # 37x37 paletted file, interlaced
|
||||||
|
"s37n3p04", # 37x37 paletted file, no interlacing
|
||||||
|
# "s38i3p04", # 38x38 paletted file, interlaced
|
||||||
|
"s38n3p04", # 38x38 paletted file, no interlacing
|
||||||
|
# "s39i3p04", # 39x39 paletted file, interlaced
|
||||||
|
"s39n3p04", # 39x39 paletted file, no interlacing
|
||||||
|
# "s40i3p04", # 40x40 paletted file, interlaced
|
||||||
|
"s40n3p04", # 40x40 paletted file, no interlacing
|
||||||
|
]
|
||||||
|
|
||||||
|
pngSuiteCorruptedFiles* = [
|
||||||
|
"xs1n0g01", # signature byte 1 MSBit reset to zero
|
||||||
|
"xs2n0g01", # signature byte 2 is a 'Q'
|
||||||
|
"xs4n0g01", # signature byte 4 lowercase
|
||||||
|
"xs7n0g01", # 7th byte a space instead of control-Z
|
||||||
|
"xcrn0g04", # added cr bytes
|
||||||
|
"xlfn0g04", # added lf bytes
|
||||||
|
# "xhdn0g08", # incorrect IHDR checksum
|
||||||
|
"xc1n0g08", # color type 1
|
||||||
|
"xc9n2c08", # color type 9
|
||||||
|
"xd0n2c08", # bit-depth 0
|
||||||
|
"xd3n2c08", # bit-depth 3
|
||||||
|
"xd9n2c08", # bit-depth 99
|
||||||
|
"xdtn0g01", # missing IDAT chunk
|
||||||
|
# "xcsn0g01" # incorrect IDAT checksum
|
||||||
|
]
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import pixie/fileformats/png, strformat, pngsuite
|
import pixie/fileformats/png, strformat, pngsuite, pixie/common
|
||||||
|
|
||||||
for file in pngSuiteFiles:
|
for file in pngSuiteFiles:
|
||||||
let
|
let
|
||||||
|
@ -20,3 +20,10 @@ for channels in 1 .. 4:
|
||||||
components[i] = (x * 16).uint8
|
components[i] = (x * 16).uint8
|
||||||
data.add(components)
|
data.add(components)
|
||||||
let encoded = encodePng(16, 16, channels, data[0].addr, data.len)
|
let encoded = encodePng(16, 16, channels, data[0].addr, data.len)
|
||||||
|
|
||||||
|
for file in pngSuiteCorruptedFiles:
|
||||||
|
try:
|
||||||
|
discard decodePng(readFile(&"tests/data/pngsuite/{file}.png"))
|
||||||
|
doAssert false
|
||||||
|
except PixieError:
|
||||||
|
discard
|
||||||
|
|
Loading…
Reference in a new issue