]> git.draconx.ca Git - liblbx.git/blobdiff - tests/pam-formats.tap
tests: Add a simple test to validate PAM output formats.
[liblbx.git] / tests / pam-formats.tap
diff --git a/tests/pam-formats.tap b/tests/pam-formats.tap
new file mode 100755 (executable)
index 0000000..42f3892
--- /dev/null
@@ -0,0 +1,59 @@
+#!/bin/sh
+#
+# 2ooM: The Master of Orion II Reverse Engineering Project
+# Test that the PAM writer emits the smallest output format.
+# Copyright © 2013 Nick Bowler
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+. "$srcdir/tests/util/test-init.sh" || exit 99
+
+plan_ 8
+dx_create_testdir
+
+check_image()
+{
+       dx_pam_header "$1" > "$1.sh" || return
+       . "./$1.sh" || return
+
+       test x"$WIDTH"  = x"1"  || return
+       test x"$HEIGHT" = x"1"  || return
+       test x"$DEPTH"  = x"$2" || return
+
+       case $DEPTH in
+       1) test x"$TUPLTYPE" = x"GRAYSCALE" ;;
+       2) test x"$TUPLTYPE" = x"GRAYSCALE_ALPHA" ;;
+       3) test x"$TUPLTYPE" = x"RGB" ;;
+       4) test x"$TUPLTYPE" = x"RGB_ALPHA" ;;
+       *) false
+       esac
+}
+
+command_ok_ "decoding image-1x1 (no palette)" \
+       $LBXIMG -F pam --output-prefix test0 -dnf "$testdata/image-1x1"
+command_ok_ "PAM format GRAYSCALE" check_image test0.000.pam 1
+
+command_ok_ "decoding image-1x1-mt (no palette)" \
+       $LBXIMG -F pam --output-prefix test1 -dnf "$testdata/image-1x1-mt"
+command_ok_ "PAM format GRAYSCALE_ALPHA" check_image test1.000.pam 2
+
+command_ok_ "decoding image-1x1 (with palette)" \
+       $LBXIMG -F pam --output-prefix test2 -p "$testdata/palette-ramp" \
+               -df "$testdata/image-1x1"
+command_ok_ "PAM format RGB" check_image test2.000.pam 3
+
+command_ok_ "decoding image-1x1-mt (with palette)" \
+       $LBXIMG -F pam --output-prefix test3 -p "$testdata/palette-ramp" \
+               -df "$testdata/image-1x1-mt"
+command_ok_ "PAM format RGB_ALPHA" check_image test3.000.pam 4