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

tmpdir=${tmpdir:-/tmp}
base_pbm=${tmpdir}/font.pbm
insert_pbm=${tmpdir}/insert.pbm

cat > ${base_pbm} << EOF
P1
18 1
000111000111000111
EOF

pbmmake -g 15 1 > ${insert_pbm}

# Test 1.
echo "Test 1."

for operation in "-replace" "-and" "-or" "-xor" "-nand" "-nor" "-nxor"
  do
  echo ${operation} 
  pnmpaste ${operation} -plain ${insert_pbm} 1 0 ${base_pbm} | tr '\n' ' '
  echo
  done


# Test 2.
# Perform an operation and its negative counterpart, combine the
# resulting images with "-xor".
# The untouched area of the base image should be 1; inserted area 0.

echo "Test 2."

positive_pbm=${tmpdir}/positive.pbm
negative_pbm=${tmpdir}/negative.pbm

for operation in "and" "or" "xor"
  do
  echo "-"$operation " -n"$operation 
  pnmpaste "-"${operation} ${insert_pbm} 2 0 ${base_pbm} > ${positive_pbm}
  pnmpaste "-n"${operation} ${insert_pbm} 2 0 ${base_pbm} > ${negative_pbm}
  pnmpaste -xor -plain ${positive_pbm} 0 0 ${negative_pbm} | tr '\n ' ' '
  echo
  done

rm ${base_pbm} ${insert_pbm} ${positive_pbm} ${negative_pbm}