pixie/tests/fuzz_qoi.nim

26 lines
563 B
Nim
Raw Normal View History

2022-01-03 23:41:36 +00:00
import pixie/common, pixie/fileformats/qoi, std/random, strformat
2022-01-01 22:50:23 +00:00
randomize()
let original = readFile("tests/fileformats/qoi/testcard_rgba.qoi")
for i in 0 ..< 10_000:
var data = original
let
pos = rand(data.len)
2022-01-03 23:41:36 +00:00
value = rand(255).uint8
data[pos] = value.char
echo &"{i} {pos} {value}"
2022-01-01 22:50:23 +00:00
try:
2022-01-03 23:41:36 +00:00
let img = decodeQoi(data)
2022-01-01 22:50:23 +00:00
doAssert img.height > 0 and img.width > 0
except PixieError:
discard
data = data[0 ..< pos]
try:
2022-01-03 23:41:36 +00:00
let img = decodeQoi(data)
2022-01-01 22:50:23 +00:00
doAssert img.height > 0 and img.width > 0
except PixieError:
discard