]> gitweb.factorcode.org Git - factor.git/blob - core/io/io-tests.factor
Merge branch 'master' of git://factorcode.org/git/factor
[factor.git] / core / io / io-tests.factor
1 USING: arrays io io.files kernel math parser strings system
2 tools.test words namespaces make io.encodings.8-bit
3 io.encodings.binary sequences ;
4 IN: io.tests
5
6 [ f ] [
7     "resource:core/io/test/no-trailing-eol.factor" run-file
8     "foo" "io.tests" lookup
9 ] unit-test
10
11 [
12     "This is a line.\rThis is another line.\r"
13 ] [
14     "resource:core/io/test/mac-os-eol.txt" latin1 <file-reader>
15     [ 500 read ] with-input-stream
16 ] unit-test
17
18 [
19     255
20 ] [
21     "resource:core/io/test/binary.txt" latin1 <file-reader>
22     [ read1 ] with-input-stream >fixnum
23 ] unit-test
24
25 ! Make sure we use correct to_c_string form when writing
26 [ ] [ "\0" write ] unit-test
27
28 [ ] [
29     "It seems Jobs has lost his grasp on reality again.\n"
30     "separator-test.txt" temp-file latin1 set-file-contents
31 ] unit-test
32
33 [
34     {
35         { "It seems " CHAR: J }
36         { "obs has lost h" CHAR: i }
37         { "s grasp on reality again.\n" f }
38     }
39 ] [
40     [
41         "separator-test.txt" temp-file
42         latin1 <file-reader> [
43             "J" read-until 2array ,
44             "i" read-until 2array ,
45             "X" read-until 2array ,
46         ] with-input-stream
47     ] { } make
48 ] unit-test
49
50 [ ] [
51     image binary [
52         10 [ 65536 read drop ] times
53     ] with-file-reader
54 ] unit-test
55
56 ! Test EOF behavior
57 [ 10 ] [
58     image binary [
59         0 read drop
60         10 read length
61     ] with-file-reader
62 ] unit-test