From 85836c5f813bb25879f1db7feace5317e7653af4 Mon Sep 17 00:00:00 2001 From: anthony Date: Thu, 29 Mar 2012 11:54:02 +0000 Subject: [PATCH] More MagickWand Tests --- MagickWand/tests/Makefile | 20 +++++ MagickWand/tests/add_first.c | 72 +++++++++++++++ MagickWand/tests/add_first_lists.c | 91 +++++++++++++++++++ MagickWand/tests/add_index.c | 81 +++++++++++++++++ MagickWand/tests/add_last.c | 71 +++++++++++++++ MagickWand/tests/add_last_lists.c | 90 +++++++++++++++++++ MagickWand/tests/add_mixed.c | 95 ++++++++++++++++++++ MagickWand/tests/add_mixed_lists.c | 90 +++++++++++++++++++ MagickWand/tests/add_norm.c | 69 +++++++++++++++ MagickWand/tests/add_norm_lists.c | 89 +++++++++++++++++++ MagickWand/tests/font_0.gif | Bin 0 -> 241 bytes MagickWand/tests/font_1.gif | Bin 0 -> 198 bytes MagickWand/tests/font_2.gif | Bin 0 -> 203 bytes MagickWand/tests/font_3.gif | Bin 0 -> 204 bytes MagickWand/tests/font_4.gif | Bin 0 -> 221 bytes MagickWand/tests/font_5.gif | Bin 0 -> 221 bytes MagickWand/tests/font_6.gif | Bin 0 -> 222 bytes MagickWand/tests/font_7.gif | Bin 0 -> 187 bytes MagickWand/tests/font_8.gif | Bin 0 -> 226 bytes MagickWand/tests/font_9.gif | Bin 0 -> 215 bytes MagickWand/tests/loop_over_lists.c | 128 +++++++++++++++++++++++++++ MagickWand/tests/script-token-test.c | 1 + 22 files changed, 897 insertions(+) create mode 100644 MagickWand/tests/Makefile create mode 100644 MagickWand/tests/add_first.c create mode 100644 MagickWand/tests/add_first_lists.c create mode 100644 MagickWand/tests/add_index.c create mode 100644 MagickWand/tests/add_last.c create mode 100644 MagickWand/tests/add_last_lists.c create mode 100644 MagickWand/tests/add_mixed.c create mode 100644 MagickWand/tests/add_mixed_lists.c create mode 100644 MagickWand/tests/add_norm.c create mode 100644 MagickWand/tests/add_norm_lists.c create mode 100644 MagickWand/tests/font_0.gif create mode 100644 MagickWand/tests/font_1.gif create mode 100644 MagickWand/tests/font_2.gif create mode 100644 MagickWand/tests/font_3.gif create mode 100644 MagickWand/tests/font_4.gif create mode 100644 MagickWand/tests/font_5.gif create mode 100644 MagickWand/tests/font_6.gif create mode 100644 MagickWand/tests/font_7.gif create mode 100644 MagickWand/tests/font_8.gif create mode 100644 MagickWand/tests/font_9.gif create mode 100644 MagickWand/tests/loop_over_lists.c diff --git a/MagickWand/tests/Makefile b/MagickWand/tests/Makefile new file mode 100644 index 000000000..3eef27123 --- /dev/null +++ b/MagickWand/tests/Makefile @@ -0,0 +1,20 @@ + +# get includes and libraries from source directory +SRC=$(shell pwd )/../.. +CFLAGS=-I$(SRC) -L$(SRC)/MagickWand/.libs -L$(SRC)/MagickCore/.libs + +# get includes and libraries from installed ImageMagick-devel Package +#CFLAGS=-I/usr/include/ImageMagick + +LDLIBS=-lMagickWand -lMagickCore + +files=$(wildcard *.c) +tests=$(files:%.c=%) + +all: $(tests) + +script-token-test: script-token-test.c ../script-token.[ch] + $(CC) -o script-token-test script-token-test.c + +clean: + rm -f $(tests) diff --git a/MagickWand/tests/add_first.c b/MagickWand/tests/add_first.c new file mode 100644 index 000000000..f3b387464 --- /dev/null +++ b/MagickWand/tests/add_first.c @@ -0,0 +1,72 @@ +#include +#include + +/* Simplify the exception handling + * technically we should abort the program if + * severity >= ErrorException + */ +void ThrowWandException(MagickWand *wand) +{ char + *description; + + ExceptionType + severity; + + description=MagickGetException(wand,&severity); + (void) fprintf(stderr,"%s %s %lu %s\n",GetMagickModule(),description); + description=(char *) MagickRelinquishMemory(description); +} + +/* useful function especially after appending two wands together */ +#define SwapWands(a,b) { MagickWand *tmp=a; a=b; b=tmp; } + +int main(int argc, char *argv[]) +{ + MagickWand + *wand, + *input, + *output; + + MagickBooleanType + status; + + printf("Check prepend when using 'FirstIterator' on empty wand\n"); + printf("Result shoud be: 3210\n"); + + MagickWandGenesis(); + + wand = NewMagickWand(); + + MagickSetFirstIterator(wand); /* set first iterator to empty wand */ + + status = MagickReadImage(wand, "font_0.gif" ); + if (status == MagickFalse) + ThrowWandException(wand); + + status = MagickReadImage(wand, "font_1.gif" ); + if (status == MagickFalse) + ThrowWandException(wand); + + status = MagickReadImage(wand, "font_2.gif" ); + if (status == MagickFalse) + ThrowWandException(wand); + + status = MagickReadImage(wand, "font_3.gif" ); + if (status == MagickFalse) + ThrowWandException(wand); + + /* append all images together to create the output wand */ + MagickResetIterator(wand); /* append all images */ + output = MagickAppendImages(wand,MagickFalse); + wand = DestroyMagickWand(wand); /* finished - could swap here */ + + /* Final output */ + status = MagickWriteImage(output,"show:"); + if (status == MagickFalse) + ThrowWandException(output); + + output = DestroyMagickWand(output); + + MagickWandTerminus(); +} + diff --git a/MagickWand/tests/add_first_lists.c b/MagickWand/tests/add_first_lists.c new file mode 100644 index 000000000..25ff7736a --- /dev/null +++ b/MagickWand/tests/add_first_lists.c @@ -0,0 +1,91 @@ +#include +#include + +/* Simplify the exception handling + * technically we should abort the program if + * severity >= ErrorException + */ +void ThrowWandException(MagickWand *wand) +{ char + *description; + + ExceptionType + severity; + + description=MagickGetException(wand,&severity); + (void) fprintf(stderr,"%s %s %lu %s\n",GetMagickModule(),description); + description=(char *) MagickRelinquishMemory(description); +} + +/* useful function especially after appending two wands together */ +#define SwapWands(a,b) { MagickWand *tmp=a; a=b; b=tmp; } + +int main(int argc, char *argv[]) +{ + MagickWand + *wand, + *input, + *output; + + MagickBooleanType + status; + + printf("Add 3 sets of images after setting 'first' on empty wand\n"); + printf("Result shoud be: 678 345 012\n"); + + MagickWandGenesis(); + + wand = NewMagickWand(); + input = NewMagickWand(); + + MagickSetFirstIterator(wand); + + status = MagickReadImage(input, "font_0.gif" ) + && MagickReadImage(input, "font_1.gif" ) + && MagickReadImage(input, "font_2.gif" ); + if (status == MagickFalse) + ThrowWandException(input); + + status = MagickAddImage(wand, input); + if (status == MagickFalse) + ThrowWandException(wand); + + ClearMagickWand(input); + status = MagickReadImage(input, "font_3.gif" ) + && MagickReadImage(input, "font_4.gif" ) + && MagickReadImage(input, "font_5.gif" ); + if (status == MagickFalse) + ThrowWandException(input); + + status = MagickAddImage(wand, input); + if (status == MagickFalse) + ThrowWandException(wand); + + ClearMagickWand(input); + status = MagickReadImage(input, "font_6.gif" ) + && MagickReadImage(input, "font_7.gif" ) + && MagickReadImage(input, "font_8.gif" ); + if (status == MagickFalse) + ThrowWandException(input); + + + status = MagickAddImage(wand, input); + if (status == MagickFalse) + ThrowWandException(wand); + input=DestroyMagickWand(input); /* finished */ + + /* append all images together to create the output wand */ + MagickResetIterator(wand); /* append all images */ + output = MagickAppendImages(wand,MagickFalse); + wand = DestroyMagickWand(wand); /* finished - could swap here */ + + /* Final output */ + status = MagickWriteImage(output,"show:"); + if (status == MagickFalse) + ThrowWandException(output); + + output = DestroyMagickWand(output); + + MagickWandTerminus(); +} + diff --git a/MagickWand/tests/add_index.c b/MagickWand/tests/add_index.c new file mode 100644 index 000000000..4601854e8 --- /dev/null +++ b/MagickWand/tests/add_index.c @@ -0,0 +1,81 @@ +#include +#include + +/* Simplify the exception handling + * technically we should abort the program if + * severity >= ErrorException + */ +void ThrowWandException(MagickWand *wand) +{ char + *description; + + ExceptionType + severity; + + description=MagickGetException(wand,&severity); + (void) fprintf(stderr,"%s %s %lu %s\n",GetMagickModule(),description); + description=(char *) MagickRelinquishMemory(description); +} + +/* useful function especially after appending two wands together */ +#define SwapWands(a,b) { MagickWand *tmp=a; a=b; b=tmp; } + +int main(int argc, char *argv[]) +{ + MagickWand + *wand, + *input, + *output; + + MagickBooleanType + status; + + printf("Read 4 images, then set index 1 and read more individual images\n"); + printf("Result shoud be: 01 654 23\n"); + + MagickWandGenesis(); + + wand = NewMagickWand(); + input = NewMagickWand(); + + status = MagickReadImage(input, "font_0.gif" ) + && MagickReadImage(input, "font_1.gif" ) + && MagickReadImage(input, "font_2.gif" ) + && MagickReadImage(input, "font_3.gif" ); + if (status == MagickFalse) + ThrowWandException(input); + + status = MagickAddImage(wand, input); + if (status == MagickFalse) + ThrowWandException(wand); + input=DestroyMagickWand(input); /* finished */ + + MagickSetIteratorIndex(wand, 1); + + status = MagickReadImage(wand, "font_4.gif" ); + if (status == MagickFalse) + ThrowWandException(wand); + + status = MagickReadImage(wand, "font_5.gif" ); + if (status == MagickFalse) + ThrowWandException(wand); + + status = MagickReadImage(wand, "font_6.gif" ); + if (status == MagickFalse) + ThrowWandException(wand); + + /* append all images together to create the output wand */ + MagickResetIterator(wand); /* append all images */ + output = MagickAppendImages(wand,MagickFalse); + wand = DestroyMagickWand(wand); /* finished - could swap here */ + + /* Final output */ + status = MagickWriteImage(output,"show:"); + if (status == MagickFalse) + ThrowWandException(output); + + output = DestroyMagickWand(output); + + MagickWandTerminus(); +} + diff --git a/MagickWand/tests/add_last.c b/MagickWand/tests/add_last.c new file mode 100644 index 000000000..fcf913423 --- /dev/null +++ b/MagickWand/tests/add_last.c @@ -0,0 +1,71 @@ +#include +#include + +/* Simplify the exception handling + * technically we should abort the program if + * severity >= ErrorException + */ +void ThrowWandException(MagickWand *wand) +{ char + *description; + + ExceptionType + severity; + + description=MagickGetException(wand,&severity); + (void) fprintf(stderr,"%s %s %lu %s\n",GetMagickModule(),description); + description=(char *) MagickRelinquishMemory(description); +} + +/* useful function especially after appending two wands together */ +#define SwapWands(a,b) { MagickWand *tmp=a; a=b; b=tmp; } + +int main(int argc, char *argv[]) +{ + MagickWand + *wand, + *output; + + MagickBooleanType + status; + + printf("Check append when using 'LastIterator' on empty wand\n"); + printf("Result shoud be: 0123\n"); + + MagickWandGenesis(); + + wand = NewMagickWand(); + + MagickSetLastIterator(wand); /* to empty wand */ + + status = MagickReadImage(wand, "font_0.gif" ); + if (status == MagickFalse) + ThrowWandException(wand); + + status = MagickReadImage(wand, "font_1.gif" ); + if (status == MagickFalse) + ThrowWandException(wand); + + status = MagickReadImage(wand, "font_2.gif" ); + if (status == MagickFalse) + ThrowWandException(wand); + + status = MagickReadImage(wand, "font_3.gif" ); + if (status == MagickFalse) + ThrowWandException(wand); + + /* append all images together to create the output wand */ + MagickResetIterator(wand); /* append all images */ + output = MagickAppendImages(wand,MagickFalse); + wand = DestroyMagickWand(wand); /* finished - could swap here */ + + /* Final output */ + status = MagickWriteImage(output,"show:"); + if (status == MagickFalse) + ThrowWandException(output); + + output = DestroyMagickWand(output); + + MagickWandTerminus(); +} + diff --git a/MagickWand/tests/add_last_lists.c b/MagickWand/tests/add_last_lists.c new file mode 100644 index 000000000..6013e0f38 --- /dev/null +++ b/MagickWand/tests/add_last_lists.c @@ -0,0 +1,90 @@ +#include +#include + +/* Simplify the exception handling + * technically we should abort the program if + * severity >= ErrorException + */ +void ThrowWandException(MagickWand *wand) +{ char + *description; + + ExceptionType + severity; + + description=MagickGetException(wand,&severity); + (void) fprintf(stderr,"%s %s %lu %s\n",GetMagickModule(),description); + description=(char *) MagickRelinquishMemory(description); +} + +/* useful function especially after appending two wands together */ +#define SwapWands(a,b) { MagickWand *tmp=a; a=b; b=tmp; } + +int main(int argc, char *argv[]) +{ + MagickWand + *wand, + *input, + *output; + + MagickBooleanType + status; + + printf("Add 3 sets of images after setting 'last' on empty wand\n"); + printf("Result shoud be: 012 345 678\n"); + + MagickWandGenesis(); + + wand = NewMagickWand(); + input = NewMagickWand(); + + MagickSetLastIterator(wand); + + status = MagickReadImage(input, "font_0.gif" ) + && MagickReadImage(input, "font_1.gif" ) + && MagickReadImage(input, "font_2.gif" ); + if (status == MagickFalse) + ThrowWandException(input); + + status = MagickAddImage(wand, input); + if (status == MagickFalse) + ThrowWandException(wand); + + ClearMagickWand(input); + status = MagickReadImage(input, "font_3.gif" ) + && MagickReadImage(input, "font_4.gif" ) + && MagickReadImage(input, "font_5.gif" ); + if (status == MagickFalse) + ThrowWandException(input); + + status = MagickAddImage(wand, input); + if (status == MagickFalse) + ThrowWandException(wand); + + ClearMagickWand(input); + status = MagickReadImage(input, "font_6.gif" ) + && MagickReadImage(input, "font_7.gif" ) + && MagickReadImage(input, "font_8.gif" ); + if (status == MagickFalse) + ThrowWandException(input); + + status = MagickAddImage(wand, input); + if (status == MagickFalse) + ThrowWandException(wand); + input=DestroyMagickWand(input); + + /* append all images together to create the output wand */ + MagickResetIterator(wand); /* append all images */ + output = MagickAppendImages(wand,MagickFalse); + wand = DestroyMagickWand(wand); /* finished - could swap here */ + + /* Final output */ + status = MagickWriteImage(output,"show:"); + if (status == MagickFalse) + ThrowWandException(output); + + output = DestroyMagickWand(output); + + MagickWandTerminus(); +} + diff --git a/MagickWand/tests/add_mixed.c b/MagickWand/tests/add_mixed.c new file mode 100644 index 000000000..cc947c154 --- /dev/null +++ b/MagickWand/tests/add_mixed.c @@ -0,0 +1,95 @@ +#include +#include + +/* Simplify the exception handling + * technically we should abort the program if + * severity >= ErrorException + */ +void ThrowWandException(MagickWand *wand) +{ char + *description; + + ExceptionType + severity; + + description=MagickGetException(wand,&severity); + (void) fprintf(stderr,"%s %s %lu %s\n",GetMagickModule(),description); + description=(char *) MagickRelinquishMemory(description); +} + +/* useful function especially after appending two wands together */ +#define SwapWands(a,b) { MagickWand *tmp=a; a=b; b=tmp; } + +int main(int argc, char *argv[]) +{ + MagickWand + *wand, /* red image wand */ + *output; + + MagickBooleanType + status; + + printf("Read 3 sets of 3 Images, each set with settings: none, first, last\n"); + printf("Result shoud be: 543 012 678\n"); + + MagickWandGenesis(); + + /* read in the red image */ + wand = NewMagickWand(); + + /* add test from empty wand */ + status = MagickReadImage(wand, "font_0.gif" ); + if (status == MagickFalse) + ThrowWandException(wand); + + status = MagickReadImage(wand, "font_1.gif" ); + if (status == MagickFalse) + ThrowWandException(wand); + + status = MagickReadImage(wand, "font_2.gif" ); + if (status == MagickFalse) + ThrowWandException(wand); + + /* add test to start */ + MagickSetFirstIterator(wand); + status = MagickReadImage(wand, "font_3.gif" ); + if (status == MagickFalse) + ThrowWandException(wand); + + status = MagickReadImage(wand, "font_4.gif" ); + if (status == MagickFalse) + ThrowWandException(wand); + + status = MagickReadImage(wand, "font_5.gif" ); + if (status == MagickFalse) + ThrowWandException(wand); + + /* add test to end */ + MagickSetLastIterator(wand); + status = MagickReadImage(wand, "font_6.gif" ); + if (status == MagickFalse) + ThrowWandException(wand); + + status = MagickReadImage(wand, "font_7.gif" ); + if (status == MagickFalse) + ThrowWandException(wand); + + status = MagickReadImage(wand, "font_8.gif" ); + if (status == MagickFalse) + ThrowWandException(wand); + + /* append all images together to create the output wand */ + MagickResetIterator(wand); /* append all images */ + output = MagickAppendImages(wand,MagickFalse); + wand = DestroyMagickWand(wand); /* finished - could swap here */ + + /* Final output */ + status = MagickWriteImage(output,"show:"); + if (status == MagickFalse) + ThrowWandException(output); + + output = DestroyMagickWand(output); + + MagickWandTerminus(); +} + diff --git a/MagickWand/tests/add_mixed_lists.c b/MagickWand/tests/add_mixed_lists.c new file mode 100644 index 000000000..8d33e5caf --- /dev/null +++ b/MagickWand/tests/add_mixed_lists.c @@ -0,0 +1,90 @@ +#include +#include + +/* Simplify the exception handling + * technically we should abort the program if + * severity >= ErrorException + */ +void ThrowWandException(MagickWand *wand) +{ char + *description; + + ExceptionType + severity; + + description=MagickGetException(wand,&severity); + (void) fprintf(stderr,"%s %s %lu %s\n",GetMagickModule(),description); + description=(char *) MagickRelinquishMemory(description); +} + +/* useful function especially after appending two wands together */ +#define SwapWands(a,b) { MagickWand *tmp=a; a=b; b=tmp; } + +int main(int argc, char *argv[]) +{ + MagickWand + *wand, /* red image wand */ + *input, /* red image wand */ + *output; + + MagickBooleanType + status; + + printf("Add 3 sets of image using settings: none, first, last\n"); + printf("Result shoud be: 345 012 678\n"); + + MagickWandGenesis(); + + wand = NewMagickWand(); + input = NewMagickWand(); + + status = MagickReadImage(input, "font_0.gif" ) + && MagickReadImage(input, "font_1.gif" ) + && MagickReadImage(input, "font_2.gif" ); + if (status == MagickFalse) + ThrowWandException(input); + + status = MagickAddImage(wand, input); + if (status == MagickFalse) + ThrowWandException(wand); + + ClearMagickWand(input); + status = MagickReadImage(input, "font_3.gif" ) + && MagickReadImage(input, "font_4.gif" ) + && MagickReadImage(input, "font_5.gif" ); + if (status == MagickFalse) + ThrowWandException(input); + + MagickSetFirstIterator(wand); + status = MagickAddImage(wand, input); + if (status == MagickFalse) + ThrowWandException(wand); + + ClearMagickWand(input); + status = MagickReadImage(input, "font_6.gif" ) + && MagickReadImage(input, "font_7.gif" ) + && MagickReadImage(input, "font_8.gif" ); + if (status == MagickFalse) + ThrowWandException(input); + + MagickSetLastIterator(wand); + status = MagickAddImage(wand, input); + if (status == MagickFalse) + ThrowWandException(wand); + input=DestroyMagickWand(input); + + /* append all images together to create the output wand */ + MagickResetIterator(wand); /* append all images */ + output = MagickAppendImages(wand,MagickFalse); + wand = DestroyMagickWand(wand); /* finished - could swap here */ + + /* Final output */ + status = MagickWriteImage(output,"show:"); + if (status == MagickFalse) + ThrowWandException(output); + + output = DestroyMagickWand(output); + + MagickWandTerminus(); +} + diff --git a/MagickWand/tests/add_norm.c b/MagickWand/tests/add_norm.c new file mode 100644 index 000000000..9f122715e --- /dev/null +++ b/MagickWand/tests/add_norm.c @@ -0,0 +1,69 @@ +#include +#include + +/* Simplify the exception handling + * technically we should abort the program if + * severity >= ErrorException + */ +void ThrowWandException(MagickWand *wand) +{ char + *description; + + ExceptionType + severity; + + description=MagickGetException(wand,&severity); + (void) fprintf(stderr,"%s %s %lu %s\n",GetMagickModule(),description); + description=(char *) MagickRelinquishMemory(description); +} + +/* useful function especially after appending two wands together */ +#define SwapWands(a,b) { MagickWand *tmp=a; a=b; b=tmp; } + +int main(int argc, char *argv[]) +{ + MagickWand + *wand, + *output; + + MagickBooleanType + status; + + printf("Just read images one at a time, no settings\n"); + printf("Result shoud be: 0123\n"); + + MagickWandGenesis(); + + wand = NewMagickWand(); + + status = MagickReadImage(wand, "font_0.gif" ); + if (status == MagickFalse) + ThrowWandException(wand); + + status = MagickReadImage(wand, "font_1.gif" ); + if (status == MagickFalse) + ThrowWandException(wand); + + status = MagickReadImage(wand, "font_2.gif" ); + if (status == MagickFalse) + ThrowWandException(wand); + + status = MagickReadImage(wand, "font_3.gif" ); + if (status == MagickFalse) + ThrowWandException(wand); + + /* append all images together to create the output wand */ + MagickResetIterator(wand); /* append all images */ + output = MagickAppendImages(wand,MagickFalse); + wand = DestroyMagickWand(wand); /* finished - could swap here */ + + /* Final output */ + status = MagickWriteImage(output,"show:"); + if (status == MagickFalse) + ThrowWandException(output); + + output = DestroyMagickWand(output); + + MagickWandTerminus(); +} + diff --git a/MagickWand/tests/add_norm_lists.c b/MagickWand/tests/add_norm_lists.c new file mode 100644 index 000000000..5512f1a62 --- /dev/null +++ b/MagickWand/tests/add_norm_lists.c @@ -0,0 +1,89 @@ +#include +#include + +/* Simplify the exception handling + * technically we should abort the program if + * severity >= ErrorException + */ +void ThrowWandException(MagickWand *wand) +{ char + *description; + + ExceptionType + severity; + + description=MagickGetException(wand,&severity); + (void) fprintf(stderr,"%s %s %lu %s\n",GetMagickModule(),description); + description=(char *) MagickRelinquishMemory(description); +} + +/* useful function especially after appending two wands together */ +#define SwapWands(a,b) { MagickWand *tmp=a; a=b; b=tmp; } + +int main(int argc, char *argv[]) +{ + MagickWand + *wand, + *input, + *output; + + MagickBooleanType + status; + + printf("Just read images in three groups, no settings used\n"); + printf("Result shoud be: 012 345 678\n"); + + MagickWandGenesis(); + + wand = NewMagickWand(); + input = NewMagickWand(); + + status = MagickReadImage(input, "font_0.gif" ) + && MagickReadImage(input, "font_1.gif" ) + && MagickReadImage(input, "font_2.gif" ); + if (status == MagickFalse) + ThrowWandException(input); + + status = MagickAddImage(wand, input); + if (status == MagickFalse) + ThrowWandException(wand); + + ClearMagickWand(input); + status = MagickReadImage(input, "font_3.gif" ) + && MagickReadImage(input, "font_4.gif" ) + && MagickReadImage(input, "font_5.gif" ); + if (status == MagickFalse) + ThrowWandException(input); + + status = MagickAddImage(wand, input); + if (status == MagickFalse) + ThrowWandException(wand); + ClearMagickWand(input); + + ClearMagickWand(input); + status = MagickReadImage(input, "font_6.gif" ) + && MagickReadImage(input, "font_7.gif" ) + && MagickReadImage(input, "font_8.gif" ); + if (status == MagickFalse) + ThrowWandException(input); + + status = MagickAddImage(wand, input); + if (status == MagickFalse) + ThrowWandException(wand); + input=DestroyMagickWand(input); + + /* append all images together to create the output wand */ + MagickResetIterator(wand); /* append all images */ + output = MagickAppendImages(wand,MagickFalse); + wand = DestroyMagickWand(wand); /* finished - could swap here */ + + /* Final output */ + status = MagickWriteImage(output,"show:"); + if (status == MagickFalse) + ThrowWandException(output); + + output = DestroyMagickWand(output); + + MagickWandTerminus(); +} + diff --git a/MagickWand/tests/font_0.gif b/MagickWand/tests/font_0.gif new file mode 100644 index 0000000000000000000000000000000000000000..e33bd5f0ec5b8570335bb876a8413a0573a96b08 GIT binary patch literal 241 zcmZ?wbhEHbRA5kG_{7Y>z|g?J@Lz7ie;@#I;6U*w3nK#q3xnc+Za>$MU}whwS0g4f^3b+hNrWm+1gW@xc& ivB}bPb2aC!+q`9qiQ<}_JB4=bT_AGc;Gu(@4Auas^z|g?J@Lz7ie;@#I;6U*w3nK#q3xf_w1f-UMx!Yscoqqz|g?J@Lz7ie;@#I;6U*w3nK#q3xf_w1f-UMd4k8TJO2z$ zoov`^k-l>Get&_QB^FG5nv}I=nG;WIHQOyzT-MgxI<+QC^Z^ShHX6irP`lZ2^>&VORHhT6c8iDS51}&}J uwrZ|^e(_wk?GsG()xF)OPP3fZ=reoKVt3~SbEkFJtgvrbw_b#k!5RR!VMn?E literal 0 HcmV?d00001 diff --git a/MagickWand/tests/font_3.gif b/MagickWand/tests/font_3.gif new file mode 100644 index 0000000000000000000000000000000000000000..8d6bd7395bef68dbc1bd53423790dec8f414cfc0 GIT binary patch literal 204 zcmZ?wbhEHbRA5kG_{7Y>z|g?J@Lz7ie;@#I;6U*w3nK#q3xf_w1f-UMd7{UzJO2z$ z?QGa<@miwk--4$lDw1hx7pCM$vK@M`)+xJuML@Ur^8W`E_$Ei)joN+T@eQj$g_Y-v zXHM~oyUKgz^T)!q%FDuciX3jc75MgtbMm%>JI>WU?09~E`;&cs{?!JxlJ#yCb)xEG xc1=|coeU~%E<9--le(r%Rn2vlosvD(Nwu|TX`xEuEcdcii(A%j*ucqP4FEtlQ^x=R literal 0 HcmV?d00001 diff --git a/MagickWand/tests/font_4.gif b/MagickWand/tests/font_4.gif new file mode 100644 index 0000000000000000000000000000000000000000..0c052048c1f492f8849acba8cacdc6fc67432d41 GIT binary patch literal 221 zcmZ?wbhEHbRA5kG_{7Y>z|g?J@Lz7ie;@#I;6U*w3nK#q3xf_w1f-UMd6CDiJO2z$ zoorzJ@@R$Wo9n_Ej+vH^Lzii2@+7a`XPA7BY4@Elg(u5ny-GLpR=Ymjm>g3zWr2Xn zuD~^O9JTqc90}vpezkpybsl5ls*Q6#9rVatH(~Fu*!Qn2|DOA9cA~7dHn6_IzP+Qp z&_A}RG_^&kFFdD6M8j@^&-59M)8z|g?J@Lz7ie;@#I;6U*w3nK#q3xf_w1f-UMd6CDiJO2z$ zoov`^@p{GX<9;7%9V6pLG@AVM?S1Q;e!<%3f*9v;C7ak)o$_g5 zYSfy}kY&o5vsOp&vOeeUrunW9Gz|g?J@Lz7ie;@#I;6U*w3nK#q3xf_w1f-UMd9lZ?JO2z$ zoov`^@p{GX<9;7%9V6pLG@AVM?R~ZGoaHMen>Cf5Rn)LpGjct- zInin=L(W$(o;@Mj4jr>t`{sG3c7GA&FHGp(m{F!(b?ax*w`+WlCG!iUt)iS-9U975 zvZKr6nj2f&nyj

