void setDifference(BSONObjSetDefaultOrder &l, BSONObjSetDefaultOrder &r, vector<BSONObj*> &diff) { BSONObjSetDefaultOrder::iterator i = l.begin(); BSONObjSetDefaultOrder::iterator j = r.begin(); while ( 1 ) { if ( i == l.end() ) break; while ( j != r.end() && j->woCompare( *i ) < 0 ) j++; if ( j == r.end() || i->woCompare(*j) != 0 ) { const BSONObj *jo = &*i; diff.push_back( (BSONObj *) jo ); } i++; } }
void run() { create(); BSONObjSetDefaultOrder keys; id().getKeysFromObject( fromjson( "{a:[{b:[2]}]}" ), keys ); checkSize( 1, keys ); assertEquals( BSON( "" << 2 ), *keys.begin() ); }
void run() { create(); BSONObjSetDefaultOrder keys; id().getKeysFromObject( BSON( "b" << 1 ), keys ); checkSize( 1, keys ); assertEquals( nullObj(), *keys.begin() ); }
void run() { create(); BSONObjBuilder b, e; b.append( "b", 4 ); b.append( "a", 5 ); e.append( "", 5 ); BSONObjSetDefaultOrder keys; id().getKeysFromObject( b.done(), keys ); checkSize( 1, keys ); assertEquals( e.obj(), *keys.begin() ); }
void run(){ create(); { BSONObjSetDefaultOrder keys; id().getKeysFromObject( fromjson( "{x:'a',y:'b'}" ) , keys ); checkSize( 1 , keys ); assertEquals( BSON( "" << "a" << "" << "b" ) , *keys.begin() ); } { BSONObjSetDefaultOrder keys; id().getKeysFromObject( fromjson( "{x:'a'}" ) , keys ); checkSize( 1 , keys ); BSONObjBuilder b; b.append( "" , "a" ); b.appendNull( "" ); assertEquals( b.obj() , *keys.begin() ); } }
void run() { create(); vector< BSONObj > elts; BSONObjBuilder s; s.append( "foo", 41 ); for ( int i = 1; i < 4; ++i ) elts.push_back( s.done() ); BSONObjBuilder b; b.append( "a", elts ); BSONObjSetDefaultOrder keys; id().getKeysFromObject( b.done(), keys ); checkSize( 1, keys ); assertEquals( nullObj(), *keys.begin() ); }
void run() { create(); BSONObjBuilder b; b.append( "a", shortArray()) ; BSONObjSetDefaultOrder keys; id().getKeysFromObject( b.done(), keys ); checkSize( 3, keys ); int j = 1; for ( BSONObjSetDefaultOrder::iterator i = keys.begin(); i != keys.end(); ++i, ++j ) { BSONObjBuilder b; b.append( "", j ); assertEquals( b.obj(), *i ); } }
void run() { create(); vector< BSONObj > elts; for ( int i = 1; i < 4; ++i ) elts.push_back( simpleBC( i ) ); BSONObjBuilder b; b.append( "a", elts ); BSONObjSetDefaultOrder keys; id().getKeysFromObject( b.done(), keys ); checkSize( 3, keys ); int j = 1; for ( BSONObjSetDefaultOrder::iterator i = keys.begin(); i != keys.end(); ++i, ++j ) { BSONObjBuilder b; b.append( "", j ); assertEquals( b.obj(), *i ); } }
void run() { create(); BSONObjSetDefaultOrder keys; id().getKeysFromObject( fromjson( "{a:[{b:1},{c:2}]}" ), keys ); checkSize( 2, keys ); BSONObjSetDefaultOrder::iterator i = keys.begin(); { BSONObjBuilder e; e.appendNull( "" ); e.append( "", 2 ); assertEquals( e.obj(), *i++ ); } { BSONObjBuilder e; e.append( "", 1 ); e.appendNull( "" ); assertEquals( e.obj(), *i++ ); } }