summaryrefslogtreecommitdiff
path: root/dbtests/jstests.cpp
diff options
context:
space:
mode:
authorAaron <aaron@10gen.com>2010-01-25 14:07:02 -0800
committerAaron <aaron@10gen.com>2010-01-25 14:07:02 -0800
commit769029d7c8b243a30d0494c9fc526a3c20031f40 (patch)
treeed4f94cf3ca7e97ef5f724005b632ae74d4f44cd /dbtests/jstests.cpp
parentd0cd08bfb2e577a7cd2cce96f6a16f47c8636dc7 (diff)
downloadmongo-769029d7c8b243a30d0494c9fc526a3c20031f40.tar.gz
SERVER-256 fix BinData byte alignment issue and add base64 representation to toString() output
Diffstat (limited to 'dbtests/jstests.cpp')
-rw-r--r--dbtests/jstests.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/dbtests/jstests.cpp b/dbtests/jstests.cpp
index 599d2a7ec41..1810c561118 100644
--- a/dbtests/jstests.cpp
+++ b/dbtests/jstests.cpp
@@ -25,6 +25,8 @@
#include "dbtests.h"
+#include "util/base64.h"
+
namespace mongo {
bool dbEval(const char *ns, BSONObj& cmd, BSONObjBuilder& result, string& errmsg);
} // namespace mongo
@@ -721,7 +723,7 @@ namespace JSTests {
Scope * s = globalScriptEngine->newScope();
s->localConnect( "asd" );
const char * foo = "asdas\0asdasd";
-
+ const char * base64 = "YXNkYXMAYXNkYXNk";
BSONObj in;
{
@@ -737,13 +739,15 @@ namespace JSTests {
BSONObj out = s->getObject( "y" );
ASSERT_EQUALS( BinData , out["c"].type() );
- //blah( "in " , in["b"] );
- //blah( "out" , out["c"] );
+// pp( "in " , in["b"] );
+// pp( "out" , out["c"] );
ASSERT_EQUALS( 0 , in["b"].woCompare( out["c"] , false ) );
// check that BinData js class is utilized
- s->invokeSafe( "q = tojson( x.b );", BSONObj() );
- ASSERT_EQUALS( "BinData", s->getString( "q" ).substr( 0, 7 ) );
+ s->invokeSafe( "q = x.b.toString();", BSONObj() );
+ stringstream expected;
+ expected << "BinData( type: " << ByteArray << ", base64: \"" << base64 << "\" )";
+ ASSERT_EQUALS( expected.str(), s->getString( "q" ) );
delete s;
}