N+OI8B~{gHx<|}(wnHW(8sJ(Cvf2sH~aO;6E<$$rWUhum#Wb2 Om0<@C9unYWum%9H?NvGe literal 0 HcmV?d00001 diff --git a/MagickWand/tests/font_7.gif b/MagickWand/tests/font_7.gif new file mode 100644 index 0000000000000000000000000000000000000000..9bf72973084af61a1eb318c2f8a7edeb15680e31 GIT binary patch literal 187 zcmZ?wbhEHbRA5kG_{7Y>z|g?J@Lz7ie;@#I;6U*w3nK#q3xf_w1f-UMxxr)Coqq}L-p_bJad z3G@1{y!zO5@>QqZEVtNY!t#1=-kabZHveSm{a;M)Pj370qc-^bS;oq;`o_9&#uoeR f_S#M@waTh;;|ZyjMg3Der|_7}o;RP5lffDQh#*am literal 0 HcmV?d00001 diff --git a/MagickWand/tests/font_8.gif b/MagickWand/tests/font_8.gif new file mode 100644 index 0000000000000000000000000000000000000000..7c5880b4b18378da8c168b254d4664d82974d325 GIT binary patch literal 226 zcmZ?wbhEHbRA5kG_{7Y>z|g?J@Lz7ie;@#I;6U*w3nK#q3xf_w1f-UMdAY}~JO2z$ zoov`^k-l>Ge*X`>4hd0x9#xG79cORO+)}f(>C_G5bJI87^$(Wj3|*r5>_=kN9N86a zyCSzt2-bd^dDe96{@}O2LPhe|eH7h&<=F&_#u~kFuKN;OSDtg*`8Kv9GR>~GyeYS( zrkSO>Lm{ufu4@uQyIEpuPoI&le&wvn_WU_n#WswKtCrPhsTme7sVdpDa>K?gJGYo9 UuHKg=w12z|g?J@Lz7ie;@#I;6U*w3nK#q3xf_w1f-UMd5*`fJO2z$ zoov`^k-l>Ge*X`>4hd0x9#xG79cORO+)}f(>C_G5bJI87^$(Wj3|*r5>_=i%--)wL z*X9IS?~Vx#lulb5l(*V@S?2sO$92z?)?W+VvYsHCL??+|tyybJuPG HP6lfLyfjwk literal 0 HcmV?d00001 diff --git a/MagickWand/tests/loop_over_lists.c b/MagickWand/tests/loop_over_lists.c new file mode 100644 index 000000000..b5f985817 --- /dev/null +++ b/MagickWand/tests/loop_over_lists.c @@ -0,0 +1,128 @@ +#include +#include + +/* set this to true to test loops methods with a empty wand */ +#define TEST_EMPTY_WAND 0 + +/* Simplify the exception handling + * technically we should abort the program if + * severity >= ErrorException + */ +void ThrowWandException(MagickWand *wand) +{ char + *description; + + ExceptionType + severity; + + description=MagickGetException(wand,&severity); + (void) fprintf(stderr,"%s %s %lu %s\n",GetMagickModule(),description); + description=(char *) MagickRelinquishMemory(description); +} + +/* useful function especially after appending two wands together */ +#define SwapWands(a,b) { MagickWand *tmp=a; a=b; b=tmp; } + +int main(int argc, char *argv[]) +{ + MagickWand + *wand, + *output; + + MagickBooleanType + status; + + MagickWandGenesis(); + + printf("Read in a list of 6 images...\n"); + + wand = NewMagickWand(); +#if !TEST_EMPTY_WAND + status = MagickReadImage(wand, "font_0.gif" ) + && MagickReadImage(wand, "font_1.gif" ) + && MagickReadImage(wand, "font_2.gif" ) + && MagickReadImage(wand, "font_3.gif" ) + && MagickReadImage(wand, "font_4.gif" ) + && MagickReadImage(wand, "font_5.gif" ); + if (status == MagickFalse) + ThrowWandException(wand); +#endif + + printf("I actually read in %u images\n", + (unsigned) MagickGetNumberImages(wand) ); + printf("\n"); + + printf("After reading current image is #%d \"%s\"\n", + (unsigned) MagickGetIteratorIndex(wand), + MagickGetImageFilename(wand) ); + printf("\n"); + + // Note that using MagickGetIteratorIndex() is slower than just + // keeping track of the current image index yourself! But not a great cost. + + printf("Standard 'Reset while Next' loop through images\n"); + // keeping track of it to start with! + MagickResetIterator(wand); + while (MagickNextImage(wand) != MagickFalse) + printf("image #%u \"%s\"\n", + (unsigned) MagickGetIteratorIndex(wand), + MagickGetImageFilename(wand) ); + printf("\n"); + + printf("At this point, any image 'added' to wand will be appended!\n"); + printf("This special condition can be set by using either\n"); + printf("just MagickSetLastIterator(w)\n"); + printf("or MagickSetIteratorIndex(w,-1)\n"); + printf("\n"); + + printf("Now that we are at the end, lets loop backward using 'Previous'\n"); + while (MagickPreviousImage(wand) != MagickFalse) + printf("image #%u \"%s\"\n", + (unsigned) MagickGetIteratorIndex(wand), + MagickGetImageFilename(wand) ); + printf("\n"); + + + printf("Note at this point, any image 'added' to wand will be prepended!\n"); + printf("This special condition can be set by using either\n"); + printf("just MagickSetFirstIterator(w)\n"); + printf("Or MagickResetIterator(w); MagickPreviousImage(w);\n"); + printf("The latter method being the cause of the current condition\n"); + printf("\n"); + + + printf("Directly loop though images backward using 'Last, while Previous'\n"); + MagickSetLastIterator(wand); + while ( MagickPreviousImage(wand) != MagickFalse ) + printf("image #%u \"%s\"\n", + (unsigned) MagickGetIteratorIndex(wand), + MagickGetImageFilename(wand) ); + printf("\n"); + + + printf("Loop through images using Indexes, in a weird flip-flop way!\n"); + printf("Note that indexing using a negative number, indexes from end \n"); + { ssize_t i; + ssize_t n = (ssize_t) MagickGetNumberImages(wand); + + for ( i=0; i!=n; i= (i>=0) ? -(i+1):-i ) { + (void) MagickSetIteratorIndex(wand,i); + /* Note that a return of MagickFalse by the above is not actually an + * error (no exception will be generated). It just means that the + * index value used (positive or negative) is too large for the + * size of the current image list (EG: range error: -n <= i < n ) + * When it does happen, no change is made to the current image + */ + printf("index %2d -> #%u \"%s\"\n", (int) i, + (unsigned) MagickGetIteratorIndex(wand), + MagickGetImageFilename(wand) ); + } + } + printf("\n"); + + + wand=DestroyMagickWand(wand); + + MagickWandTerminus(); +} + diff --git a/MagickWand/tests/script-token-test.c b/MagickWand/tests/script-token-test.c index e1c3249f7..119a10229 100644 --- a/MagickWand/tests/script-token-test.c +++ b/MagickWand/tests/script-token-test.c @@ -71,6 +71,7 @@ #define LocaleCompare(p,q) strcasecmp(p,q) #define LocaleNCompare(p,q,l) strncasecmp(p,q,l) #define WandSignature 0xabacadabUL +#define fopen_utf8(p,q) fopen(p,q) #define WandExport /* Include the actual code for ScriptToken functions */ -- 2.40.0