update tests

This commit is contained in:
andri lim 2018-10-09 10:50:02 +07:00
parent 1d19a7a40e
commit 74dab921d5
2 changed files with 8 additions and 4 deletions

View File

@ -13,3 +13,7 @@ task tests, "Run tests":
exec "nim c -r test.nim" exec "nim c -r test.nim"
exec "nim c -r testCodec.nim" exec "nim c -r testCodec.nim"
exec "nim c -r testSuite.nim" exec "nim c -r testSuite.nim"
exec "nim c -r -d:release test.nim"
exec "nim c -r -d:release testCodec.nim"
exec "nim c -r -d:release testSuite.nim"

View File

@ -1,6 +1,6 @@
import streams, os, strutils, nimPNG, minibmp import streams, os, strutils, nimPNG, minibmp
proc loadPNG(fileName: string): BMP = proc loadPNG2BMP(fileName: string): BMP =
var settings = makePNGDecoder() var settings = makePNGDecoder()
settings.readTextChunks = true settings.readTextChunks = true
var png = loadPNG24(fileName, settings) var png = loadPNG24(fileName, settings)
@ -13,7 +13,7 @@ proc loadPNG(fileName: string): BMP =
result.data[px + 1] = png.data[px + 1] result.data[px + 1] = png.data[px + 1]
result.data[px + 2] = png.data[px + 2] result.data[px + 2] = png.data[px + 2]
proc write(bmp: BMP): string = proc toString(bmp: BMP): string =
var s = newStringStream() var s = newStringStream()
s.writeBMP(bmp) s.writeBMP(bmp)
result = s.data result = s.data
@ -30,9 +30,9 @@ proc convert(dir: string) =
let bmpName = path.dir & DirSep & path.name & ExtSep & "bmp" let bmpName = path.dir & DirSep & path.name & ExtSep & "bmp"
echo fileName, " vs. ", bmpName echo fileName, " vs. ", bmpName
var bmp = loadPNG(fileName) var bmp = loadPNG2BMP(fileName)
if bmp != nil: if bmp != nil:
let data1 = bmp.write() let data1 = bmp.toString()
let data2 = readFile(bmpName) let data2 = readFile(bmpName)
assert data1 == data2 assert data1 == data2