From 3cbf48cae7305054163fc3174a279d43820223fb Mon Sep 17 00:00:00 2001 From: Keith Lazuka Date: Wed, 23 Sep 2009 12:06:49 -0400 Subject: [PATCH] images.gif: added unit tests --- extra/images/gif/gif-tests.factor | 29 ++++++++++++++++++ extra/images/testing/check-256-colors.gif | Bin 0 -> 1227 bytes extra/images/testing/monochrome.gif | Bin 0 -> 45 bytes .../images/testing/symbol-word-16-colors.gif | Bin 0 -> 142 bytes 4 files changed, 29 insertions(+) create mode 100644 extra/images/gif/gif-tests.factor create mode 100644 extra/images/testing/check-256-colors.gif create mode 100644 extra/images/testing/monochrome.gif create mode 100644 extra/images/testing/symbol-word-16-colors.gif 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 0000000000000000000000000000000000000000..df83efaf55df781953fb2cce13186bb95c2ddfd4 GIT binary patch literal 1227 zcmZ?wbhEHblw*)(_|Cu}nIFQVI6Lx#qujjhjGJ1n<%pY9&q7!cbS9^V?} zxXsabi*IsQd`f3RR&Q$2+`O`>#TC;^>ZVr~EKPSl=j?sf+v$Rn_eJlJDae(9mo!rO%n$7?38>YKKD(uA!&bGOW1vTeb#-AmT(UA=kl`Yro5 z^c-q#xZlwFpta{w&$K7gWg*~vUT6_UAs?h+k0x)raSAl-rltP;jZf z^Y>3(xO(>To%7djUcPzv+L6bHj=ns6`r+}jPfne9f8xTUv)3P9x%u?k{fBoSJ-z?n z)x9Ur9zA{e_~o1DZ{EFn`{DJ6Pw&2b{rvsM_a8sL|NHmv%$YL`qk#4yp!k!8k%6Iu zK?h_NC{HkO{9_R0l=0ZGz_F>F=jO?v7Yh!zx3k>c+1PU7a5wA!E1Zj!I$e7tel9RH zPHCL#tf2o*($bZM$y6g)%4UlYuc(X^-gU-U8 zj!p&JCMYT&%@34pR9YGK^V8#&HU`0U3Su44J-hhi9WwrIaOhrW6|&^P3kC+J$zPcT zFR}2j@qB3HR2L~_P7nDrL5#_LgXwKKHxmU0c8<0HC+Reghfc938Eis|kro9DIW?X< zI4W*8r@T?Va-*RmgY<$E&U~^g7Z{`yRMptI*>W5Xaq??j4CwDT;;6trK{9|j&Vx&Y notrC#fq~7&%~C*GjNw3oP;2JQ8&W(C>S|8DC$0rMFjxZs@K%pL literal 0 HcmV?d00001 diff --git a/extra/images/testing/monochrome.gif b/extra/images/testing/monochrome.gif new file mode 100644 index 0000000000000000000000000000000000000000..de74e65eb1d6f01b022983cc4e24a5f3e0315a1c GIT binary patch literal 45 ycmZ?wbhEHbWLWCLu-c7bqX)xQPli=q3_E=p4h1rt4q>KUp{#82A}sU)iLIVwzuaN^it s&~we=j>V)1j-WpW?k#nHBgr#;zFwn&h*8UmFP}St*57!e%*0>~03)k0K>z>% literal 0 HcmV?d00001