]> gitweb.factorcode.org Git - factor.git/blob - basis/specialized-arrays/specialized-arrays-tests.factor
Merge branch 'master' into redis
[factor.git] / basis / specialized-arrays / specialized-arrays-tests.factor
1 IN: specialized-arrays.tests
2 USING: tools.test specialized-arrays sequences
3 specialized-arrays.int specialized-arrays.bool
4 specialized-arrays.ushort alien.c-types accessors kernel
5 specialized-arrays.direct.int specialized-arrays.char
6 specialized-arrays.uint arrays combinators ;
7
8 [ t ] [ { 1 2 3 } >int-array int-array? ] unit-test
9
10 [ t ] [ int-array{ 1 2 3 } int-array? ] unit-test
11
12 [ 2 ] [ int-array{ 1 2 3 } second ] unit-test
13
14 [ t ] [
15     { t f t } >bool-array underlying>>
16     { 1 0 1 } "bool" heap-size {
17         { 1 [ >char-array ] }
18         { 4 [ >uint-array ] }
19     } case underlying>> =
20 ] unit-test
21
22 [ ushort-array{ 1234 } ] [
23     little-endian? B{ 210 4 } B{ 4 210 } ? byte-array>ushort-array
24 ] unit-test
25
26 [ B{ 210 4 1 } byte-array>ushort-array ] must-fail
27
28 [ { 3 1 3 3 7 } ] [
29     int-array{ 3 1 3 3 7 } malloc-byte-array 5 <direct-int-array> >array
30 ] unit-test