]> gitweb.factorcode.org Git - factor.git/blob - basis/io/mmap/mmap-tests.factor
967009243e24cd1d66f629f870f2f84cfe28cc9a
[factor.git] / basis / io / mmap / mmap-tests.factor
1 USING: alien.c-types alien.data compiler.tree.debugger
2 continuations io.directories io.encodings.ascii io.files
3 io.files.temp io.mmap kernel math sequences sequences.private
4 specialized-arrays tools.test ;
5 SPECIALIZED-ARRAY: uint
6 IN: io.mmap.tests
7
8 [ "mmap-test-file.txt" temp-file delete-file ] ignore-errors
9 [ ] [ "12345" "mmap-test-file.txt" temp-file ascii set-file-contents ] unit-test
10 [ ] [ "mmap-test-file.txt" temp-file [ char <mapped-array> CHAR: 2 0 pick set-nth drop ] with-mapped-file ] unit-test
11 [ 5 ] [ "mmap-test-file.txt" temp-file [ char <mapped-array> length ] with-mapped-file ] unit-test
12 [ 5 ] [ "mmap-test-file.txt" temp-file [ char <mapped-array> length ] with-mapped-file-reader ] unit-test
13 [ "22345" ] [ "mmap-test-file.txt" temp-file ascii file-contents ] unit-test
14
15 SPECIALIZED-ARRAY: uint
16
17 [ t ] [
18     "mmap-test-file.txt" temp-file uint [ sum ] with-mapped-array
19     integer?
20 ] unit-test
21
22 [ t ] [
23     "mmap-test-file.txt" temp-file uint [ sum ] with-mapped-array-reader
24     integer?
25 ] unit-test
26
27 [ "mmap-test-file.txt" temp-file delete-file ] ignore-errors
28
29
30 [ "mmap-empty-file.txt" temp-file delete-file ] ignore-errors
31 [ ] [ "mmap-empty-file.txt" temp-file touch-file ] unit-test
32
33 [
34     "mmap-empty-file.txt" temp-file [
35         drop
36     ] with-mapped-file
37 ] [ bad-mmap-size? ] must-fail-with
38
39 [ t ] [
40     [ "test.txt" <mapped-file> void* <c-direct-array> first-unsafe ]
41     { nth-unsafe } inlined?
42 ] unit-test