]> gitweb.factorcode.org Git - factor.git/commitdiff
images.gif: added more tests
authorKeith Lazuka <klazuka@gmail.com>
Fri, 25 Sep 2009 13:34:29 +0000 (09:34 -0400)
committerKeith Lazuka <klazuka@gmail.com>
Fri, 25 Sep 2009 13:54:49 +0000 (09:54 -0400)
extra/images/gif/gif-tests.factor
extra/images/testing/alpha.gif [new file with mode: 0644]
extra/images/testing/astronaut_animation.gif [new file with mode: 0644]
extra/images/testing/check-256-colors.gif [deleted file]
extra/images/testing/checkmark.gif [new file with mode: 0644]
extra/images/testing/circle.gif [new file with mode: 0644]
extra/images/testing/symbol-word.gif [deleted file]

index 609f98c693fbd2d32b996aa4962adb6670803df9..b62565ffbc519ef415a5956ebcf2b39a2ff7ad99 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors bitstreams compression.lzw-gif images.gif io
 io.encodings.binary io.files kernel math math.bitwise
-math.parser namespaces prettyprint sequences tools.test ;
+math.parser namespaces prettyprint sequences tools.test images.viewer ;
 QUALIFIED-WITH: bitstreams bs
 IN: images.gif.tests
 
@@ -10,10 +10,10 @@ IN: images.gif.tests
     binary [ input-stream get load-gif ] with-file-reader ;
 
 : gif-example1 ( -- loading-gif )
-    "resource:extra/images/testing/symbol-word.gif" path>gif ;
+    "resource:extra/images/testing/circle.gif" path>gif ;
 
 : gif-example2 ( -- loading-gif )
-    "resource:extra/images/testing/check-256-colors.gif" path>gif ;
+    "resource:extra/images/testing/checkmark.gif" path>gif ;
 
 : gif-example3 ( -- loading-gif )
     "resource:extra/images/testing/monochrome.gif" path>gif ;
@@ -21,8 +21,21 @@ IN: images.gif.tests
 : gif-example4 ( -- loading-gif )
     "resource:extra/images/testing/noise.gif" path>gif ;
 
+: gif-example5 ( -- loading-gif )
+    "resource:extra/images/testing/alpha.gif" path>gif ;
+
+: gif-example6 ( -- loading-gif )
+    "resource:extra/images/testing/astronaut_animation.gif" path>gif ;
+
+: gif-all. ( -- )
+    {
+        gif-example1 gif-example2 gif-example3 gif-example4 gif-example5
+        gif-example6
+    }
+    [ execute( -- gif ) loading-gif>image image. ] each ;
+
 : declared-num-colors ( gif -- n ) flags>> 3 bits 1 + 2^ ;
-: actual-num-colors ( gif -- n ) global-color-table>> length 3 /i ;
+: actual-num-colors ( gif -- n ) global-color-table>> length ;
 
 [ 16 ] [ gif-example1 actual-num-colors ] unit-test
 [ 16 ] [ gif-example1 declared-num-colors ] unit-test
@@ -49,4 +62,34 @@ IN: images.gif.tests
     }
 ] [ gif-example3 >index-stream ] unit-test
 
+[
+    B{
+        255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
+        0 0 0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 0 0 255
+        0 0 0 255 0 0 0 255 255 255 255 255 255 255 255 255 0 0 0 255 0 0 0 255
+        0 0 0 255 0 0 0 255 0 0 0 255 0 0 0 255 0 0 0 255 0 0 0 255
+        0 0 0 255 255 255 255 255 0 0 0 255 0 0 0 255 255 255 255 255 0 0 0 255
+        0 0 0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 0 0 255
+    }
+] [ gif-example3 loading-gif>image bitmap>> ] unit-test
+
+[
+    BV{
+        0 1
+        1 0
+    }
+] [ gif-example5 >index-stream ] unit-test
+
+[
+    B{
+        255 000 000 255     000 000 000 000
+        000 000 000 000     255 000 000 255
+    }
+] [ gif-example5 loading-gif>image bitmap>> ] unit-test
+
+[ 100 ] [ gif-example1 >index-stream length ] unit-test
+[ 870 ] [ gif-example2 >index-stream length ] unit-test
+[ 16384 ] [ gif-example4 >index-stream length ] unit-test
 
+! example6 is a GIF animation and the first frame contains 1768 pixels
+[ 1768 ] [ gif-example6 >index-stream length ] unit-test
diff --git a/extra/images/testing/alpha.gif b/extra/images/testing/alpha.gif
new file mode 100644 (file)
index 0000000..c4c38bd
Binary files /dev/null and b/extra/images/testing/alpha.gif differ
diff --git a/extra/images/testing/astronaut_animation.gif b/extra/images/testing/astronaut_animation.gif
new file mode 100644 (file)
index 0000000..8c76848
Binary files /dev/null and b/extra/images/testing/astronaut_animation.gif differ
diff --git a/extra/images/testing/check-256-colors.gif b/extra/images/testing/check-256-colors.gif
deleted file mode 100644 (file)
index df83efa..0000000
Binary files a/extra/images/testing/check-256-colors.gif and /dev/null differ
diff --git a/extra/images/testing/checkmark.gif b/extra/images/testing/checkmark.gif
new file mode 100644 (file)
index 0000000..df83efa
Binary files /dev/null and b/extra/images/testing/checkmark.gif differ
diff --git a/extra/images/testing/circle.gif b/extra/images/testing/circle.gif
new file mode 100644 (file)
index 0000000..101a48a
Binary files /dev/null and b/extra/images/testing/circle.gif differ
diff --git a/extra/images/testing/symbol-word.gif b/extra/images/testing/symbol-word.gif
deleted file mode 100644 (file)
index 101a48a..0000000
Binary files a/extra/images/testing/symbol-word.gif and /dev/null differ