]> gitweb.factorcode.org Git - factor.git/blob - basis/io/mmap/mmap-tests.factor
Merge branch 'help' of git://github.com/klazuka/factor
[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 specialized-arrays.instances.uint tools.test ;
5 IN: io.mmap.tests
6
7 [ "mmap-test-file.txt" temp-file delete-file ] ignore-errors
8 [ ] [ "12345" "mmap-test-file.txt" temp-file ascii set-file-contents ] unit-test
9 [ ] [ "mmap-test-file.txt" temp-file [ char <mapped-array> CHAR: 2 0 pick set-nth drop ] with-mapped-file ] unit-test
10 [ 5 ] [ "mmap-test-file.txt" temp-file [ char <mapped-array> length ] with-mapped-file ] unit-test
11 [ 5 ] [ "mmap-test-file.txt" temp-file [ char <mapped-array> length ] with-mapped-file-reader ] unit-test
12 [ "22345" ] [ "mmap-test-file.txt" temp-file ascii file-contents ] unit-test
13
14 SPECIALIZED-ARRAY: uint
15
16 [ t ] [
17     "mmap-test-file.txt" temp-file uint [ sum ] with-mapped-array
18     integer?
19 ] unit-test
20
21 [ t ] [
22     "mmap-test-file.txt" temp-file uint [ sum ] with-mapped-array-reader
23     integer?
24 ] unit-test
25
26 [ "mmap-test-file.txt" temp-file delete-file ] ignore-errors
27
28
29 [ "mmap-empty-file.txt" temp-file delete-file ] ignore-errors
30 [ ] [ "mmap-empty-file.txt" temp-file touch-file ] unit-test
31
32 [
33     "mmap-empty-file.txt" temp-file [
34         drop
35     ] with-mapped-file
36 ] [ bad-mmap-size? ] must-fail-with
37
38 [ t ] [
39     [ "test.txt" <mapped-file> void* <c-direct-array> first-unsafe ]
40     { nth-unsafe } inlined?
41 ] unit-test