summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathias Stearn <mathias@10gen.com>2010-03-01 20:24:50 -0500
committerMathias Stearn <mathias@10gen.com>2010-03-01 20:24:50 -0500
commitfe4b68b1ea900c20bf0acc319e9e6115d32f9aa5 (patch)
treef06b250e6b6a39431c3dd73e3911cba79aaf2bc6
parent55df6a9a233806f3823d5fa527704a6c63e2d135 (diff)
downloadmongo-fe4b68b1ea900c20bf0acc319e9e6115d32f9aa5.tar.gz
Fix regex unit tests
-rw-r--r--dbtests/queryoptimizertests.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/dbtests/queryoptimizertests.cpp b/dbtests/queryoptimizertests.cpp
index 0d053697535..d757f1a4a01 100644
--- a/dbtests/queryoptimizertests.cpp
+++ b/dbtests/queryoptimizertests.cpp
@@ -55,7 +55,6 @@ namespace QueryOptimizerTests {
virtual bool lowerInclusive() { return true; }
virtual BSONElement upper() { return maxKey.firstElement(); }
virtual bool upperInclusive() { return true; }
- private:
static void checkElt( BSONElement expected, BSONElement actual ) {
if ( expected.woCompare( actual, false ) ) {
stringstream ss;
@@ -144,7 +143,17 @@ namespace QueryOptimizerTests {
}
};
- class Regex : public Base {
+ struct RegexBase : Base {
+ void run() { //need to only look at first interval
+ FieldRangeSet s( "ns", query() );
+ checkElt( lower(), s.range( "a" ).intervals()[0].lower_.bound_ );
+ checkElt( upper(), s.range( "a" ).intervals()[0].upper_.bound_ );
+ ASSERT_EQUALS( lowerInclusive(), s.range( "a" ).intervals()[0].lower_.inclusive_ );
+ ASSERT_EQUALS( upperInclusive(), s.range( "a" ).intervals()[0].upper_.inclusive_ );
+ }
+ };
+
+ class Regex : public RegexBase {
public:
Regex() : o1_( BSON( "" << "abc" ) ), o2_( BSON( "" << "abd" ) ) {}
virtual BSONObj query() {
@@ -158,7 +167,7 @@ namespace QueryOptimizerTests {
BSONObj o1_, o2_;
};
- class RegexObj : public Base {
+ class RegexObj : public RegexBase {
public:
RegexObj() : o1_( BSON( "" << "abc" ) ), o2_( BSON( "" << "abd" ) ) {}
virtual BSONObj query() { return BSON("a" << BSON("$regex" << "^abc")); }
@@ -168,7 +177,7 @@ namespace QueryOptimizerTests {
BSONObj o1_, o2_;
};
- class UnhelpfulRegex : public Base {
+ class UnhelpfulRegex : public RegexBase {
public:
UnhelpfulRegex() {
BSONObjBuilder b;