Add test for malloc-struct-array

db4
U-SLAVA-DFB8FF805\Slava 2008-12-03 09:54:59 -06:00
parent 85c79bb41e
commit 35df2fd480
1 changed files with 11 additions and 1 deletions

12
basis/struct-arrays/struct-arrays-tests.factor Normal file → Executable file
View File

@ -1,6 +1,6 @@
IN: struct-arrays.tests
USING: struct-arrays tools.test kernel math sequences
alien.syntax alien.c-types ;
alien.syntax alien.c-types destructors libc accessors ;
C-STRUCT: test-struct
{ "int" "x" }
@ -17,3 +17,13 @@ C-STRUCT: test-struct
3 4 make-point over set-second
0 [ [ test-struct-x ] [ test-struct-y ] bi / + ] reduce
] unit-test
[ 5/4 ] [
[
2 "test-struct" malloc-struct-array
dup underlying>> &free drop
1 2 make-point over set-first
3 4 make-point over set-second
0 [ [ test-struct-x ] [ test-struct-y ] bi / + ] reduce
] with-destructors
] unit-test