X-Git-Url: https://gitweb.factorcode.org/gitweb.cgi?p=factor.git;a=blobdiff_plain;f=core%2Fio%2Ffiles%2Ffiles-tests.factor;h=5db1822d9e5152942d7499654e3822c11a8fd974;hp=cf58dbfe05585a5823cf367c90af71840974c7a3;hb=17b095a5243c0ec94acb336d06cec2890159c08c;hpb=ebd2cce1bed8d3b23e9fcfd05ba6dab650302498 diff --git a/core/io/files/files-tests.factor b/core/io/files/files-tests.factor index cf58dbfe05..5db1822d9e 100644 --- a/core/io/files/files-tests.factor +++ b/core/io/files/files-tests.factor @@ -1,8 +1,9 @@ -USING: arrays debugger.threads destructors io io.directories -io.encodings.ascii io.encodings.binary io.encodings.string -io.encodings.8-bit.latin1 io.files io.files.private -io.files.temp io.files.unique kernel make math sequences system -threads tools.test generic.single specialized-arrays alien.c-types ; +USING: alien alien.c-types arrays classes.struct +debugger.threads destructors generic.single io io.directories +io.encodings.8-bit.latin1 io.encodings.ascii +io.encodings.binary io.encodings.string io.files +io.files.private io.files.temp io.files.unique kernel make math +sequences specialized-arrays system threads tools.test ; SPECIALIZED-ARRAY: int IN: io.files.tests @@ -80,6 +81,44 @@ IN: io.files.tests byte-array>int-array ] unit-test +[ ] [ + BV{ 0 1 2 } "test.txt" temp-file binary set-file-contents +] unit-test + +[ t ] [ + "test.txt" temp-file binary file-contents + B{ 0 1 2 } = +] unit-test + +STRUCT: pt { x uint } { y uint } ; +SPECIALIZED-ARRAY: pt + +CONSTANT: pt-array-1 + pt-array{ S{ pt f 1 1 } S{ pt f 2 2 } S{ pt f 3 3 } } + +[ ] [ + pt-array-1 + "test.txt" temp-file binary set-file-contents +] unit-test + +[ t ] [ + "test.txt" temp-file binary file-contents + pt-array-1 >c-ptr sequence= +] unit-test + +! Slices should support >c-ptr and byte-length + +[ ] [ + pt-array-1 rest-slice + "test.txt" temp-file binary set-file-contents +] unit-test + +[ t ] [ + "test.txt" temp-file binary file-contents + byte-array>pt-array + pt-array-1 rest-slice sequence= +] unit-test + ! Writing strings to binary streams should fail [ "test.txt" temp-file binary [