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

tmpdir=${tmpdir:-/tmp}
fname_stem=${tmpdir}/pamdice_part

# Test 1.
echo "Test 1."

pbmmake -w 2 5 | pamdice -height=1 -width=1 -outstem=${fname_stem} -plain
ls ${fname_stem}*.pbm | while read file
  do
  cat ${file} | tr '\n'  '@' ; echo
  done | sort | uniq -c | sed 's/^ *//'

rm ${fname_stem}*.pbm

# Test 1.
echo "Test 2."

pbmmake -g 2 5 | pamdice -height=1 -width=1 -outstem=${fname_stem} -plain
ls ${fname_stem}*.pbm | while read file
  do
  cat ${file} | tr '\n'  '@' ; echo
  done

rm ${fname_stem}*.pbm


# Test Invalid.
echo "Test Invalid"

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

# No output files should be producd.  With nothing to remove,
# the rm commands should always fail.

# No input file
pamdice -width=10 -height=10  -outstem=${fname_stem} /dev/null || \
echo "Expected failure 1"
rm ${fname_stem}* ||
echo "Expected failure 1.rm"

# No -outstem
pamdice -width=10 -height=10 testgrid.pbm || \
echo "Expected failure 2"
rm ${fname_stem}* ||
echo "Expected failure 2.rm"

# -width=0
pamdice -width=0 -height=10 -outstem=${fname_stem} testgrid.pbm || \
echo "Expected failure 3"
rm ${fname_stem}* ||
echo "Expected failure 3.rm"

# -height=0
pamdice -width=10 -height=0 -outstem=${fname_stem} testgrid.pbm || \
echo "Expected failure 4"
rm ${fname_stem}* ||
echo "Expected failure 4.rm"

# -hoverlap larger than width
pamdice -width=10 -height=10 -hoverlap=11 \
  -outstem=${fname_stem} testgrid.pbm || \
echo "Expected failure 5"
rm ${fname_stem}* ||
echo "Expected failure 5.rm"


# -voverlap larger than height
pamdice -width=10 -height=10 -voverlap=11 \
  -outstem=${fname_stem} testgrid.pbm || \
echo "Expected failure 6"
rm ${fname_stem}* ||
echo "Expected failure 6.rm"