]> gitweb.factorcode.org Git - factor.git/blob - core/io/streams/c/c-tests.factor
Revert "factor: rename [ ] [ ] unit-test -> { } [ ] unit-test using a refactoring...
[factor.git] / core / io / streams / c / c-tests.factor
1 USING: tools.test io.files io.files.temp io io.streams.c
2 io.encodings.ascii strings destructors kernel specialized-arrays
3 alien.c-types math alien.data ;
4 SPECIALIZED-ARRAY: int
5 IN: io.streams.c.tests
6
7 [ "hello world" ] [
8     "hello world" "test.txt" temp-file ascii set-file-contents
9
10     "test.txt" temp-file "rb" fopen <c-reader> stream-contents
11     >string
12 ] unit-test
13
14 ! Writing specialized arrays to binary streams
15 [ ] [
16     "test.txt" temp-file "wb" fopen <c-writer> [
17         int-array{ 1 2 3 } write
18     ] with-output-stream
19 ] unit-test
20
21 [ int-array{ 1 2 3 } ] [
22     "test.txt" temp-file "rb" fopen <c-reader> [
23         3 4 * read
24     ] with-input-stream
25     int cast-array
26 ] unit-test
27
28 ! Writing strings to binary streams should fail
29 [
30     "test.txt" temp-file "wb" fopen <c-writer> [
31         "OMGFAIL" write
32     ] with-output-stream
33 ] must-fail