about summary refs log tree commit diff
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2022-08-22 01:56:02 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2022-08-22 01:56:02 +0000
commitd55353a6c2b108bf5e6ae37b831d1b1dc19e4c83 (patch)
tree66952e03935b6ee65c14c8f4cac43a8caf78acc2
parent1829f708c013f5631f4ea2fa66131e5fda9b633f (diff)
downloadnetpbm-mirror-d55353a6c2b108bf5e6ae37b831d1b1dc19e4c83.tar.gz
netpbm-mirror-d55353a6c2b108bf5e6ae37b831d1b1dc19e4c83.tar.xz
netpbm-mirror-d55353a6c2b108bf5e6ae37b831d1b1dc19e4c83.zip
Add initial 'pamcat' tests
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@4418 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-rw-r--r--test/Test-Order1
-rw-r--r--test/pamcat1.ok150
-rwxr-xr-xtest/pamcat1.test271
-rwxr-xr-xtest/pnmcat.test8
-rwxr-xr-xtest/qoi-roundtrip.test2
5 files changed, 430 insertions, 2 deletions
diff --git a/test/Test-Order b/test/Test-Order
index 8ad544a2..7f9d0184 100644
--- a/test/Test-Order
+++ b/test/Test-Order
@@ -72,6 +72,7 @@ pamhue.test
 
 pbmclean.test
 pamcut.test
+pamcat1.test
 pnmcat.test
 pamdice.test
 pamundice.test
