]> gitweb.factorcode.org Git - factor.git/blob - basis/io/ports/ports-tests.factor
specialized-arrays: performed some cleanup.
[factor.git] / basis / io / ports / ports-tests.factor
1 USING: alien.c-types alien.data destructors io io.directories
2 io.encodings.binary io.files io.files.temp kernel libc math
3 sequences 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 int malloc-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 int cast-array 100,000 iota sequence=
22     ] with-file-reader
23 ] unit-test
24
25 [ ] [ "test.txt" temp-file delete-file ] unit-test