factor/basis/bitstreams/bitstreams-tests.factor

55 lines
1.3 KiB
Factor
Raw Normal View History

2009-02-12 18:44:43 -05:00
! Copyright (C) 2009 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors bitstreams io io.streams.string kernel tools.test
2009-02-12 23:10:32 -05:00
grouping compression.lzw multiline byte-arrays io.encodings.binary
io.streams.byte-array ;
2009-02-12 18:44:43 -05:00
IN: bitstreams.tests
[ BIN: 1111111111 ]
[
B{ HEX: 0f HEX: ff HEX: ff HEX: ff } <msb0-bit-reader>
2 >>byte-pos 6 >>bit-pos
10 swap peek
] unit-test
2009-02-12 18:44:43 -05:00
[ BIN: 111111111 ]
[
B{ HEX: 0f HEX: ff HEX: ff HEX: ff } <msb0-bit-reader>
2 >>byte-pos 6 >>bit-pos
9 swap peek
] unit-test
[ BIN: 11111111 ]
[
B{ HEX: 0f HEX: ff HEX: ff HEX: ff } <msb0-bit-reader>
2 >>byte-pos 6 >>bit-pos
8 swap peek
] unit-test
[ BIN: 1111111 ]
[
B{ HEX: 0f HEX: ff HEX: ff HEX: ff } <msb0-bit-reader>
2 >>byte-pos 6 >>bit-pos
7 swap peek
] unit-test
[ BIN: 111111 ]
[
B{ HEX: 0f HEX: ff HEX: ff HEX: ff } <msb0-bit-reader>
2 >>byte-pos 6 >>bit-pos
6 swap peek
] unit-test
2009-02-12 18:44:43 -05:00
[ BIN: 11111 ]
2009-02-12 18:44:43 -05:00
[
B{ HEX: 0f HEX: ff HEX: ff HEX: ff } <msb0-bit-reader>
2 >>byte-pos 6 >>bit-pos
5 swap peek
2009-02-12 18:44:43 -05:00
] unit-test
[ B{ } <msb0-bit-reader> 5 swap peek ] must-fail
[ B{ } <msb0-bit-reader> 1 swap peek ] must-fail
[ B{ } <msb0-bit-reader> 8 swap peek ] must-fail
2009-02-12 18:44:43 -05:00
[ 0 ] [ B{ } <msb0-bit-reader> 0 swap peek ] unit-test