1 USING: destructors io io.encodings.binary io.files io.directories
2 io.files.temp io.ports kernel sequences math
3 specialized-arrays.instances.alien.c-types.int tools.test
4 specialized-arrays alien.c-types classes.struct alien ;
7 ! Make sure that writing malloced storage to a file works, and
8 ! also make sure that writes larger than the buffer size work
11 "test.txt" temp-file binary [
14 100,000 malloc-int-array &dispose [ copy ] keep write
19 "test.txt" temp-file binary [
20 100,000 4 * read byte-array>int-array 100,000 iota sequence=
27 BV{ 0 1 2 } "test.txt" temp-file binary set-file-contents
31 "test.txt" temp-file binary file-contents
35 STRUCT: pt { x uint } { y uint } ;
39 pt-array{ S{ pt f 1 1 } S{ pt f 2 2 } S{ pt f 3 3 } }
43 "test.txt" temp-file binary set-file-contents
47 "test.txt" temp-file binary file-contents
48 pt-array-1 >c-ptr sequence=
53 "test.txt" temp-file binary set-file-contents
57 "test.txt" temp-file binary file-contents
58 pt-array-1 rest-slice >c-ptr sequence=
63 [ ] [ "test.txt" temp-file delete-file ] unit-test