1 USING: io io.streams.string kernel namespaces make
2 pack strings tools.test pack.private ;
5 { B{ 1 0 2 0 0 3 0 0 0 4 0 0 0 0 0 0 0 5 } } [
12 "cstiq" [ pack-be ] keep unpack-be
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
21 "cstiq" [ pack-le ] keep unpack-le
24 { { -1 -2 -3 -4 -5 } } [
26 "cstiq" [ pack-le ] keep unpack-le
29 { { -1 -2 -3 -4 -5 3.14 } } [
30 { -1 -2 -3 -4 -5 3.14 }
31 "cstiqd" [ pack-be ] keep unpack-be
34 { { -1 -2 -3 -4 -5 } } [
36 "cstiq" [ pack-native ] keep unpack-native
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
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
52 : test-pack ( str -- ba )
55 [ test-pack ] must-infer
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