]> gitweb.factorcode.org Git - factor.git/blob - basis/io/ports/ports-tests.factor
Slices over specialized arrays can now be passed to C functions, written to binary...
[factor.git] / basis / io / ports / ports-tests.factor
1 USING: destructors io io.directories io.encodings.binary
2 io.files io.files.temp kernel libc math sequences
3 specialized-arrays.instances.alien.c-types.int tools.test ;
4 IN: io.ports.tests
5
6 ! Make sure that writing malloced storage to a file works, and
7 ! also make sure that writes larger than the buffer size work
8
9 [ ] [
10     "test.txt" temp-file binary [
11         [
12             100,000 iota
13             0
14             100,000 malloc-int-array &free [ copy ] keep write
15         ] with-destructors
16     ] with-file-writer
17 ] unit-test
18
19 [ t ] [
20     "test.txt" temp-file binary [
21         100,000 4 * read byte-array>int-array 100,000 iota sequence=
22     ] with-file-reader
23 ] unit-test
24
25 [ ] [ "test.txt" temp-file delete-file ] unit-test