summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorHenning Makholm <henning@makholm.net>2006-02-11 18:00:00 (EST)
committer Julien Jorge <julien.jorge@stuff-o-matic.com>2013-01-10 16:03:45 (EST)
commit00a8b13b5bf8cf2c367a0db3ae09086e45230968 (patch)
tree2cf634f141fc82b26bf1cfcc9de4c6f194208905 /test
parent03c71dffc5d7bcb4686260b21aaa268d68310613 (diff)
downloadxcftools-00a8b13b5bf8cf2c367a0db3ae09086e45230968.zip
xcftools-00a8b13b5bf8cf2c367a0db3ae09086e45230968.tar.gz
xcftools-00a8b13b5bf8cf2c367a0db3ae09086e45230968.tar.bz2
Import of release 0.9
Diffstat (limited to 'test')
-rw-r--r--test/answer/Addition.pngbin1236 -> 1542 bytes
-rw-r--r--test/answer/Burn.pngbin1501 -> 2120 bytes
-rw-r--r--test/answer/Color.pngbin0 -> 2172 bytes
-rw-r--r--test/answer/DarkenOnly.pngbin1056 -> 1341 bytes
-rw-r--r--test/answer/Difference.pngbin1823 -> 2057 bytes
-rw-r--r--test/answer/Divide.pngbin1750 -> 2463 bytes
-rw-r--r--test/answer/Dodge.pngbin2076 -> 2508 bytes
-rw-r--r--test/answer/GrainExtract.pngbin1523 -> 2013 bytes
-rw-r--r--test/answer/GrainMerge.pngbin1506 -> 1906 bytes
-rw-r--r--test/answer/Hardlight.pngbin2142 -> 3042 bytes
-rw-r--r--test/answer/Hue.pngbin0 -> 1659 bytes
-rw-r--r--test/answer/LightenOnly.pngbin1035 -> 1353 bytes
-rw-r--r--test/answer/Multiply.pngbin2255 -> 2964 bytes
-rw-r--r--test/answer/Overlay.pngbin1364 -> 2090 bytes
-rw-r--r--test/answer/Saturation.pngbin0 -> 2005 bytes
-rw-r--r--test/answer/Screen.pngbin2235 -> 2970 bytes
-rw-r--r--test/answer/Subtract.pngbin1438 -> 1592 bytes
-rw-r--r--test/answer/Value.pngbin0 -> 1351 bytes
-rw-r--r--test/answer/crisp1.pngbin248 -> 331 bytes
-rw-r--r--test/answer/huetest.pngbin0 -> 308 bytes
-rw-r--r--test/answer/index4.pngbin309 -> 315 bytes
-rw-r--r--test/answer/indextest.pngbin438 -> 448 bytes
-rw-r--r--test/answer/modeA.pngbin243 -> 410 bytes
-rw-r--r--test/answer/modeB.pngbin491 -> 495 bytes
-rwxr-xr-xtest/dotest212
-rw-r--r--test/source/huetest.xcf.gzbin0 -> 635 bytes
-rw-r--r--test/source/indextest.xcf.gzbin941 -> 943 bytes
-rw-r--r--test/source/mkmodebase.c17
-rw-r--r--test/source/modetest.xcf.gzbin836 -> 792 bytes
-rw-r--r--test/source/truncated.xcfbin0 -> 455 bytes
30 files changed, 214 insertions, 15 deletions
diff --git a/test/answer/Addition.png b/test/answer/Addition.png
index 93024de..c974f38 100644
--- a/test/answer/Addition.png
+++ b/test/answer/Addition.png
Binary files differ
diff --git a/test/answer/Burn.png b/test/answer/Burn.png
index b6e747e..d4e9907 100644
--- a/test/answer/Burn.png
+++ b/test/answer/Burn.png
Binary files differ
diff --git a/test/answer/Color.png b/test/answer/Color.png
new file mode 100644
index 0000000..f419579
--- /dev/null
+++ b/test/answer/Color.png
Binary files differ
diff --git a/test/answer/DarkenOnly.png b/test/answer/DarkenOnly.png
index 58f71dd..9248c9b 100644
--- a/test/answer/DarkenOnly.png
+++ b/test/answer/DarkenOnly.png
Binary files differ
diff --git a/test/answer/Difference.png b/test/answer/Difference.png
index 9a1c5fb..21e9bea 100644
--- a/test/answer/Difference.png
+++ b/test/answer/Difference.png
Binary files differ
diff --git a/test/answer/Divide.png b/test/answer/Divide.png
index a7668ec..d0be2ee 100644
--- a/test/answer/Divide.png
+++ b/test/answer/Divide.png
Binary files differ
diff --git a/test/answer/Dodge.png b/test/answer/Dodge.png
index 05d274b..7d76847 100644
--- a/test/answer/Dodge.png
+++ b/test/answer/Dodge.png
Binary files differ
diff --git a/test/answer/GrainExtract.png b/test/answer/GrainExtract.png
index c386af2..724bed5 100644
--- a/test/answer/GrainExtract.png
+++ b/test/answer/GrainExtract.png
Binary files differ
diff --git a/test/answer/GrainMerge.png b/test/answer/GrainMerge.png
index 616e232..0ca919b 100644
--- a/test/answer/GrainMerge.png
+++ b/test/answer/GrainMerge.png
Binary files differ
diff --git a/test/answer/Hardlight.png b/test/answer/Hardlight.png
index 8a4739d..27b6284 100644
--- a/test/answer/Hardlight.png
+++ b/test/answer/Hardlight.png
Binary files differ
diff --git a/test/answer/Hue.png b/test/answer/Hue.png
new file mode 100644
index 0000000..8acb1b3
--- /dev/null
+++ b/test/answer/Hue.png
Binary files differ
diff --git a/test/answer/LightenOnly.png b/test/answer/LightenOnly.png
index bb2200f..893fbf7 100644
--- a/test/answer/LightenOnly.png
+++ b/test/answer/LightenOnly.png
Binary files differ
diff --git a/test/answer/Multiply.png b/test/answer/Multiply.png
index 17e43b1..083165c 100644
--- a/test/answer/Multiply.png
+++ b/test/answer/Multiply.png
Binary files differ
diff --git a/test/answer/Overlay.png b/test/answer/Overlay.png
index 628d2b5..ce47807 100644
--- a/test/answer/Overlay.png
+++ b/test/answer/Overlay.png
Binary files differ
diff --git a/test/answer/Saturation.png b/test/answer/Saturation.png
new file mode 100644
index 0000000..dd20b06
--- /dev/null
+++ b/test/answer/Saturation.png
Binary files differ
diff --git a/test/answer/Screen.png b/test/answer/Screen.png
index 9335e59..438c005 100644
--- a/test/answer/Screen.png
+++ b/test/answer/Screen.png
Binary files differ
diff --git a/test/answer/Subtract.png b/test/answer/Subtract.png
index e5f03c5..9b68cbd 100644
--- a/test/answer/Subtract.png
+++ b/test/answer/Subtract.png
Binary files differ
diff --git a/test/answer/Value.png b/test/answer/Value.png
new file mode 100644
index 0000000..1b259ca
--- /dev/null
+++ b/test/answer/Value.png
Binary files differ
diff --git a/test/answer/crisp1.png b/test/answer/crisp1.png
index 927308e..f0e3f1e 100644
--- a/test/answer/crisp1.png
+++ b/test/answer/crisp1.png
Binary files differ
diff --git a/test/answer/huetest.png b/test/answer/huetest.png
new file mode 100644
index 0000000..ec38604
--- /dev/null
+++ b/test/answer/huetest.png
Binary files differ
diff --git a/test/answer/index4.png b/test/answer/index4.png
index 3de2398..c26cbee 100644
--- a/test/answer/index4.png
+++ b/test/answer/index4.png
Binary files differ
diff --git a/test/answer/indextest.png b/test/answer/indextest.png
index c8ff807..e3ea6a7 100644
--- a/test/answer/indextest.png
+++ b/test/answer/indextest.png
Binary files differ
diff --git a/test/answer/modeA.png b/test/answer/modeA.png
index 597099b..244c062 100644
--- a/test/answer/modeA.png
+++ b/test/answer/modeA.png
Binary files differ
diff --git a/test/answer/modeB.png b/test/answer/modeB.png
index d9836da..947d025 100644
--- a/test/answer/modeB.png
+++ b/test/answer/modeB.png
Binary files differ
diff --git a/test/dotest b/test/dotest
index 0bb6115..9074270 100755
--- a/test/dotest
+++ b/test/dotest
@@ -14,7 +14,7 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
export LC_CTYPE=C
export LC_MESSAGES=C
@@ -69,6 +69,16 @@ testrun() {
fi
}
+errtest() {
+ expect=$1
+ shift
+ program=${XCFTOOLS_PREFIX}$1
+ shift
+ [ -f expected:stderr ] && \
+ (sed "1s!^!$program: !" expected:stderr > expected.stderr)
+ testrun --exit $expect $program "$@"
+}
+
testinfo() {
testrun ${XCFTOOLS_PREFIX}xcfinfo "$@"
}
@@ -153,13 +163,160 @@ rm -f pngtype.want
S=source
+cp /dev/null expected.stdout
+
+#############################################################################
+#
+# Test for discovery of error conditions.
+#
+
+echo > expected:stderr \
+ "The --mode option must follow a layer name on the command line"
+errtest 20 xcf2pnm $S/modetest.xcf.gz --mode Addition A B
+
+echo > expected:stderr \
+ "The --percent option must follow a layer name on the command line"
+errtest 20 xcf2png $S/tiletest.xcf.gz --percent 33 Mid
+
+echo > expected:stderr \
+ "The image has no layer called 'MID'"
+errtest 22 xcf2pnm $S/tiletest.xcf.gz Background MID -o foo.pnm
+
+echo > expected:stderr \
+ "Layer 'Vert' has no layer mask to enable"
+errtest 22 xcf2pnm $S/tiletest.xcf.gz Background Vert --mask Horiz --nomask
+
+echo > expected:stderr \
+ "Grayscale output selected, but colored pixel(s) found"
+errtest 103 xcf2pnm -o o.pgm $S/tiletest.xcf.gz Background
+errtest 103 xcf2png -o o.png -g $S/tiletest.xcf.gz Background
+rm -rf o.pgm o.png
+errtest 103 xcf2pnm -o o.pgm $S/tiletest.xcf.gz Background -f
+if [ -f o.pgm ] ; then echo o.pgm exists ; failed ; fi
+errtest 103 xcf2png -o o.png -g $S/tiletest.xcf.gz Background -f
+if [ -f o.png ] ; then echo o.png exists ; failed ; fi
+
+echo > expected:stderr \
+ "Monochrome output selected, but not all pixels are black or white"
+errtest 103 xcf2pnm -o o.pbm $S/tiletest.xcf.gz Background
+errtest 103 xcf2pnm -o o.pbm $S/tiletest.xcf.gz Background \
+ 'Straight loop' 'Long and low'
+rm -rf o.pbm
+errtest 103 xcf2pnm -o o.pbm $S/tiletest.xcf.gz Background -f
+if [ -f o.pbm ] ; then echo o.pbm exists ; failed ; fi
+errtest 103 xcf2pnm -o o.pbm $S/tiletest.xcf.gz Background -f \
+ 'Straight loop' 'Long and low'
+if [ -f o.pbm ] ; then echo o.pbm exists ; failed ; fi
+
+cat > expected:stderr <<EOF
+The image contains features not understood by this program:
+ 'AntiErase' layer mode
+EOF
+errtest 123 xcf2pnm $S/modetest.xcf.gz A B --mode AntiErase
+
+echo > expected:stderr \
+ "Flattened image has partially transparent pixels"
+errtest 102 xcf2pnm $S/modetest.xcf.gz -G
+
+cat > expected:stderr <<EOF
+Corrupted or malformed XCF file:
+ Not an XCF file at all (magic not recognized)
+EOF
+errtest 125 xcfinfo answer/modeA.png
+
+rm expected:stderr
+cat > expected.stderr <<EOF
+Warning: XCF version 345 not supported (trying anyway...)
+${XCFTOOLS_PREFIX}xcf2png: Corrupted or truncated XCF file
+ (0x1C7 bytes): Overlong property at 82
+EOF
+errtest 125 xcf2png $S/truncated.xcf
+
+echo > expected:stderr \
+ "Transparency found, but -a option not given"
+errtest 100 xcf2pnm $S/modetest.xcf.gz -o o.pnm
+
+echo > expected:stderr \
+ "The -a option was given, but the image has no transparency"
+errtest 101 xcf2pnm $S/modetest.xcf.gz -b white -a a.pgm
+errtest 101 xcf2pnm $S/tiletest.xcf.gz -a a.pgm
+
+echo > expected:stderr \
+ "Only one XCF file per command line, please"
+errtest 20 xcfinfo $S/tiletest.xcf.gz Background 'Long and low'
+
+rm expected:stderr
+rgbfile=/usr/lib/X11/rgb.txt
+( [ -f $rgbfile ] || echo "Could not open color database file $rgbfile" ) \
+ > expected.stderr
+echo "${XCFTOOLS_PREFIX}xcf2pnm: Unknown background color 'Plaid'" \
+ >> expected.stderr
+errtest 20 xcf2pnm $S/tiletext.xcf.gz -b Plaid
+
+echo > expected:stderr \
+ "-S option must have an argument of the form wxh"
+errtest 20 xcf2pnm $S/tiletext.xcf.gz -S 10x
+errtest 20 xcf2pnm $S/tiletext.xcf.gz -S 10x20x30
+
+echo > expected:stderr \
+ "-O option must have an argument of the form x,y"
+errtest 20 xcf2pnm $S/tiletest.xcf.gz -S 10x10 -O 2x4
+
+echo > expected:stderr \
+ "Layer mode 'GammaShift' is unknown"
+errtest 20 xcf2png $S/modetest.xcf.gz B A --mode GammaShift
+
+echo > expected:stderr \
+ "The argument to --percent is not a percentage"
+errtest 20 xcf2pnm $S/tiletest.xcf.gz Background Mid --percent -3
+errtest 20 xcf2pnm $S/tiletest.xcf.gz Background Mid --percent 20.2
+errtest 20 xcf2pnm $S/tiletest.xcf.gz Background Mid --percent 101
+
+echo > expected:stderr \
+ "The argument to --opacity is not a number between 0 and 255"
+errtest 20 xcf2pnm $S/tiletest.xcf.gz Background Mid --opacity -3
+errtest 20 xcf2pnm $S/tiletest.xcf.gz Background Mid --opacity 220.2
+errtest 20 xcf2pnm $S/tiletest.xcf.gz Background Mid --opacity 256
+
+#######################################################
+#
+# Error tests for io-unix.c
+#
+# XXX: if another I/O module is added later, these tests should
+# be conditionally enabled
+#
+
+cat <<EOF > enoent.c
+#include <errno.h>
+#include <stdio.h>
+int main(int argc,char **argv) { errno = ENOENT;
+ if( argv[1][0] == '!' ) { errno = EACCES; argv++; }
+ perror(argv[1]); return 0; }
+EOF
+cp /dev/null expected.stderr
+testrun cc enoent.c
+./a.out $S/nonexist.xcf 2> expected:stderr
+errtest 21 xcfinfo $S/nonexist.xcf
+
+rm expected:stderr
+./a.out "Cannot execute source/nonexist.xcf" 2> expected.stderr
+errtest 126 xcf2png -Z $S/nonexist.xcf $S/tiletest.xcf.gz
+
cp /dev/null expected.stderr
+command false
+errtest $? xcf2png -Z false $S/tiletest.xcf.gz
+
+./a.out ! "Cannot execute answer/modeA.png" 2> expected.stderr
+errtest 126 xcf2pnm -Z answer/modeA.png $S/comptest.xcf.gz
+
+rm -f expected:stderr
#############################################################################
#
# Use all of the example XCF inputs as checks of xcfinfo
#
+cp /dev/null expected.stderr
cat <<EOF > expected.stdout
Version 0, 256x256 Grayscale, 2 layers, compressed RLE
+ 256x256+0+0 Grayscale-alpha Normal Partially transparent
@@ -206,6 +363,13 @@ EOF
testinfo $S/i256.xcf.gz
testinfo $S/i255.xcf.gz
+cat <<EOF > expected.stdout
+Version 0, 32x40 RGB color, 2 layers, compressed RLE
++ 32x40+0+0 RGB-alpha Hue Hue
++ 32x40+0+0 RGB Normal Background
+EOF
+testinfo $S/huetest.xcf.gz
+
cp /dev/null expected.stdout
#############################################################################
@@ -231,12 +395,16 @@ testpnm o:Subtract a:modeA modetest
testpnm o:Addition a:modeB modetest B A -f
for mode in Multiply Screen Overlay Difference DarkenOnly \
LightenOnly Divide Dodge Burn GrainExtract GrainMerge \
- Hardlight
+ Hardlight Hue Saturation Value Color
do
testpnm o:$mode a:modeA modetest A B --mode $mode
done
testpnm o:Overlay a:modeA modetest AE=AE A --mode Normal B --mode Softlight
+# huetest.xcf.gz is an auxiliary test that makes sure that all of the
+# six hue hexants have matching implementations in RGB->HSV and HSV->RGB
+
+testpnm o:huetest huetest
#############################################################################
#
@@ -300,12 +468,16 @@ testpnm o:burmid tiletest Mid -S 27x25 -O 5,5 -b '#963'
# Tests of xcf2png
#
-#############################################################################
#
# Basic functionality
#
testpng tiletest tiletest
+cat <<EOF > pngtype.want
+64x64x8
+color+alpha
+z0 f0 i0
+EOF
testpng modeA modetest A
#############################################################################
@@ -364,11 +536,29 @@ testpng gray tiletest Background 'Straight loop' 'Long and low' -f
testpng gray tiletest Background 'Straight loop' 'Long and low' -g
testpng comptest comptest
-# RGB: many of the layer mode tests test this
+# RGB: The tiletest runs above test this
# gray+alpha
testpng comptestB comptest 'Partially transparent' -f
+# RGB+artificial alpha
+cat <<EOF > pngtype.want
+161x161x8
+color+alpha
+z0 f0 i0
+EOF
+testpng A:-pgm tiletest tiletest -A
+
+# RGS+artificial alpha, compressed
+cat <<EOF > pngtype.want
+161x161x8
+color
+z0 f0 i0
+tRNS(6)
+ 00 06 00 06 00 06
+EOF
+testpng tiletest tiletest -A -f
+
# RGB+alpha
cat <<EOF > pngtype.want
16x20x8
@@ -396,7 +586,7 @@ testpng "b:0,0,0" crisp1 modetest -S16x20 -O48,46 -c -f
testpng crisp1 modetest -S16x20 -O48,46 -f
# index, various transparent colors
-testpng modeB modetest B -f
+testpng modeA modetest A -f
#############################################################################
#
@@ -445,6 +635,18 @@ PLTE(12)
EOF
testpng index4 indextest Background -f
+# 4 colors, artificial transparency
+cat <<EOF > pngtype.want
+64x64x2
+color+index
+z0 f0 i0
+PLTE(12)
+ DC 98 85 FF 00 77 10 36 38 FF B4 23
+tRNS(4)
+ FF FF FF FF
+EOF
+testpng index4 indextest Background -f -A
+
# 16 colors, no transparency
testpng mid tiletest -O17,17 -S32x32 -f
diff --git a/test/source/huetest.xcf.gz b/test/source/huetest.xcf.gz
new file mode 100644
index 0000000..b1f24a3
--- /dev/null
+++ b/test/source/huetest.xcf.gz
Binary files differ
diff --git a/test/source/indextest.xcf.gz b/test/source/indextest.xcf.gz
index b782acf..f8675eb 100644
--- a/test/source/indextest.xcf.gz
+++ b/test/source/indextest.xcf.gz
Binary files differ
diff --git a/test/source/mkmodebase.c b/test/source/mkmodebase.c
index 3e5c656..376be12 100644
--- a/test/source/mkmodebase.c
+++ b/test/source/mkmodebase.c
@@ -7,17 +7,14 @@
void
makepixel(int x,int y,int *r,int *g,int *b,int *a) {
- if( y < 3 || y >= 61 ) {
+ if( x < 3 || x >= 61 ) {
*a = 0 ;
return ;
}
- if( x < 3 || x >= 61 ||
- y < 6 || y >= 58 ) {
- *r=*g=*b=*a=255 ;
- return ;
- }
- if( x < 6 || x >= 58 ) {
- *a=0 ;
+ if( y < 3 || y >= 61 ||
+ x < 6 || x >= 58 ) {
+ *a = 255 ;
+ *r=*g=*b= 255*(x>=32) ;
return ;
}
x -= 6 ;
@@ -39,8 +36,8 @@ makepixel(int x,int y,int *r,int *g,int *b,int *a) {
x -= 17 ;
if( x <= 17 ) {
*r = (17-x)*15 ;
- *g = 255 ;
- *b = x*15 ;
+ *g = (17-x)*15 ;
+ *b = (x-1)*15 ;
return ;
}
*r=255 ;
diff --git a/test/source/modetest.xcf.gz b/test/source/modetest.xcf.gz
index c2d7f8a..d4b37c1 100644
--- a/test/source/modetest.xcf.gz
+++ b/test/source/modetest.xcf.gz
Binary files differ
diff --git a/test/source/truncated.xcf b/test/source/truncated.xcf
new file mode 100644
index 0000000..0229b3f
--- /dev/null
+++ b/test/source/truncated.xcf
Binary files differ