]> gitweb.factorcode.org Git - factor.git/blob - extra/bson/bson-tests.factor
Fixes #2966
[factor.git] / extra / bson / bson-tests.factor
1 USING: bson.reader bson.writer bson.constants byte-arrays io.encodings.binary
2 io.streams.byte-array tools.test literals calendar kernel math ;
3
4 IN: bson.tests
5
6 : turnaround ( value -- value )
7     assoc>bv binary [ H{ } clone stream>assoc ] with-byte-reader ;
8
9 { H{ { "a" "a string" } } } [ H{ { "a" "a string" } } turnaround ] unit-test
10
11 { H{ { "a" "a string" } { "b" H{ { "a" "アップルからの最新のニュースや情報を読む" } } } } }
12 [ H{ { "a" "a string" } { "b" H{ { "a" "アップルからの最新のニュースや情報を読む" } } } } turnaround ] unit-test
13
14 { H{ { "a list" { 1 2.234 "hello world" } } } }
15 [ H{ { "a list" { 1 2.234 "hello world" } } } turnaround ] unit-test
16
17 { H{ { "a quotation" [ 1 2 + ] } } }
18 [ H{ { "a quotation" [ 1 2 + ] } } turnaround ] unit-test
19
20 { H{ { "ref" T{ dbref f "a" "b" "c" } } } }
21 [ H{ { "ref" T{ dbref f "a" "b" "c" } } } turnaround ] unit-test
22
23 { H{ { "a date" T{ timestamp { year 2009 }
24                    { month 7 }
25                    { day 11 }
26                    { hour 9 }
27                    { minute 8 }
28                    { second 40+77/1000 } } } }
29 }
30 [ H{ { "a date" T{ timestamp { year 2009 }
31                    { month 7 }
32                    { day 11 }
33                    { hour 11 }
34                    { minute 8 }
35                    { second 40+15437/200000 }
36                    { gmt-offset T{ duration { hour 2 } } } } } } turnaround
37 ] unit-test
38
39 { H{ { "nested" H{ { "a" "a string" } { "b" H{ { "a" "a string" } } } } }
40      { "ref" T{ dbref f "a" "b" "c" } }
41      { "array" H{ { "a list" { 1 2.234 "hello world" } } } }
42      { "quot" [ 1 2 + ] } }
43 }
44 [ H{ { "nested" H{ { "a" "a string" } { "b" H{ { "a" "a string" } } } } }
45      { "ref" T{ dbref f "a" "b" "c" } }
46      { "array" H{ { "a list" { 1 2.234 "hello world" } } } }
47      { "quot" [ 1 2 + ] } } turnaround ] unit-test