about summary refs log tree commit diff
path: root/test/macp-roundtrip.test
blob: b264e3d1a8b948a449684f06001dce5e606f4a39 (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
#! /bin/bash
# This script tests: pbmtomacp macptopbm
# Also requires: pnmcrop pbmpage pbmupc pnmpad pbmmake

tmpdir=${tmpdir:-/tmp}
temp1_pbm=${tmpdir}/temp1.pbm
temp2_pbm=${tmpdir}/temp2.pbm
tempupc_pbm=${tmpdir}/tempupc.pbm
temp3_pbm=${tmpdir}/temp3.pbm
temp3_macp=${tmpdir}/temp3.macp

# Macpaint files are fixed size (576 x 720 pixels)
# pbmtomacp automatically adds padding when input is smaller.

echo "Test 1. Should produce 281226646 481 twice"
pbmtomacp maze.pbm | macptopbm | tee ${temp1_pbm} | \
    pnmcrop | cksum

pbmtomacp ${temp1_pbm} | macptopbm | pnmcrop | cksum

rm ${temp1_pbm}

echo "Test 2. Should produce 2329957971 51851"
pbmpage 1 | pbmtomacp | macptopbm | cksum

echo "Test 3. Should produce 2907103393 5086 three times"
pbmupc 0 12345 67890 | tee ${tempupc_pbm} | \
    pnmpad -black -t 44 -b 20 -l 100 -r 251 | \
    pbmtomacp | macptopbm | \
    tee ${temp2_pbm} | \
    pnmcrop | pnmcrop | cksum

pnmpad -black -t 44 -l 100 ${tempupc_pbm} | \
    pbmtomacp|  macptopbm | pnmcrop -white | pnmcrop | cksum

pbmtomacp ${temp2_pbm} | macptopbm | pnmcrop | pnmcrop | cksum

rm ${temp2_pbm} ${tempupc_pbm}


echo "Test 4. Should produce 3432623660 51851 four times"
pbmmake -b 576 720 | tee ${temp3_pbm} | cksum

pbmtomacp ${temp3_pbm} | tee ${temp3_macp} | macptopbm | cksum

pbmtomacp -norle ${temp3_pbm} | macptopbm | cksum

( head -c 128 /dev/zero ; cat ${temp3_macp} ) | \
    macptopbm -extraskip 128 | cksum

rm ${temp3_pbm} ${temp3_macp}