about summary refs log tree commit diff
path: root/test
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2018-01-18 15:12:44 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2018-01-18 15:12:44 +0000
commit4edbf3ad0fe135c7f7412779eafc1bf329e23e51 (patch)
treebba157d42d2a3252188de792796b3115f2998646 /test
parent7b1a77afca304a8ecc61cce1118a0565613e13b3 (diff)
downloadnetpbm-mirror-4edbf3ad0fe135c7f7412779eafc1bf329e23e51.tar.gz
netpbm-mirror-4edbf3ad0fe135c7f7412779eafc1bf329e23e51.tar.xz
netpbm-mirror-4edbf3ad0fe135c7f7412779eafc1bf329e23e51.zip
Updates to GIF tests
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@3118 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'test')
-rw-r--r--test/gif-roundtrip.ok13
-rwxr-xr-xtest/gif-roundtrip.test105
2 files changed, 113 insertions, 5 deletions
diff --git a/test/gif-roundtrip.ok b/test/gif-roundtrip.ok
index 552bf90c..1704ba03 100644
--- a/test/gif-roundtrip.ok
+++ b/test/gif-roundtrip.ok
@@ -3,9 +3,20 @@
 1571496937 33838
 1571496937 33838
 1571496937 33838
+1571496937 33838
 2425386270 41
 2425386270 41
 2425386270 41
 2425386270 41
 2425386270 41
-P1 4 1 0101 
\ No newline at end of file
+P1 4 1 0101 
+4030 0 , 4030 0
+4031 0 , 4031 0
+4097 0 , 4097 0
+238 0 , 238 0
+239 0 , 239 0
+240 0 , 240 0
+241 0 , 241 0
+255 0 , 255 0
+256 0 , 256 0
+257 0 , 257 0
diff --git a/test/gif-roundtrip.test b/test/gif-roundtrip.test
index a6d0ec4c..b49cc6d2 100755
--- a/test/gif-roundtrip.test
+++ b/test/gif-roundtrip.test
@@ -1,7 +1,6 @@
 #! /bin/bash
 # This script tests: giftopnm pamtogif
-# Also requires: ppmtorgb3 rgb3toppm pbmmake pnminvert
-
+# Also requires: ppmtorgb3 rgb3toppm pbmmake pnminvert pamcut pamdepth
 
 tmpdir=${tmpdir:-/tmp}
 
@@ -33,12 +32,13 @@ rm ${test_ppm} ${test_grn} ${test_blu} ${out_red} ${out_grn}
 
 # Test 2. Should produce 1571496937 33838
 # which is the result of cksum testimg.red
-# four times
+# five times
 
 test_gif=${tmpdir}/testimg.gif
 
 pamtogif ${test_red} | giftopnm | cksum
 pamtogif -interlace ${test_red} | giftopnm | cksum
+pamtogif -noclear ${test_red} | giftopnm | cksum
 pamtogif -sort ${test_red} | tee ${test_gif} | \
   giftopnm | cksum
 echo "junk" >> ${test_gif} && \
@@ -48,6 +48,7 @@ rm  ${test_gif} ${test_red}
 
 
 # Test 3. Should produce 2425386270 41 five times.
+# testgrid.pbm is too small for -noclear to take effect 
 
 pamtogif testgrid.pbm | giftopnm | cksum
 pamtogif -nolzw testgrid.pbm | giftopnm | cksum
@@ -56,11 +57,107 @@ pamtogif -alpha=testgrid.pbm testgrid.pbm | giftopnm | cksum
 pamtogif -transparent=white testgrid.pbm | giftopnm -alpha=- | \
   pnminvert | cksum
 
+
 # Test 4.
 # In this gif file the code length changes after the last image data.
 # Image data: 3 bits, end code 4 bits.
 # Should produce P1 4 1 0 1 0 1
 
 pbmmake -g 4 1 | \
-  pamtogif | giftopnm -plain | \
+  pamtogif -verbose | giftopnm -plain | \
   tr '\n' ' '
+echo ""
+
+
+# Test 5.
+# Test whether saturated code tables are handled correctly.
+# Test input images which most use up the string code table or
+# come close to doing so.
+
+# Should produce:
+# 4030 0 , 4030 0
+# 4031 0 , 4031 0
+# 4097 0 , 4097 0
+# 238 0 , 238 0
+# 239 0 , 239 0
+# 240 0 , 240 0
+# 241 0 , 241 0
+# 255 0 , 255 0
+# 256 0 , 256 0
+# 257 0 , 257 0
+
+test4097_pgm=${tmpdir}/testimg4097.pgm
+test_pgm=${tmpdir}/testimg.pgm
+
+# The following awk script produces a PGM file with no repeated sequences.
+# Here is a smaller example with the same property:
+# P2
+# 8 8
+# 7
+# 0 0 1 1 0 2 2 0
+# 3 3 0 4 4 0 5 5
+# 0 6 6 0 7 7 1 2
+# 1 3 1 4 1 5 1 6
+# 1 7 2 3 2 4 2 5
+# 2 6 2 7 3 4 3 5
+# 3 6 3 7 4 5 4 6
+# 4 7 5 6 5 7 6 7
+
+maxval=63
+awk -v maxval=${maxval} 'BEGIN \
+{ print "P2"
+         print "1 "(maxval+1) * (maxval+1) +1
+         print maxval
+         print 0 
+         for (j=i+1; j<=maxval; ++j)
+	    {print 0; print j; print j }
+         for (i=1; i<=maxval; ++i)
+             for (j=i+1; j<=maxval; ++j)
+                 {print i; print j }
+         print 0
+}' > ${test4097_pgm}
+
+for size in 4030 4031 4097
+  do
+  pamcut -height ${size} ${test4097_pgm} > ${test_pgm} &&
+  pamtogif -verbose ${test_pgm} | giftopnm | pamdepth ${maxval} | \
+    cmp - ${test_pgm}
+  # pamdepth ${maxval} is necessary because
+  # giftopnm output is maxval 255
+  echo -n ${size} $? ", "
+  pamtogif -nolzw ${test_pgm} | giftopnm | pamdepth ${maxval} | \
+    cmp - ${test_pgm}
+  echo ${size} $?
+  rm ${test_pgm}
+  done 
+
+rm ${test4097_pgm}
+test257_pgm=${tmpdir}/testimg257.pgm
+
+maxval=15
+awk -v maxval=${maxval} 'BEGIN \
+{ print "P2"
+         print "1 "(maxval+1) * (maxval+1) +1
+         print maxval
+         print 0 
+         for (j=i+1; j<=maxval; ++j)
+	    {print 0; print j; print j }
+         for (i=1; i<=maxval; ++i)
+             for (j=i+1; j<=maxval; ++j)
+                 {print i; print j }
+         print 0
+}' >  ${test257_pgm}
+
+for size in 238 239 240 241 255 256 257
+  do
+  pamcut -height=${size} ${test257_pgm} > ${test_pgm} &&
+  pamtogif -verbose ${test_pgm} | giftopnm | pamdepth ${maxval} | \
+    cmp - ${test_pgm}
+  echo -n ${size} $? ", "
+  pamtogif -nolzw -verbose ${test_pgm} | giftopnm | pamdepth ${maxval} | \
+    cmp - ${test_pgm}
+  echo ${size} $?
+  rm ${test_pgm}
+  done 
+
+rm ${test257_pgm}