1 USING: alien.c-types alien.data arrays io io.encodings.ascii
2 io.encodings.binary io.encodings.utf8 io.streams.byte-array
3 kernel math specialized-arrays strings tools.test ;
6 { B{ } } [ B{ } binary [ contents ] with-byte-reader ] unit-test
9 { f } [ B{ } binary [ 0 read ] with-byte-reader ] unit-test
10 { f } [ B{ } binary [ 1 read ] with-byte-reader ] unit-test
11 { f } [ B{ } ascii [ 0 read ] with-byte-reader ] unit-test
12 { f } [ B{ } ascii [ readln ] with-byte-reader ] unit-test
13 { f f } [ B{ } ascii [ "a" read-until ] with-byte-reader ] unit-test
14 { f f } [ B{ } binary [ { 2 } read-until ] with-byte-reader ] unit-test
17 { B{ 1 2 3 } } [ binary [ B{ 1 2 3 } write ] with-byte-writer ] unit-test
18 { B{ 1 2 3 4 5 6 } } [ binary [ B{ 1 2 3 } write B{ 4 5 6 } write ] with-byte-writer ] unit-test
19 { B{ 1 2 3 } } [ { 1 2 3 } binary [ 3 read ] with-byte-reader ] unit-test
21 { B{ 0b11110101 0b10111111 0b10000000 0b10111111 0b11101111 0b10000000 0b10111111 0b11011111 0b10000000 CHAR: x } }
22 [ { 0b101111111000000111111 0b1111000000111111 0b11111000000 CHAR: x } >string utf8 [ write ] with-byte-writer ] unit-test
23 { { 0b1111111000000111111 } t } [ { 0b11110001 0b10111111 0b10000000 0b10111111 } utf8 <byte-reader> stream-contents dup >array swap string? ] unit-test
26 B{ 0 121 120 0 0 0 0 0 0 } binary
27 [ 1 read drop "\0" read-until ] with-byte-reader
32 B{ 1 2 3 } binary [ B{ 1 } read-until ] with-byte-reader
36 B{ } binary [ B{ 0 } read-until ] with-byte-reader
40 B{ 1 2 3 4 5 6 7 8 9 10 11 12 } binary
43 0 seek-absolute seek-input
45 2 seek-relative seek-input
47 -2 seek-end seek-input
55 B{ 1 2 3 4 5 6 7 8 9 10 11 12 } binary [ tell-input ] with-byte-reader
58 ! Overly aggressive compiler optimizations
60 binary [ 123 >bignum write1 ] with-byte-writer
63 ! Writing specialized arrays to byte writers
64 { int-array{ 1 2 3 } } [
65 binary [ int-array{ 1 2 3 } write ] with-byte-writer