factor/basis/bitstreams/bitstreams-tests.factor

55 lines
1.2 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
2011-11-23 21:49:33 -05:00
[ 0b1111111111 ]
[
2011-11-23 21:49:33 -05:00
B{ 0x0f 0xff 0xff 0xff } <msb0-bit-reader>
2 >>byte-pos 6 >>bit-pos
10 swap peek
] unit-test
2009-02-12 18:44:43 -05:00
2011-11-23 21:49:33 -05:00
[ 0b111111111 ]
[
2011-11-23 21:49:33 -05:00
B{ 0x0f 0xff 0xff 0xff } <msb0-bit-reader>
2 >>byte-pos 6 >>bit-pos
9 swap peek
] unit-test
2011-11-23 21:49:33 -05:00
[ 0b11111111 ]
[
2011-11-23 21:49:33 -05:00
B{ 0x0f 0xff 0xff 0xff } <msb0-bit-reader>
2 >>byte-pos 6 >>bit-pos
8 swap peek
] unit-test
2011-11-23 21:49:33 -05:00
[ 0b1111111 ]
[
2011-11-23 21:49:33 -05:00
B{ 0x0f 0xff 0xff 0xff } <msb0-bit-reader>
2 >>byte-pos 6 >>bit-pos
7 swap peek
] unit-test
2011-11-23 21:49:33 -05:00
[ 0b111111 ]
[
2011-11-23 21:49:33 -05:00
B{ 0x0f 0xff 0xff 0xff } <msb0-bit-reader>
2 >>byte-pos 6 >>bit-pos
6 swap peek
] unit-test
2009-02-12 18:44:43 -05:00
2011-11-23 21:49:33 -05:00
[ 0b11111 ]
2009-02-12 18:44:43 -05:00
[
2011-11-23 21:49:33 -05:00
B{ 0x0f 0xff 0xff 0xff } <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