add predefinedfilters tests

This commit is contained in:
jangko 2020-07-20 17:12:44 +07:00
parent 89c433f1a1
commit 489b722f85
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9
1 changed files with 23 additions and 0 deletions

View File

@ -504,6 +504,29 @@ proc testPredefinedFilters() =
for i in 0..<h:
assertEquals(FLT_AVERAGE, outFilters[i])
# bad predefinedFilters
state.predefinedFilters = newSeq[PNGFilter](h-1)
for i in 0..<h-1:
state.predefinedFilters[i] = FLT_AVERAGE
try:
var pngx = encodePNG(image.data, w, h, state)
doAssert(false, "should never reach this code")
except PNGError:
discard
# bad predefinedFilters
state.predefinedFilters = newSeq[PNGFilter](h+1)
for i in 0..<h+1:
state.predefinedFilters[i] = FLT_AVERAGE
try:
var pngx = encodePNG(image.data, w, h, state)
doAssert(false, "should never reach this code")
except PNGError:
discard
# Tests combinations of various colors in different orders
proc testFewColors() =
echo "codec test few colors"