#! /bin/sh
# This script tests: pamtowinicon ppmtowinicon winicontopam
# Also requires: pamchannel pamcut pamdepth pamtopam
# Also requires: pngtopam pnmtopng

tmpdir=${tmpdir:-/tmp}
test_pam=${tmpdir}/testimg.pam

echo "Test 1. Should print 4241318573 6973 four times"

pamcut --left=30 --width=48 --height=48 testimg.ppm | pamtopam | \
  tee ${test_pam} | cksum
pamtowinicon ${test_pam} | winicontopam | \
  pamchannel -tupletype="RGB" 0 1 2 | cksum
pamtowinicon -pngthreshold=300 ${test_pam} | winicontopam | \
  pamchannel -tupletype="RGB" 0 1 2 | cksum
pamtowinicon -pngthreshold=1   ${test_pam} | winicontopam | \
  pamchannel -tupletype="RGB" 0 1 2 | cksum

rm ${test_pam}

echo "Test 1. Should print 1009647580 1093 six times"

pamcut -top=0 -left=0 -width=32 -height=32 maze.pbm | pamtopam | \
  tee ${test_pam} | cksum
pamtowinicon ${test_pam} | winicontopam | \
  pamdepth 1 | pamchannel -tupletype="BLACKANDWHITE" 0 | cksum
pamtowinicon -pngthreshold=300 ${test_pam} | winicontopam | \
  pamdepth 1 | pamchannel -tupletype="BLACKANDWHITE" 0 | cksum
pamtowinicon -pngthreshold=1   ${test_pam} | winicontopam | 
  pamdepth 1 | pamchannel -tupletype="BLACKANDWHITE" 0 | cksum
pamtowinicon -pngthreshold=1   ${test_pam} | winicontopam | 
  pamchannel -tupletype="BLACKANDWHITE" 0 | cksum

rm ${test_pam}

pamcut -top=0 -left=0 -width=32 -height=32 maze.pbm | \
  ppmtowinicon | winicontopam | \
  pamdepth 1 | pamchannel -tupletype="BLACKANDWHITE" 0 | cksum
