: buffer-read-all ( buffer -- byte-array )
[ buffer@ ] [ buffer-length ] bi memory>byte-array ;
-[ B{ } 65536 ] [
+{ B{ } 65536 } [
65536 <buffer>
dup buffer-read-all
over buffer-capacity
rot dispose
] unit-test
-[ "hello world" "" ] [
+{ "hello world" "" } [
"hello world" string>buffer
dup buffer-read-all >string
0 pick buffer-reset
rot dispose
] unit-test
-[ "hello" ] [
+{ "hello" } [
"hello world" string>buffer
5 over buffer-read >string swap dispose
] unit-test
-[ 11 ] [
+{ 11 } [
"hello world" string>buffer
[ buffer-length ] keep dispose
] unit-test
-[ "hello world" ] [
+{ "hello world" } [
"hello" 1024 <buffer> [ buffer-set ] keep
" world" >byte-array binary-object pick buffer-write
dup buffer-read-all >string swap dispose
] unit-test
-[ CHAR: e ] [
+{ CHAR: e } [
"hello" string>buffer
1 over buffer-consume [ buffer-pop ] keep dispose
] unit-test
"hello world" string>buffer "b" set
-[ "hello world" ] [ 1000 "b" get buffer-read >string ] unit-test
+{ "hello world" } [ 1000 "b" get buffer-read >string ] unit-test
"b" get dispose
100 <buffer> "b" set
"b" get dispose
"hello world" string>buffer "b" set
-[ "hello" CHAR: \s ] [ " " "b" get buffer-read-until [ >string ] dip ] unit-test
+{ "hello" CHAR: \s } [ " " "b" get buffer-read-until [ >string ] dip ] unit-test
"b" get dispose
-[ 4 B{ 1 2 3 4 0 0 0 0 0 0 } ] [
+{ 4 B{ 1 2 3 4 0 0 0 0 0 0 } } [
10 <buffer>
[ B{ 1 2 3 4 } binary-object rot buffer-write ]
[ 10 <byte-array> [ 10 rot buffer-read-into ] keep ] bi
] unit-test
-[ 4 { 1 2 3 4 f f f f f f } ] [
+{ 4 { 1 2 3 4 f f f f f f } } [
10 <buffer>
[ B{ 1 2 3 4 } binary-object rot buffer-write ]
[ 10 f <array> [ 10 rot buffer-read-into ] keep ] bi