about summary refs log tree commit diff
path: root/test/pamhue.test
blob: ca7a7d82f9a0bf5845cad3e118df595d361156c4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#! /bin/bash
# This script tests: pamhue
# Also requires: pamseq ppmhist pamdepth

echo "Test 1"
# Should print 1213482165 83 twice

pamseq -tupletype=RGB 3 1 | pamdepth 255 | pamhue -huechange=60 | cksum
pamseq -tupletype=RGB 3 1 | pamdepth 255 | pamhue -huechange=-300 | cksum

echo "Test 2"

pamseq -tupletype=RGB 3 1 | pamdepth 255 | ppmhist -sort=rgb
pamseq -tupletype=RGB 3 1 | pamdepth 255 | pamhue -huechange=60 | \
  ppmhist -sort=rgb

echo "Test 3"
# pamhue has no effect on monotone images
# Should print 281226646 481 twice

pamhue -huechange=45  maze.pbm | cmp -s - maze.pbm
  echo ${PIPESTATUS[@]} ":" $?
pamhue -huechange=180 maze.pbm | cmp -s - maze.pbm
  echo ${PIPESTATUS[@]} ":" $?

echo "Test 4"
# spinning the color wheel by multiples of 360 leaves the image unchanged
# Should print 1926073387 101484 twice

pamhue -huechange=0 testimg.ppm   | cmp -s - testimg.ppm
  echo ${PIPESTATUS[@]} ":" $?
pamhue -huechange=360 testimg.ppm | cmp -s - testimg.ppm
  echo ${PIPESTATUS[@]} ":" $?

echo "Test Invalid"

tmpdir=${tmpdir:-/tmp}
test_out=${tmpdir}/test_out

echo 1>&2
echo "Omission of mandatory argument." 1>&2
echo "An error message should appear below the line." 1>&2
echo "-----------------------------------------------------------" 1>&2

pamhue testimg.ppm  > ${test_out} || \
  printf "Expected failure 1 "
  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
  rm -f ${test_out}