#! /bin/sh
# This script tests: pamstereogram
# Also requires: pamdepth

tmpdir=${tmpdir:-/tmp}
testgrid_pgm=${tmpdir}/testgrid.pgm

# Make input file

echo "Test 00. Should print 729348909 237"
pamdepth -quiet 255 testgrid.pbm | tee ${testgrid_pgm} | cksum


# Random pattern

echo "Test 01. Should print 3308667841 293"
pamstereogram -randomseed=1 testgrid.pbm | cksum 
echo "Test 02. Should print 3308667841 293"
pamstereogram -randomseed=1 -blackandwhite testgrid.pbm | cksum 
echo "Test 03. Should print 748200469 170"
pamseq -tupletype=GRAYSCALE 1 100 | pamstereogram -randomseed=1 | cksum 
echo "Test 04. Should print 1538641408 1070"
pamgauss 100 10 -maxval=10000 -sigma 20 | pamfunc -multiplier=500 | \
  pamstereogram -randomseed=1 -dpi=10 | cksum

# Makemask

echo "Test 10. Should print 1266273778 293"
pamstereogram -randomseed=1 -makemask testgrid.pbm | cksum 

echo "Test 11. Should print 55276708 1070"
pamgauss 100 10 -maxval=10000 -sigma 20 | pamfunc -multiplier=500 | \
  pamstereogram -randomseed=1 -dpi=10 -makemask | cksum

# Grayscale

echo "Test 20. Should print 1920539795 289"
pamstereogram -randomseed=1 -grayscale testgrid.pbm | cksum 
echo "Test 21. Should print 4069109690 4068"
pamseq 1 100 | pnmtile 200 20 | \
  pamstereogram -randomseed=1 -dpi=10 -grayscale | \
  cksum
echo "Test 22. Should print 1163376052 4068"
pamseq 1 100 | pnmtile 200 20 | \
  pamstereogram -randomseed=1 -dpi=10 -grayscale -maxval 255 | \
  cksum

# Color

echo "Test 30. Should print 2127252909 731"
pamstereogram -randomseed=1 -color testgrid.pbm | cksum 
echo "Test 31. Should print 858421050 12062"
pamseq 1 100 | pnmtile 200 20 | \
  pamstereogram -randomseed=1 -dpi=10 -color | \
  cksum

# Pattern file

echo "Test 40. Should print 1236679620 660"
pamgradient black gray50 white gray50 100 50 | \
  pamstereogram -patfile testgrid.pbm -eyesep=.1 -crosseyed | cksum

echo "Test 41. Should print 1022068930 5014"
pamgradient black gray50 white gray50 100 50 | \
  pamstereogram -patfile  ${testgrid_pgm} -eyesep=.1 -crosseyed | cksum

# drawguides

echo "Test 51. Should print 3784833098 11071"
pamgradient black gray50 white gray50 100 50 | \
  pamstereogram -randomseed=1 -dpi 10 -guidesize=20 -guidetop | cksum

echo "Test 52. Should print 1419662425 1441"
pamgradient black gray50 white gray50 100 50 | \
  pamstereogram -patfile=testgrid.pbm -dpi 10 -guidesize=20 -guidetop | cksum


# Clean up files we created
rm  ${testgrid_pgm}