diff --git a/test/pamcat1.ok b/test/pamcat1.ok
new file mode 100644
index 00000000..4e23666f
--- /dev/null
+++ b/test/pamcat1.ok
@@ -0,0 +1,150 @@
+Test 1.  Should print 15135078 29, then 0 fourteen times
+15135078 29
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+Test 2.  Should print 1957849403 59, 0 six times, 1 once
+1957849403 59
+0
+0
+0
+0
+0
+0
+1
+Test 3.  Should print 2673197404 69, 0 six times, 1 once
+2673197404 69
+0
+0
+0
+0
+0
+0
+1
+Test 4.  Should print 2285402562 36, then 0 twelve times
+2285402562 36
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+Test 5.  Should print 1836757613 62, 0 six times, 1 once
+1836757613 62
+0
+0
+0
+0
+0
+0
+1
+Test 6.  Should print 3601245348 137, 0 six times, 1 once
+3601245348 137
+0
+0
+0
+0
+0
+0
+1
+Test 7.  Should print 1572996771 71, then 0 twelve times
+1572996771 71
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+Test 8.  Should print 270413826 252, 0 six times, 1 once
+270413826 252
+0
+0
+0
+0
+0
+0
+1
+Test 9.  Should print 2942772630 192, 0 six times, 1 once
+2942772630 192
+0
+0
+0
+0
+0
+0
+1
+Test 10.  Should print 2700536985 95, then 0 twelve times
+2700536985 95
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+0
+Test 11.  Should print 2193235886 195, 0 eight times, 1 once
+2193235886 195
+0
+0
+0
+0
+0
+0
+0
+0
+1
+Test 12.  Should print 2773166369 245, 0 nine times, 1 once
+2773166369 245
+0
+0
+0
+0
+0
+0
+0
+0
+0
+1
+Test Invalid
+Expected failure 1 1
+Expected failure 2 1
+Expected failure 3 1
+Expected failure 4 1
+Expected failure 5 1
+Expected failure 6 1
+Expected failure 7 1
+Expected failure 8 1
+Expected failure 9 1
+Expected failure 10 1
+Expected failure 11 1
+Expected failure 12 1
+Expected failure 13 1
+Expected failure 14 1
diff --git a/test/pamcat1.test b/test/pamcat1.test
new file mode 100755
index 00000000..67d941cc
--- /dev/null
+++ b/test/pamcat1.test
@@ -0,0 +1,271 @@
+#! /bin/sh
+# This script tests: pamcat
+# Also requires: pbmmake pgmmake ppmmake pamseq pamrestack
+
+tmpdir=${tmpdir:-/tmp}
+check10x10_pbm=${tmpdir}/check10x10.pbm
+check40x10_pbm=${tmpdir}/check40x10.pbm
+check10x30_pbm=${tmpdir}/check10x30.pbm
+
+gray5x5_pgm=${tmpdir}/gray5x5.pgm
+gray10x5_pgm=${tmpdir}/gray10x5.pgm
+gray5x25_pgm=${tmpdir}/gray5x25.pgm
+
+yellow4x5_ppm=${tmpdir}/yellow4x5.ppm
+yellow16x5_ppm=${tmpdir}/yellow16x5.ppm
+yellow4x15_ppm=${tmpdir}/yellow4x15.ppm
+
+seq2_4h_pam=${tmpdir}/seq2_4h.pam
+seq2_4h4_pam=${tmpdir}/seq2_4h4.pam
+seq2_4v_pam=${tmpdir}/seq2_4v.pam
+seq2_4v3_pam=${tmpdir}/seq2_4v3.pam
+
+
+echo "Test 1.  Should print 15135078 29, then 0 fourteen times"
+
+pbmmake -g 10 10 | tee ${check10x10_pbm} | cksum
+for opt in "-leftright" "-lr" "-lr -jtop" "-lr -jcenter" "-lr -jbottom" \
+    "-lr -white" "-lr -black" \
+    "-topbottom" "-tb" "-tb -jleft"  "-tb -jcenter" "-tb --jright" \
+    "-tb -white" "-tb -black"
+  do
+  pamcat ${opt} ${check10x10_pbm} | cmp -s ${check10x10_pbm} - ; echo $?
+  done
+
+
+echo "Test 2.  Should print 1957849403 59, 0 six times, 1 once"
+pbmmake -g 40 10 | tee ${check40x10_pbm} | cksum
+for opt in "-leftright" "-lr -jtop" "-lr -jcenter" "-lr -jbottom" \
+    "-lr -white" "-lr -black" \
+    "-tb"
+  do
+  pamcat ${opt} ${check10x10_pbm} ${check10x10_pbm} \
+         ${check10x10_pbm} ${check10x10_pbm} | \
+  cmp -s ${check40x10_pbm} - ; echo $?
+  done
+
+
+echo "Test 3.  Should print 2673197404 69, 0 six times, 1 once"
+pbmmake -g 10 30 | tee ${check10x30_pbm} | cksum
+for opt in "-topbottom" "-tb -jleft"  "-tb -jcenter" "-tb --jright" \
+    "-tb -white" "-tb -black" \
+    "-lr"
+  do
+  pamcat ${opt} ${check10x10_pbm} ${check10x10_pbm} ${check10x10_pbm} |\
+  cmp -s ${check10x30_pbm} - ; echo $? 	
+  done
+
+rm ${check10x10_pbm} ${check40x10_pbm} ${check10x30_pbm}
+
+
+echo "Test 4.  Should print 2285402562 36, then 0 twelve times"
+
+pgmmake 0.125 5 5 | tee ${gray5x5_pgm} | cksum
+for opt in "-leftright" "-lr -jtop" "-lr -jcenter" "-lr -jbottom" \
+    "-lr -white" "-lr -black" \
+    "-topbottom" "-tb -jleft"  "-tb -jcenter" "-tb --jright" \
+    "-tb -white" "-tb -black"
+  do
+  pamcat ${opt} ${gray5x5_pgm} | cmp -s ${gray5x5_pgm} - ; echo $?
+  done
+
+
+echo "Test 5.  Should print 1836757613 62, 0 six times, 1 once"
+pgmmake 0.125 10 5 | tee ${gray10x5_pgm} | cksum
+for opt in "-leftright" "-lr -jtop" "-lr -jcenter" "-lr -jbottom" \
+    "-lr -white" "-lr -black" \
+    "-tb"
+  do
+  pamcat ${opt} ${gray5x5_pgm} ${gray5x5_pgm} |\
+  cmp -s ${gray10x5_pgm} - ; echo $?
+  done
+
+
+echo "Test 6.  Should print 3601245348 137, 0 six times, 1 once"
+pgmmake 0.125 5 25 | tee ${gray5x25_pgm} | cksum
+for opt in "-topbottom" "-tb -jleft"  "-tb -jcenter" "-tb --jright" \
+    "-tb -white" "-tb -black" \
+    "-lr"
+  do
+  pamcat ${opt} ${gray5x5_pgm} ${gray5x5_pgm} ${gray5x5_pgm} \
+	 ${gray5x5_pgm} ${gray5x5_pgm} |\
+  cmp -s ${gray5x25_pgm} - ; echo $?
+  done
+
+
+rm ${gray5x5_pgm} ${gray10x5_pgm} ${gray5x25_pgm}
+
+
+echo "Test 7.  Should print 1572996771 71, then 0 twelve times"
+ppmmake rgb:255/255/1 4 5 | tee ${yellow4x5_ppm} | cksum
+for opt in "-leftright" "-lr -jtop" "-lr -jcenter" "-lr -jbottom" \
+    "-lr -white" "-lr -black" \
+    "-topbottom" "-tb -jleft"  "-tb -jcenter" "-tb --jright" \
+    "-tb -white" "-tb -black"
+  do
+  pamcat ${opt} ${yellow4x5_ppm} |\
+  cmp -s ${yellow4x5_ppm} - ; echo $?
+  done
+
+
+echo "Test 8.  Should print 270413826 252, 0 six times, 1 once"
+ppmmake rgb:255/255/1 16 5 | tee ${yellow16x5_ppm} | cksum
+for opt in "-leftright" "-lr -jtop" "-lr -jcenter" "-lr -jbottom" \
+    "-lr -white" "-lr -black" \
+    "-tb"
+  do
+  pamcat ${opt} ${yellow4x5_ppm} ${yellow4x5_ppm} \
+         ${yellow4x5_ppm} ${yellow4x5_ppm} |\
+  cmp -s ${yellow16x5_ppm} - ; echo $?
+  done
+
+
+echo "Test 9.  Should print 2942772630 192, 0 six times, 1 once"
+ppmmake rgb:255/255/1 4 15 | tee ${yellow4x15_ppm} | cksum
+for opt in "-topbottom" "-tb -jleft"  "-tb -jcenter" "-tb --jright" \
+    "-tb -white" "-tb -black" \
+    "-lr"
+  do
+  pamcat ${opt} ${yellow4x5_ppm} ${yellow4x5_ppm} ${yellow4x5_ppm} |\
+  cmp -s ${yellow4x15_ppm} - ; echo $?
+  done
+
+rm ${yellow4x5_ppm} ${yellow16x5_ppm} ${yellow4x15_ppm}
+
+
+echo "Test 10.  Should print 2700536985 95, then 0 twelve times"
+pamseq 2 4 | tee ${seq2_4h_pam} | cksum
+for opt in "-leftright" "-lr -jtop" "-lr -jcenter" "-lr -jbottom" \
+    "-lr -white" "-lr -black" \
+    "-topbottom" "-tb -jleft"  "-tb -jcenter" "-tb --jright" \
+    "-tb -white" "-tb -black"
+  do
+  pamcat ${opt} ${seq2_4h_pam}  |\
+  cmp -s ${seq2_4h_pam} - ; echo $?
+  done
+
+
+echo "Test 11.  Should print 2193235886 195, 0 eight times, 1 once"
+pamrestack -width=1 ${seq2_4h_pam} | tee ${seq2_4v_pam} |\
+  pamenlarge -xscale=3 |\
+  tee ${seq2_4v3_pam} | cksum
+pamcat -lr ${seq2_4v_pam} ${seq2_4v_pam} | pamcat -lr - ${seq2_4v_pam} |\
+  cmp -s ${seq2_4v3_pam} - ; echo $?
+pamcat -lr ${seq2_4v_pam} | pamcat -lr - ${seq2_4v_pam}  ${seq2_4v_pam} |\
+  cmp -s ${seq2_4v3_pam} - ; echo $?
+for opt in "-leftright" "-lr -jtop" "-lr -jcenter" "-lr -jbottom" \
+    "-lr -white" "-lr -black" \
+    "-topbottom"
+  do
+  pamcat ${opt} ${seq2_4v_pam} ${seq2_4v_pam} ${seq2_4v_pam} |\
+  cmp -s ${seq2_4v3_pam} - ; echo $?
+  done
+
+
+echo "Test 12.  Should print 2773166369 245, 0 nine times, 1 once"
+pamenlarge -yscale 4 ${seq2_4h_pam} | tee ${seq2_4h4_pam} | cksum
+pamcat -tb ${seq2_4h_pam} |\
+    pamcat -tb - ${seq2_4h_pam} ${seq2_4h_pam} ${seq2_4h_pam} |\
+    cmp -s ${seq2_4h4_pam} - ; echo $?
+pamcat -tb ${seq2_4h_pam} ${seq2_4h_pam} |\
+    pamcat -tb - ${seq2_4h_pam} ${seq2_4h_pam} |\
+    cmp -s ${seq2_4h4_pam} - ; echo $?
+pamcat -tb ${seq2_4h_pam} ${seq2_4h_pam} ${seq2_4h_pam}|\
+    pamcat -tb - ${seq2_4h_pam} |\
+    cmp -s ${seq2_4h4_pam} - ; echo $?
+for opt in "-topbottom" "-tb -jleft"  "-tb -jcenter" "-tb --jright" \
+    "-tb -white" "-tb -black" \
+    "-leftright"
+  do
+  pamcat ${opt} ${seq2_4h_pam} ${seq2_4h_pam} ${seq2_4h_pam} ${seq2_4h_pam} |\
+  cmp -s ${seq2_4h4_pam} - ; echo $?
+  done
+
+rm ${seq2_4h_pam} ${seq2_4v_pam} ${seq2_4v3_pam} ${seq2_4h4_pam}
+
+
+
+echo "Test Invalid"
+
+test_out=${tmpdir}/test_out
+
+echo 1>&2
+echo "Invalid command-line argument combinations." 1>&2
+echo "Error messages should appear below the line." 1>&2
+echo "-----------------------------------------------------------" 1>&2
+
+# direction not specified
+pamcat testgrid.pbm testimg.ppm > ${test_out} || \
+  printf "Expected failure 1"
+  test -s ${test_out}; echo " "$?
+  rm -f ${test_out}
+
+# both directions specified
+pamcat -topbottom -leftright testgrid.pbm testimg.ppm > ${test_out} || \
+  printf "Expected failure 2"
+  test -s ${test_out}; echo " "$?
+  rm -f ${test_out}
+
+# both pad colors specified
+pamcat -topbottom -white -black testgrid.pbm testimg.ppm > ${test_out} || \
+  printf "Expected failure 3"
+  test -s ${test_out}; echo " "$?
+  rm -f ${test_out}
+
+# justification parameters overspecified
+pamcat -lr -jtop -jbottom testgrid.pbm testimg.ppm > ${test_out} || \
+  printf "Expected failure 4"
+  test -s ${test_out}; echo " "$?
+  rm -f ${test_out}
+
+pamcat -lr -jtop -jcenter testgrid.pbm testimg.ppm > ${test_out} || \
+  printf "Expected failure 5"
+  test -s ${test_out}; echo " "$?
+  rm -f ${test_out}
+
+pamcat -lr -jcenter -jbottom testgrid.pbm testimg.ppm > ${test_out} || \
+  printf "Expected failure 6"
+  test -s ${test_out}; echo " "$?
+  rm -f ${test_out}
+
+pamcat -tb -jleft -jright testgrid.pbm testimg.ppm > ${test_out} || \
+  printf "Expected failure 7"
+  test -s ${test_out}; echo " "$?
+  rm -f ${test_out}
+
+pamcat -tb -jleft -jcenter testgrid.pbm testimg.ppm > ${test_out} || \
+  printf "Expected failure 8"
+  test -s ${test_out}; echo " "$?
+  rm -f ${test_out}
+
+pamcat -tb -jcenter -jright testgrid.pbm testimg.ppm > ${test_out} || \
+  printf "Expected failure 9"
+  test -s ${test_out}; echo " "$?
+  rm -f ${test_out}
+
+# justification parameter in the wrong direction
+pamcat -lr -jleft    testgrid.pbm testimg.ppm > ${test_out} || \
+  printf "Expected failure 10"
+  test -s ${test_out}; echo " "$?
+  rm -f ${test_out}
+
+pamcat -lr -jright   testgrid.pbm testimg.ppm > ${test_out} || \
+  printf "Expected failure 11"
+  test -s ${test_out}; echo " "$?
+  rm -f ${test_out}
+
+pamcat -tb -jtop     testgrid.pbm testimg.ppm > ${test_out} || \
+  printf "Expected failure 12"
+  test -s ${test_out}; echo " "$?
+  rm -f ${test_out}
+
+pamcat -tb -jbottom  testgrid.pbm testimg.ppm > ${test_out} || \
+  printf "Expected failure 13"
+  test -s ${test_out}; echo " "$?
+  rm -f ${test_out}
+
+# more than one input image from standard input
+cat testgrid.pbm | pamcat -lr - - testimg.ppm > ${test_out} || \
+  printf "Expected failure 14"
+  test -s ${test_out}; echo " "$?
+  rm -f ${test_out}
diff --git a/test/pnmcat.test b/test/pnmcat.test
index fd0e83a2..bf40ada2 100755
--- a/test/pnmcat.test
+++ b/test/pnmcat.test
@@ -1,6 +1,12 @@
 #! /bin/sh
 # This script tests: pnmcat
-# Also requires: pbmmake pgmramp ppmtoppm
+# Also requires: pbmmake pgmramp ppmtoppm pamcat
+
+if [ ${CHECK_TYPE} = tree ]
+  then echo "Skipping." 1>&2
+       echo "Running \"make package; make check\" is recommended." 1>&2
+  exit 80;
+fi
 
 tmpdir=${tmpdir:-/tmp}
 check2x2_pbm=${tmpdir}/check2x2.pbm
diff --git a/test/qoi-roundtrip.test b/test/qoi-roundtrip.test
index 73878ce5..f758abcc 100755
--- a/test/qoi-roundtrip.test
+++ b/test/qoi-roundtrip.test
@@ -1,5 +1,5 @@
 #! /bin/bash
-# This script tests: qoitopnm pamtoqoi
+# This script tests: qoitopam pamtoqoi
 # Also requires: pamdepth pamfile pamseq pamstack pamtopnm pbmmake
 # Also requires: pgmnoise ppmpat ppmtopgm