about summary refs log tree commit diff
path: root/test/pamfix.test
blob: c274de86a13074bbfb50041fd0a95e135f87f64e (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
#! /bin/sh
# This script tests: pamfix
# Also requires: pbmmake

tmpdir=${tmpdir:-/tmp}

# Test 1.
echo "Test 1"

pbmmake -g 5 5 | pamfix -truncate -plain

printf "P1\n5 5\n01010\n10101\n01010\n00001\n1\n" |\
  pamfix -truncate -plain

printf "P1\n5 5\n01010\n10101\n01010\n0000\n1\n" |\
  pamfix -truncate -plain

printf "P1\n5 5\n01010\n10102\n01010\n00001\n1\n" |\
  pamfix -truncate -plain

# Test 2

echo "Test 2"

printf "P2\n3 3\n7\n0 1 2\n3 4 5\n6 7 0\n" |\
  pamfix -truncate -plain

printf "P2\n3 3\n7\n0 1 2\n3 4 5\n6 7\n" |\
  pamfix -truncate -plain
printf "P2\n3 3\n7\n0 1 2\n3 4 5\n6 7 8\n" |\
  pamfix -truncate -plain

printf "P2\n3 3\n7\n0 1 2\n3 4 5\n6 7 8\n" |\
  pamfix -change -plain

printf "P2\n3 3\n7\n0 1 2\n3 4 5\n6 7 8\n" |\
 pamfix -clip -plain

printf "P2\n3 3\n7\n0 1 2\n3 4 8\n0 0 0\n" |\
  pamfix -change -truncate -plain

printf "P2\n3 3\n7\n0 1 2\n3 4 8\n0 0 0\n" |\
  pamfix -clip -truncate -plain

# Test Invalid

echo "Test Invalid"

test_out=${tmpdir}/test_out

echo 1>&2
echo "Invalid command-line combination, invalid input" 1>&2
echo "Error messages should appear below the line." 1>&2
echo "-----------------------------------------------------------" 1>&2

printf "P2\n3 2\n7\n0 1 2\n6 7 8\n" | pamfix -change -clip > ${test_out} || \
  printf "Expected failure 1 "
  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
  rm -f ${test_out}

printf "P1\n5 5\n" | pamfix -truncate -plain > ${test_out} || \
  printf "Expected failure 2 "
  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
  rm -f ${test_out}

printf "P2\n3 3\255\n" | pamfix -truncate -plain > ${test_out} || \
  printf "Expected failure 3 "
  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
  rm -f ${test_out}