factor/library/test/io/buffer.factor

39 lines
767 B
Factor
Raw Normal View History

IN: temporary
USING: kernel io-internals test ;
[ "" 65536 ] [
65536 <buffer>
dup buffer-contents
over buffer-capacity
rot buffer-free
] unit-test
[ "hello world" "" ] [
2005-04-03 18:28:55 -04:00
"hello world" 65536 string>buffer
dup buffer-contents
0 pick buffer-reset
over buffer-contents
rot buffer-free
] unit-test
[ "hello" ] [
2005-04-03 18:28:55 -04:00
"hello world" 65536 string>buffer
5 over buffer-first-n swap buffer-free
] unit-test
[ 11 ] [
2005-04-03 18:28:55 -04:00
"hello world" 65536 string>buffer
[ buffer-length ] keep buffer-free
] unit-test
[ "hello world" ] [
2005-04-03 18:28:55 -04:00
"hello" 65536 string>buffer
2005-04-03 16:55:56 -04:00
" world" over >buffer
dup buffer-contents swap buffer-free
] unit-test
2005-04-03 16:55:56 -04:00
[ CHAR: e ] [
2005-04-03 18:28:55 -04:00
"hello" 65536 string>buffer
2005-04-03 16:55:56 -04:00
1 over buffer-consume buffer-peek
] unit-test