diff options
Diffstat (limited to 'test/targa-roundtrip.test')
-rwxr-xr-x | test/targa-roundtrip.test | 82 |
1 files changed, 72 insertions, 10 deletions
diff --git a/test/targa-roundtrip.test b/test/targa-roundtrip.test index f646b8c1..79b01b61 100755 --- a/test/targa-roundtrip.test +++ b/test/targa-roundtrip.test @@ -1,18 +1,80 @@ #! /bin/bash # This script tests: pamtotga tgatoppm -# Also requires: ppmtopgm pgmtopbm pamchannel +# Also requires: ppmtopgm pgmtopbm pamchannel pnmquant pamdepth +tmpdir=${tmpdir:-/tmp} -#Test 1: Should print 2425386270 41, cksum of testgrid.pbm +#Test 1: Should print 2425386270 41, cksum of testgrid.pbm, ten times -pamtotga -mono testgrid.pbm | \ - tgatoppm | ppmtopgm | \ - pgmtopbm -threshold -val 0.5 | cksum +echo "Test 1" -#Test 2: Should produce 1571496937 33838, cksum of testimg.red -pamchannel -infile=testimg.ppm -tupletype="GRAYSCALE" 0 | \ - pamtotga -cmap | tgatoppm | ppmtopgm | cksum +for mode in "-mono" "-mono -norle" \ + "-cmap" "-cmap -norle" "-cmap16" "-cmap16 -norle" \ + "-rgb" "-rgb -norle" "" "-norle" + do + pamtotga ${mode} testgrid.pbm | \ + tgatoppm | ppmtopgm | \ + pgmtopbm -threshold -val 0.5 | cksum + done -#Test 3: Should print 1926073387 101484, cksum of testimg.ppm +#Test 2: Should produce 1571496937 33838, cksum of testimg.red, ten times -pamtotga -rgb testimg.ppm | tgatoppm | cksum +echo "Test 2" + +test_pam=${tmpdir}/testimg.pgm +pamchannel -infile=testimg.ppm -tupletype="GRAYSCALE" 0 > ${test_pam} + +for mode in "-mono" "-mono -norle" \ + "-cmap" "-cmap -norle" "-cmap16" "-cmap16 -norle" \ + "-rgb" "-rgb -norle" "" "-norle" + do + pamtotga ${mode} ${test_pam} | tgatoppm | ppmtopgm | cksum + done + +rm ${test_pam} + + +#Test 3: Should print 1926073387 101484, cksum of testimg.ppm, four times + +echo "Test 3" + +for mode in "-rgb" "-rgb -norle" "" "-norle" + do + pamtotga ${mode} testimg.ppm | tgatoppm | cksum + done + +#Test 4: Should print 0 six times + +echo "Test 4" + +test256_ppm=${tmpdir}/test256.ppm +pnmquant 256 testimg.ppm > ${test256_ppm} || echo "pnmquant failed" +# test image may have less than 256 colors + +for mode in "-rgb" "-rgb -norle" "-cmap" "-cmap -norle" "" "-norle" + do + pamtotga ${mode} ${test256_ppm} | tgatoppm | cmp -s - ${test256_ppm} + echo ${PIPESTATUS[@]} ":" $? +done + + +#Test 5: Should print 0 eight times + +echo "Test 5" + +test256_31_ppm=${tmpdir}/test256-31.ppm +pamdepth 31 ${test256_ppm} > ${test256_31_ppm} || echo "pamdepth failed" +rm ${test256_ppm} + +for mode in "-cmap16" "-cmap16 -norle" + do pamtotga ${mode} ${test256_31_ppm} | tgatoppm | cmp -s - ${test256_31_ppm} + echo ${PIPESTATUS[@]} ":" $? + done + +for mode in "-rgb" "-rgb -norle" "-cmap" "-cmap -norle" "" "-norle" + do pamtotga ${mode} ${test256_31_ppm} | tgatoppm | \ + pamdepth 31 | cmp -s - ${test256_31_ppm} + echo ${PIPESTATUS[@]} ":" $? + done + +rm ${test256_31_ppm} |