factor/extra/bson/bson-tests.factor

50 lines
1.9 KiB
Factor
Raw Normal View History

USING: bson.reader bson.writer bson.constants byte-arrays io.encodings.binary
2009-07-11 05:14:17 -04:00
io.streams.byte-array tools.test literals calendar kernel math ;
IN: bson.tests
: turnaround ( value -- value )
2010-06-05 06:04:16 -04:00
assoc>bv >byte-array binary [ H{ } clone stream>assoc ] with-byte-reader ;
2009-07-11 05:14:17 -04:00
[ H{ { "a" "a string" } } ] [ H{ { "a" "a string" } } turnaround ] unit-test
2010-06-18 06:51:35 -04:00
[ H{ { "a" "a string" } { "b" H{ { "a" "アップルからの最新のニュースや情報を読む" } } } } ]
[ H{ { "a" "a string" } { "b" H{ { "a" "アップルからの最新のニュースや情報を読む" } } } } turnaround ] unit-test
2009-07-11 05:14:17 -04:00
[ H{ { "a list" { 1 2.234 "hello world" } } } ]
[ H{ { "a list" { 1 2.234 "hello world" } } } turnaround ] unit-test
[ H{ { "a quotation" [ 1 2 + ] } } ]
[ H{ { "a quotation" [ 1 2 + ] } } turnaround ] unit-test
[ H{ { "ref" T{ dbref f "a" "b" "c" } } } ]
[ H{ { "ref" T{ dbref f "a" "b" "c" } } } turnaround ] unit-test
2009-07-11 05:14:17 -04:00
[ H{ { "a date" T{ timestamp { year 2009 }
{ month 7 }
{ day 11 }
2009-07-13 23:59:51 -04:00
{ hour 9 }
2009-07-11 05:14:17 -04:00
{ minute 8 }
2009-07-13 23:59:51 -04:00
{ second 40+77/1000 } } } }
2009-07-11 05:14:17 -04:00
]
[ H{ { "a date" T{ timestamp { year 2009 }
{ month 7 }
{ day 11 }
{ hour 11 }
{ minute 8 }
{ second 40+15437/200000 }
{ gmt-offset T{ duration { hour 2 } } } } } } turnaround
] unit-test
[ H{ { "nested" H{ { "a" "a string" } { "b" H{ { "a" "a string" } } } } }
{ "ref" T{ dbref f "a" "b" "c" } }
2009-07-11 05:14:17 -04:00
{ "array" H{ { "a list" { 1 2.234 "hello world" } } } }
{ "quot" [ 1 2 + ] } }
]
[ H{ { "nested" H{ { "a" "a string" } { "b" H{ { "a" "a string" } } } } }
{ "ref" T{ dbref f "a" "b" "c" } }
2009-07-11 05:14:17 -04:00
{ "array" H{ { "a list" { 1 2.234 "hello world" } } } }
{ "quot" [ 1 2 + ] } } turnaround ] unit-test