factor/basis/io/mmap/mmap-tests.factor

29 lines
1.1 KiB
Factor
Raw Normal View History

2009-10-09 00:06:40 -04:00
USING: alien.c-types alien.data compiler.tree.debugger
io.encodings.ascii io.files io.files.temp io.files.unique
io.mmap kernel locals math sequences sequences.private
specialized-arrays tools.test ;
2008-03-01 17:00:45 -05:00
IN: io.mmap.tests
2007-09-20 18:09:08 -04:00
2009-10-09 00:06:40 -04:00
SPECIALIZED-ARRAY: uint
[
"mmap-test-file" ".txt" [| path |
"12345" path ascii set-file-contents
{ } [ path [ char <mapped-array> CHAR: 2 0 pick set-nth drop ] with-mapped-file ] unit-test
{ 5 } [ path [ char <mapped-array> length ] with-mapped-file ] unit-test
{ 5 } [ path [ char <mapped-array> length ] with-mapped-file-reader ] unit-test
{ "22345" } [ path ascii file-contents ] unit-test
{ t } [ path uint [ sum ] with-mapped-array integer? ] unit-test
{ t } [ path uint [ sum ] with-mapped-array-reader integer? ] unit-test
] cleanup-unique-file
"mmap-empty-file" ".txt" [| path |
[ path [ drop ] with-mapped-file ] [ bad-mmap-size? ] must-fail-with
] cleanup-unique-file
] with-temp-directory
{ t } [
[ "test.txt" <mapped-file> void* <c-direct-array> first-unsafe ]
{ nth-unsafe } inlined?
] unit-test