pixie/tests/test_qoi.nim

23 lines
729 B
Nim
Raw Normal View History

2022-05-21 23:27:38 +00:00
import pixie, pixie/fileformats/qoi
2022-01-01 22:50:23 +00:00
const tests = ["testcard", "testcard_rgba"]
for name in tests:
2022-01-03 23:41:36 +00:00
let
path = "tests/fileformats/qoi/" & name & ".qoi"
input = readImage(path)
2022-05-21 23:27:38 +00:00
control = readImage("tests/fileformats/qoi/" & name & ".png")
dimensions = decodeQoiDimensions(readFile(path))
2022-01-03 23:41:36 +00:00
doAssert input.data == control.data, "input mismatch of " & name
doAssert input.width == dimensions.width
doAssert input.height == dimensions.height
2022-01-04 01:14:48 +00:00
discard encodeQoi(control)
2022-01-03 23:41:36 +00:00
2022-01-01 22:50:23 +00:00
for name in tests:
2022-01-03 23:41:36 +00:00
let
path = "tests/fileformats/qoi/" & name & ".qoi"
input = decodeQoi(readFile(path))
2022-05-21 23:27:38 +00:00
output = decodeQoi(encodeQoi(input))
2022-01-03 23:41:36 +00:00
doAssert output.data.len == input.data.len
doAssert output.data == input.data