#! /bin/sh
# This script tests: pamtosvg
# Also requires: ppmmake ppmdraw

tmpdir=${tmpdir:-/tmp}
testline_svg=${tmpdir}/testline.svg
testgrid_svg=${tmpdir}/testgrid.svg

cat > ${testline_svg} << EOF
<?xml version="1.0" standalone="yes"?>
<svg width="20" height="20">
<path style="fill:#000000; stroke:none;" d="M0 0L0 20L20 20L20 0L0 0z"/>
<path style="fill:#ffffff; stroke:none;" d="M5 2L15 18L16 18L5 2z"/>
</svg>
EOF

echo "Test 1.  Should print match"

ppmmake black 20 20 | ppmdraw -script="line 5 2 15 17" | pamtosvg |\
    cmp -s ${testline_svg} - && echo "match" || echo "no match"
rm ${testline_svg}

cat > ${testgrid_svg} << EOF
<?xml version="1.0" standalone="yes"?>
<svg width="14" height="16">
<path style="fill:#000000; stroke:none;" d="M0 0L0 16L14 16L14 1L13 0L0 0z"/>
<path style="fill:#ffffff; stroke:none;" d="M1 0L2 1L1 0M3 0L4 1L3 0M5 0L6 \
1L5 0M7 0L8 1L7 0M9 0L10 1L9 0M11 0L12 1L11 0M13 0L14 1L13 0M1 2L2 3L1 2M3 \
2L4 3L3 2M5 2L6 3L5 2M7 2L8 3L7 2M9 2L10 3L9 2M11 2L12 3L11 2M13 2L14 3L13 \
2M1 4L2 5L1 4M3 4L4 5L3 4M5 4L6 5L5 4M7 4L8 5L7 4M9 4L10 5L9 4M11 4L12 5L11 \
4M13 4L14 5L13 4M1 6L2 7L1 6M3 6L4 7L3 6M5 6L6 7L5 6M7 6L8 7L7 6M9 6L10 7L9 \
6M11 6L12 7L11 6M13 6L14 7L13 6M1 8L2 9L1 8M3 8L4 9L3 8M5 8L6 9L5 8M7 8L8 9L7 \
8M9 8L10 9L9 8M11 8L12 9L11 8M13 8L14 9L13 8M1 10L2 11L1 10M3 10L4 11L3 10M5 \
10L6 11L5 10M7 10L8 11L7 10M9 10L10 11L9 10M11 10L12 11L11 10M13 10L14 11L13 \
10M1 12L2 13L1 12M3 12L4 13L3 12M5 12L6 13L5 12M7 12L8 13L7 12M9 12L10 13L9 \
12M11 12L12 13L11 12M13 12L14 13L13 12M1 14L2 15L1 14M3 14L4 15L3 14M5 14L6 \
15L5 14M7 14L8 15L7 14M9 14L10 15L9 14M11 14L12 15L11 14M13 14L14 15L13 14z"/>
</svg>
EOF

echo "Test 2.  Should print match"

pamtosvg testgrid.pbm |\
    cmp -s ${testgrid_svg} - && echo "match" || echo "no match"
rm ${testgrid_svg}
