trailing data test for png
This commit is contained in:
parent
4d2d780a51
commit
ee79db8c88
2 changed files with 20 additions and 16 deletions
BIN
tests/images/png/trailing_data.png
Normal file
BIN
tests/images/png/trailing_data.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
|
@ -1,4 +1,4 @@
|
||||||
import pixie/common, pixie/fileformats/png, pngsuite, strformat
|
import pixie, pixie/fileformats/png, pngsuite, strformat
|
||||||
|
|
||||||
# for file in pngSuiteFiles:
|
# for file in pngSuiteFiles:
|
||||||
# let
|
# let
|
||||||
|
@ -13,19 +13,23 @@ import pixie/common, pixie/fileformats/png, pngsuite, strformat
|
||||||
# doAssert decoded.width == decoded2.width
|
# doAssert decoded.width == decoded2.width
|
||||||
# doAssert decoded.data == decoded2.data
|
# doAssert decoded.data == decoded2.data
|
||||||
|
|
||||||
for channels in 1 .. 4:
|
block:
|
||||||
var data: seq[uint8]
|
for channels in 1 .. 4:
|
||||||
for x in 0 ..< 16:
|
var data: seq[uint8]
|
||||||
for y in 0 ..< 16:
|
for x in 0 ..< 16:
|
||||||
var components = newSeq[uint8](channels)
|
for y in 0 ..< 16:
|
||||||
for i in 0 ..< channels:
|
var components = newSeq[uint8](channels)
|
||||||
components[i] = (x * 16).uint8
|
for i in 0 ..< channels:
|
||||||
data.add(components)
|
components[i] = (x * 16).uint8
|
||||||
let encoded = encodePng(16, 16, channels, data[0].addr, data.len)
|
data.add(components)
|
||||||
|
let encoded = encodePng(16, 16, channels, data[0].addr, data.len)
|
||||||
|
|
||||||
for file in pngSuiteCorruptedFiles:
|
for file in pngSuiteCorruptedFiles:
|
||||||
try:
|
try:
|
||||||
discard decodePng(readFile(&"tests/images/png/pngsuite/{file}.png"))
|
discard decodePng(readFile(&"tests/images/png/pngsuite/{file}.png"))
|
||||||
doAssert false
|
doAssert false
|
||||||
except PixieError:
|
except PixieError:
|
||||||
discard
|
discard
|
||||||
|
|
||||||
|
block:
|
||||||
|
discard readImage("tests/images/png/trailing_data.png")
|
||||||
|
|
Loading…
Reference in a new issue