]> gitweb.factorcode.org Git - factor.git/blob - basis/pack/pack-tests.factor
factor: rename [ ] [ ] unit-test -> { } [ ] unit-test using a refactoring tool!
[factor.git] / basis / pack / pack-tests.factor
1 USING: io io.streams.string kernel namespaces make
2 pack strings tools.test pack.private ;
3 IN: pack.tests
4
5 { B{ 1 0 2 0 0 3 0 0 0 4 0 0 0 0 0 0 0 5 } } [
6     { 1 2 3 4 5 }
7     "cstiq" pack-be
8 ] unit-test
9
10 { { 1 2 3 4 5 } } [
11     { 1 2 3 4 5 }
12     "cstiq" [ pack-be ] keep unpack-be
13 ] unit-test
14
15 { B{ 1 2 0 3 0 0 4 0 0 0 5 0 0 0 0 0 0 0 } } [
16     { 1 2 3 4 5 } "cstiq" pack-le
17 ] unit-test
18
19 { { 1 2 3 4 5 } } [
20     { 1 2 3 4 5 }
21     "cstiq" [ pack-le ] keep unpack-le
22 ] unit-test
23
24 { { -1 -2 -3 -4 -5 } } [
25     { -1 -2 -3 -4 -5 }
26     "cstiq" [ pack-le ] keep unpack-le
27 ] unit-test
28
29 { { -1 -2 -3 -4 -5 3.14 } } [
30     { -1 -2 -3 -4 -5 3.14 }
31     "cstiqd" [ pack-be ] keep unpack-be
32 ] unit-test
33
34 { { -1 -2 -3 -4 -5 } } [
35     { -1 -2 -3 -4 -5 }
36     "cstiq" [ pack-native ] keep unpack-native
37 ] unit-test
38
39 { B{ 1 2 3 4 5 0 0 0 } } [ { 1 2 3 4 5 } "4ci" pack-le ] unit-test
40 { { 1 2 3 4 5 } } [ B{ 1 2 3 4 5 0 0 0 } "4ci" unpack-le ] unit-test
41
42 { 9 } [ "iic" packed-length ] unit-test
43 [ "iii" read-packed-le ] must-infer
44 [ "iii" read-packed-be ] must-infer
45 [ "iii" read-packed-native ] must-infer
46 [ "iii" unpack-le ] must-infer
47 [ "iii" unpack-be ] must-infer
48 [ "iii" unpack-native ] must-infer
49 [ "iii" pack ] must-infer
50 [ "iii" unpack ] must-infer
51
52 : test-pack ( str -- ba )
53     "iii" pack ;
54
55 [ test-pack ] must-infer
56
57 { "c" } [ "1c" expand-pack-format ] unit-test
58 { "cccc" } [ "4c" expand-pack-format ] unit-test
59 { "cccccccccccc" } [ "12c" expand-pack-format ] unit-test
60 { "iccqqq" } [ "1i2c3q" expand-pack-format ] unit-test