diff options
author | Eliot Horowitz <eliot@10gen.com> | 2009-06-05 09:54:35 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2009-06-05 09:54:35 -0400 |
commit | d2bbdd79413431c25eb482ba823717f00a70d365 (patch) | |
tree | 01f2e732884f1b61376ec3b8338298133f5eed2f /dbtests/jstests.cpp | |
parent | e9d5faa697f7caeea1f96b54a26d3d3d332d6c15 (diff) | |
download | mongo-d2bbdd79413431c25eb482ba823717f00a70d365.tar.gz |
BinData for spider monkey SERVER-97
Diffstat (limited to 'dbtests/jstests.cpp')
-rw-r--r-- | dbtests/jstests.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/dbtests/jstests.cpp b/dbtests/jstests.cpp index c56654dc44e..9d721098bec 100644 --- a/dbtests/jstests.cpp +++ b/dbtests/jstests.cpp @@ -550,6 +550,47 @@ namespace JSTests { const char * _a; const char * _b; }; + + class BinDataType { + public: + + void pp( const char * s , BSONElement e ){ + int len; + const char * data = e.binData( len ); + cout << s << ":" << e.binDataType() << "\t" << len << endl; + cout << "\t"; + for ( int i=0; i<len; i++ ) + cout << (int)(data[i]) << " "; + cout << endl; + } + + void run(){ + Scope * s = globalScriptEngine->createScope(); + s->localConnect( "asd" ); + const char * foo = "asdasdasdasd"; + + + BSONObj in; + { + BSONObjBuilder b; + b.append( "a" , 7 ); + b.appendBinData( "b" , strlen( foo ) , ByteArray , foo ); + in = b.obj(); + s->setObject( "x" , in ); + } + + s->invokeSafe( "myb = x.b; print( myb ); printjson( myb );" , BSONObj() ); + s->invokeSafe( "y = { c : myb };" , BSONObj() ); + + BSONObj out = s->getObject( "y" ); + ASSERT_EQUALS( BinData , out["c"].type() ); + //blah( "in " , in["b"] ); + //blah( "out" , out["c"] ); + ASSERT_EQUALS( 0 , in["b"].woCompare( out["c"] , false ) ); + + delete s; + } + }; class All : public Suite { public: @@ -572,6 +613,7 @@ namespace JSTests { add< LongUtf8String >(); add< CodeTests >(); add< DBRefTest >(); + add< BinDataType >(); } }; |