diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2021-03-27 19:16:06 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2021-03-27 19:16:06 +0000 |
commit | fcfa49ef6735be96386bda87bab2d0976475f585 (patch) | |
tree | fccbaafc41fb0f98682d4d48f7ff584bdbb81904 /test/pgmnoise.test | |
parent | a7fca291a0c78333da13e855bdb73aa819ba8649 (diff) | |
download | netpbm-mirror-fcfa49ef6735be96386bda87bab2d0976475f585.tar.gz netpbm-mirror-fcfa49ef6735be96386bda87bab2d0976475f585.tar.xz netpbm-mirror-fcfa49ef6735be96386bda87bab2d0976475f585.zip |
Promote Development to Advanced, Release 10.94.00
git-svn-id: http://svn.code.sf.net/p/netpbm/code/advanced@4076 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'test/pgmnoise.test')
-rwxr-xr-x | test/pgmnoise.test | 88 |
1 files changed, 85 insertions, 3 deletions
diff --git a/test/pgmnoise.test b/test/pgmnoise.test index 03301ce6..21a2729e 100755 --- a/test/pgmnoise.test +++ b/test/pgmnoise.test @@ -1,7 +1,89 @@ #! /bin/bash # This script tests: pgmnoise -# Also requires: +# Also requires: pgmhist pamvalidate -# Should print: 1663614689 10015 (Glibc) -# 3516404574 10015 (MAC OS) +echo "Test 1." +echo "Should print: 2132901423 10015" # (Mersenne Twister) +# 1663614689 10015 (Glibc rand()) +# 3516404574 10015 (MAC OS rand()) pgmnoise --randomseed=0 100 100 | cksum + + +echo "Test 2." +# Output is similar to that of Test 2. of random-generator.test +# The lowest four decimal digits are printed. + +pgmnoise --randomseed=5489 -maxval=9999 -plain 5 20 + + +echo "Test 3." +for maxval in `seq 16` 255 65535 + do + echo ${maxval} + pgmnoise -maxval=${maxval} -randomseed=1 -plain 16 1 | tr '\n' ' ' + done +echo + +echo "Test 4." +# Check for maxval violation +for maxval in `seq 16` 30 31 32 254 255 256 65534 65535 + do + echo -n ${maxval} " " + pgmnoise -maxval=${maxval} -randomseed=1 -plain ${maxval} 10 | \ + pamvalidate | pamfile + done + +echo "Test 5." +echo "Should print four identical lines" +# width height values do not affect random number sequence +for xysize in "1 10000" "100 100" "250 40" "1000 10" + do pgmnoise --randomseed=0 ${xysize} | pgmhist -mach | cksum + done + + +tmpdir=${tmpdir:-/tmp} +messages=${tmpdir}/messages + +echo "Test 6." +echo "First column should be 2^n - 1" +# The "pool" method of generating pixvals is used iff maxval is +# a power of 2 minus 1: 1, 3, 7, 15, 31 ... +for maxval in `seq 35; seq 60 69; seq 120 129; seq 250 259` + do + pgmnoise -maxval=${maxval} -randomseed=1 -verbose 1 1 > /dev/null \ + 2> ${messages} + awk -v mval=${maxval} '/method/ && /pool/ { print mval, $0 }' ${messages} + done + + rm ${messages} + + +echo "Test Invalid" + +test_out=${tmpdir}/test_out + +echo 1>&2 +echo "Invalid command-line arguments." 1>&2 +echo "Error messages should appear below the line." 1>&2 +echo "-----------------------------------------------------------" 1>&2 + +pgmnoise 0 0 > ${test_out} || \ + echo -n "Expected failure 1"; test -s ${test_out}; echo " "$? +pgmnoise 0 1 > ${test_out} || \ + echo -n "Expected failure 2"; test -s ${test_out}; echo " "$? +pgmnoise 1 0 > ${test_out} || \ + echo -n "Expected failure 3"; test -s ${test_out}; echo " "$? +pgmnoise > ${test_out} || \ + echo -n "Expected failure 4"; test -s ${test_out}; echo " "$? +pgmnoise 1 > ${test_out} || \ + echo -n "Expected failure 5"; test -s ${test_out}; echo " "$? +pgmnoise 100 -1 > ${test_out} || \ + echo -n "Expected failure 6"; test -s ${test_out}; echo " "$? +pgmnoise -randomseed=-1 100 100 > ${test_out} || \ + echo -n "Expected failure 7"; test -s ${test_out}; echo " "$? +pgmnoise -maxval=-1 100 100 > ${test_out} || \ + echo -n "Expected failure 8"; test -s ${test_out}; echo " "$? +pgmnoise -maxval=0 100 100 > ${test_out} || \ + echo -n "Expected failure 9"; test -s ${test_out}; echo " "$? +pgmnoise -maxval=$((256 * 256 * 256 * 256)) 10 10 > ${test_out} || \ + echo -n "Expected failure 10"; test -s ${test_out}; echo " "$? |