359b1a2015-02-10Martin Nilsson START_MARKER test_do( add_constant("E", Standards.BSON.encode); ) define(test_codec,[[ test_equal( E($1), $2 ) test_equal( Standards.BSON.decode($2), $1 ) ]]) test_codec( ([]), "\5\0\0\0\0" ) test_eval_error( E( ([ 1:2 ]) ) ) test_eval_error( E( ([ "\0":2 ]) ) ) test_eval_error( E( ([ "$":2 ]) ) ) test_eval_error( E( ([ ".":2 ]) ) ) test_codec( ([ "a":"b" ]), "\16\0\0\0\2a\0\2\0\0\0b\0\0" )
dd71402015-02-12Martin Nilsson test_codec( ([ "\xe5":"\xf6" ]), "\20\0\0\0\2\303\245\0\3\0\0\0\303\266\0\0" )
359b1a2015-02-10Martin Nilsson  test_codec( ([ "a":"\0$." ]), "\20\0\0\0\2a\0\4\0\0\0\0$.\0\0" ) test_codec( ([ "a":1.0 ]), "\20\0\0\0\1a\0\0\0\0\0\0\0\360?\0" ) test_codec( ([ "a":(["b":"c"]) ]), "\26\0\0\0\3a\0\16\0\0\0\2b\0\2\0\0\0c\0\0\0" ) test_codec( ([ "a":({}) ]), "\r\0\0\0\4a\0\5\0\0\0\0\0") dnl mapping order isn't stable, so arrays are not stable. dnl test_codec( ([ "a":({"x","y"}) ]), dnl "\37\0\0\0\4a\0\27\0\0\0\2""1\0\2\0\0\0y\0\2""0\0\2\0\0\0x\0\0\0" ) test_codec( ([ "a":0 ]), "\f\0\0\0\20a\0\0\0\0\0\0" ) test_codec( ([ "a":2147383666 ]), "\20\0\0\0\22a\0ry\376\177\0\0\0\0\0" )
4709ec2017-05-07Martin Nilsson test_codec( ([ "a":-1 ]), "\f\0\0\0\20a\0\377\377\377\377\0" )
3710b12017-05-07Martin Nilsson test_codec( ([ "a":-0x0102030405 ]), "\20\0\0\0\22a\0\373\373\374\375\376\377\377\377\0" ) test_codec( ([ "a":({0,1,2,"e"}) ]), "+\0\0\0\4a\0#\0\0\0\20""0\0\0\0\0\0\20" "1\0\1\0\0\0\20""2\0\2\0\0\0\2""3\0\2\0\0\0e\0\0\0" )
359b1a2015-02-10Martin Nilsson  test_codec( ([ "a": Val.null ]), "\b\0\0\0\na\0\0" ) test_codec( ([ "a": Val.true ]), "\t\0\0\0\ba\0\1\0" ) test_codec( ([ "a": Val.false ]),"\t\0\0\0\ba\0\0\0" )
c4db312018-01-05Martin Nilsson test_any([[ object t = Standards.BSON.Timestamp(1,(1<<32)-1); object t2 = Standards.BSON.decode(E( ([ "a": t ]) ))->a; return t2->get_timestamp(); ]], (((1<<32)-1)<<32 | 1) ) test_eval_error( E( (["a":Standards.BSON.Timestamp(1,1<<32)]) ) )
359b1a2015-02-10Martin Nilsson test_do( add_constant("E") ) END_MARKER