about summary refs log tree commit diff
path: root/test/pnmquant.test
blob: 4baff9a8ab79865afe05202227730f2cbd1546ca (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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#! /bin/sh
# This script tests: pnmquant
# Also requires: ppmhist

echo "Test 1"

# Count colors in output image.

pnmquant 256 testimg.ppm | ppmhist | \
  awk 'NR==1 {print ($2 <= 256) , ($2 > 256 * 0.95)}'

pnmquant -center 256 testimg.ppm | ppmhist | \
  awk 'NR==1 {print ($2 <= 256) , ($2 > 256 * 0.95)}'

pnmquant -spreadbrightness 256 testimg.ppm | ppmhist | \
  awk 'NR==1 {print ($2 <= 256) , ($2 > 256 * 0.95)}'

pnmquant -spreadluminosity 128 testimg.ppm | ppmhist | \
  awk 'NR==1 {print ($2 <= 128) , ($2 > 128 * 0.95)}'

pnmquant -floyd -randomseed=0 128 testimg.ppm | ppmhist | \
  awk 'NR==1 {print ($2 <= 128) , ($2 > 128 * 0.95)}'

pnmquant 64 -meanpixel testimg.ppm | ppmhist | \
  awk 'NR==1 {print ($2 <= 64) , ($2 > 64 * 0.9)}'

pnmquant 16 -meancolor testimg.ppm | ppmhist | \
  awk 'NR==1 {print ($2 <= 16) , ($2 > 16 * 0.9)}'


pnmquant 2 testgrid.pbm | ppmhist | \
  awk 'NR==1 {print ($2 <= 2) , ($2 == 2) }'

echo "Test Invalid"

echo 1>&2
echo "Invalid command-line arguments." 1>&2
echo "Error messages should appear below the line." 1>&2
echo "-----------------------------------------------------------" 1>&2

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

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

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

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

pnmquant -center -meancolor 16 testimg.ppm > ${test_out} || \
  printf "Expected failure 4 "
  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
  rm -f ${test_out}

pnmquant -center -meanpixel 16 testimg.ppm    > ${test_out} || \
  printf "Expected failure 5 "
  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
  rm -f ${test_out}

pnmquant -meancolor -meanpixel 16 testimg.ppm > ${test_out} || \
  printf "Expected failure 6 "
  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
  rm -f ${test_out}

pnmquant -spreadbrightness -spreadluminosity 16 testimg.ppm > ${test_out} || \
  printf "Expected failure 7 "
  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
  rm -f ${test_out}

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