diff options
Diffstat (limited to 'dbtests/queryutiltests.cpp')
-rw-r--r-- | dbtests/queryutiltests.cpp | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/dbtests/queryutiltests.cpp b/dbtests/queryutiltests.cpp index e825b4f..c3dd64d 100644 --- a/dbtests/queryutiltests.cpp +++ b/dbtests/queryutiltests.cpp @@ -238,7 +238,14 @@ namespace QueryUtilTests { } }; - class QueryPatternTest { + class QueryPatternBase { + protected: + static QueryPattern p( const BSONObj &query, const BSONObj &sort = BSONObj() ) { + return FieldRangeSet( "", query, true ).pattern( sort ); + } + }; + + class QueryPatternTest : public QueryPatternBase { public: void run() { ASSERT( p( BSON( "a" << 1 ) ) == p( BSON( "a" << 1 ) ) ); @@ -258,12 +265,17 @@ namespace QueryUtilTests { ASSERT( p( BSON( "a" << 1 ), BSON( "b" << 1 << "c" << 1 ) ) != p( BSON( "a" << 4 ), BSON( "b" << 1 ) ) ); ASSERT( p( BSON( "a" << 1 ), BSON( "b" << 1 ) ) != p( BSON( "a" << 4 ), BSON( "b" << 1 << "c" << 1 ) ) ); } - private: - static QueryPattern p( const BSONObj &query, const BSONObj &sort = BSONObj() ) { - return FieldRangeSet( "", query, true ).pattern( sort ); + }; + + class QueryPatternNeConstraint : public QueryPatternBase { + public: + void run() { + ASSERT( p( BSON( "a" << NE << 5 ) ) != p( BSON( "a" << GT << 1 ) ) ); + ASSERT( p( BSON( "a" << NE << 5 ) ) != p( BSONObj() ) ); + ASSERT( p( BSON( "a" << NE << 5 ) ) == p( BSON( "a" << NE << "a" ) ) ); } }; - + class NoWhere { public: void run() { @@ -902,6 +914,7 @@ namespace QueryUtilTests { add< FieldRangeTests::Equality >(); add< FieldRangeTests::SimplifiedQuery >(); add< FieldRangeTests::QueryPatternTest >(); + add< FieldRangeTests::QueryPatternNeConstraint >(); add< FieldRangeTests::NoWhere >(); add< FieldRangeTests::Numeric >(); add< FieldRangeTests::InLowerBound >(); |