0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-30 00:56:44 +01:00

woCompare consider object length

This commit is contained in:
Aaron 2009-02-26 11:20:19 -05:00
parent ddb69bda2e
commit 8ccde5ae02
2 changed files with 13 additions and 2 deletions

View File

@ -639,7 +639,9 @@ namespace mongo {
if ( ordered )
o = k.next();
if ( l.eoo() )
return 0;
return r.eoo() ? 0 : -1;
if ( r.eoo() )
return 1;
int x = l.woCompare( r, considerFieldName );
if ( ordered && o.number() < 0 )

View File

@ -110,6 +110,14 @@ namespace JsobjTests {
}
};
class WoCompareDifferentLength : public Base {
public:
void run() {
ASSERT( BSON( "a" << 1 ).woCompare( BSON( "a" << 1 << "b" << 1 ) ) < 0 );
ASSERT( BSON( "a" << 1 << "b" << 1 ).woCompare( BSON( "a" << 1 ) ) > 0 );
}
};
class WoSortOrder : public Base {
public:
void run() {
@ -117,7 +125,7 @@ namespace JsobjTests {
ASSERT( fromjson( "{a:null}" ).woSortOrder( BSON( "b" << 1 ), BSON( "a" << 1 ) ) == 0 );
}
};
namespace Validation {
class Base {
@ -533,6 +541,7 @@ namespace JsobjTests {
add< BSONObjTests::WoCompareEmbeddedObject >();
add< BSONObjTests::WoCompareEmbeddedArray >();
add< BSONObjTests::WoCompareOrdered >();
add< BSONObjTests::WoCompareDifferentLength >();
add< BSONObjTests::WoSortOrder >();
add< BSONObjTests::Validation::BadType >();
add< BSONObjTests::Validation::EooBeforeEnd >();