images.gif: added unit tests
parent
8b5871e9d8
commit
3cbf48cae7
|
@ -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
|
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
Binary file not shown.
After Width: | Height: | Size: 45 B |
Binary file not shown.
After Width: | Height: | Size: 142 B |
Loading…
Reference in New Issue