diff --git a/extra/images/gif/gif-tests.factor b/extra/images/gif/gif-tests.factor new file mode 100644 index 0000000000..1c4a80107e --- /dev/null +++ b/extra/images/gif/gif-tests.factor @@ -0,0 +1,29 @@ +! Copyright (C) 2009 Keith Lazuka. +! See http://factorcode.org/license.txt for BSD license. +USING: accessors images.gif io io.encodings.binary io.files +math namespaces sequences tools.test math.bitwise ; +IN: images.gif.tests + +: path>gif ( path -- loading-gif ) + binary [ input-stream get load-gif ] with-file-reader ; + +: gif-example1 ( -- loading-gif ) + "resource:extra/images/testing/symbol-word-16-colors.gif" path>gif ; + +: gif-example2 ( -- loading-gif ) + "resource:extra/images/testing/check-256-colors.gif" path>gif ; + +: gif-example3 ( -- loading-gif ) + "resource:extra/images/testing/monochrome.gif" path>gif ; + +: declared-num-colors ( gif -- n ) flags>> 3 bits 1 + 2^ ; +: actual-num-colors ( gif -- n ) global-color-table>> length 3 /i ; + +[ 16 ] [ gif-example1 actual-num-colors ] unit-test +[ 16 ] [ gif-example1 declared-num-colors ] unit-test + +[ 256 ] [ gif-example2 actual-num-colors ] unit-test +[ 256 ] [ gif-example2 declared-num-colors ] unit-test + +[ 2 ] [ gif-example3 actual-num-colors ] unit-test +[ 2 ] [ gif-example3 declared-num-colors ] unit-test diff --git a/extra/images/testing/check-256-colors.gif b/extra/images/testing/check-256-colors.gif new file mode 100644 index 0000000000..df83efaf55 Binary files /dev/null and b/extra/images/testing/check-256-colors.gif differ diff --git a/extra/images/testing/monochrome.gif b/extra/images/testing/monochrome.gif new file mode 100644 index 0000000000..de74e65eb1 Binary files /dev/null and b/extra/images/testing/monochrome.gif differ diff --git a/extra/images/testing/symbol-word-16-colors.gif b/extra/images/testing/symbol-word-16-colors.gif new file mode 100644 index 0000000000..e097fdcc38 Binary files /dev/null and b/extra/images/testing/symbol-word-16-colors.gif differ