]> git.draconx.ca Git - upkg.git/blobdiff - tests/engine-pcx-rlencode.sh
engine: Add a unit test for the PCX run-length encoder.
[upkg.git] / tests / engine-pcx-rlencode.sh
diff --git a/tests/engine-pcx-rlencode.sh b/tests/engine-pcx-rlencode.sh
new file mode 100644 (file)
index 0000000..3a05444
--- /dev/null
@@ -0,0 +1,27 @@
+#!/bin/sh
+#
+# Check corner cases of the PCX run-length encoder.
+# Copyright © 2012 Nick Bowler
+#
+# License WTFPL2: Do What The Fuck You Want To Public License, version 2.
+# This is free software: you are free to do what the fuck you want to.
+# There is NO WARRANTY, to the extent permitted by law.
+
+pcxrle=test/pcxrle$EXEEXT
+
+$pcxrle 00   || exit 1
+$pcxrle 0000 || exit 1
+$pcxrle c100 || exit 1
+
+# Test RLE rollover
+t1=00
+t2=$t1$t1
+t4=$t2$t2
+t8=$t4$t4
+t16=$t8$t8
+t32=$t16$t16
+t64=$t32$t32
+
+$pcxrle "$t32$t16$t8$t4$t2$t1" || exit 1 # maximum possible run
+$pcxrle "$t64" || exit 1
+$pcxrle "$t64$t64$t64" || exit 1