diff options
Diffstat (limited to 'src/mongo/db/matcher/expression_tree_test.cpp')
| -rw-r--r-- | src/mongo/db/matcher/expression_tree_test.cpp | 64 |
1 files changed, 25 insertions, 39 deletions
diff --git a/src/mongo/db/matcher/expression_tree_test.cpp b/src/mongo/db/matcher/expression_tree_test.cpp index 8ede86c0f0d..eadfd99d889 100644 --- a/src/mongo/db/matcher/expression_tree_test.cpp +++ b/src/mongo/db/matcher/expression_tree_test.cpp @@ -42,8 +42,7 @@ using std::unique_ptr; TEST(NotMatchExpression, MatchesScalar) { BSONObj baseOperand = BSON("$lt" << 5); - const CollatorInterface* collator = nullptr; - unique_ptr<ComparisonMatchExpression> lt(new LTMatchExpression(collator)); + unique_ptr<ComparisonMatchExpression> lt(new LTMatchExpression()); ASSERT(lt->init("a", baseOperand["$lt"]).isOK()); NotMatchExpression notOp; ASSERT(notOp.init(lt.release()).isOK()); @@ -53,8 +52,7 @@ TEST(NotMatchExpression, MatchesScalar) { TEST(NotMatchExpression, MatchesArray) { BSONObj baseOperand = BSON("$lt" << 5); - const CollatorInterface* collator = nullptr; - unique_ptr<ComparisonMatchExpression> lt(new LTMatchExpression(collator)); + unique_ptr<ComparisonMatchExpression> lt(new LTMatchExpression()); ASSERT(lt->init("a", baseOperand["$lt"]).isOK()); NotMatchExpression notOp; ASSERT(notOp.init(lt.release()).isOK()); @@ -66,8 +64,7 @@ TEST(NotMatchExpression, MatchesArray) { TEST(NotMatchExpression, ElemMatchKey) { BSONObj baseOperand = BSON("$lt" << 5); - const CollatorInterface* collator = nullptr; - unique_ptr<ComparisonMatchExpression> lt(new LTMatchExpression(collator)); + unique_ptr<ComparisonMatchExpression> lt(new LTMatchExpression()); ASSERT(lt->init("a", baseOperand["$lt"]).isOK()); NotMatchExpression notOp; ASSERT(notOp.init(lt.release()).isOK()); @@ -130,10 +127,9 @@ TEST(AndOp, MatchesElementThreeClauses) { BSONObj notMatch3 = BSON("a" << "r"); - const CollatorInterface* collator = nullptr; - unique_ptr<ComparisonMatchExpression> sub1(new LTMatchExpression(collator)); + unique_ptr<ComparisonMatchExpression> sub1(new LTMatchExpression()); ASSERT(sub1->init("a", baseOperand1["$lt"]).isOK()); - unique_ptr<ComparisonMatchExpression> sub2(new GTMatchExpression(collator)); + unique_ptr<ComparisonMatchExpression> sub2(new GTMatchExpression()); ASSERT(sub2->init("a", baseOperand2["$gt"]).isOK()); unique_ptr<RegexMatchExpression> sub3(new RegexMatchExpression()); ASSERT(sub3->init("a", "1", "").isOK()); @@ -151,8 +147,7 @@ TEST(AndOp, MatchesElementThreeClauses) { TEST(AndOp, MatchesSingleClause) { BSONObj baseOperand = BSON("$ne" << 5); - const CollatorInterface* collator = nullptr; - unique_ptr<ComparisonMatchExpression> eq(new EqualityMatchExpression(collator)); + unique_ptr<ComparisonMatchExpression> eq(new EqualityMatchExpression()); ASSERT(eq->init("a", baseOperand["$ne"]).isOK()); unique_ptr<NotMatchExpression> ne(new NotMatchExpression()); ASSERT(ne->init(eq.release()).isOK()); @@ -171,14 +166,13 @@ TEST(AndOp, MatchesThreeClauses) { BSONObj baseOperand2 = BSON("$lt" << 10); BSONObj baseOperand3 = BSON("$lt" << 100); - const CollatorInterface* collator = nullptr; - unique_ptr<ComparisonMatchExpression> sub1(new GTMatchExpression(collator)); + unique_ptr<ComparisonMatchExpression> sub1(new GTMatchExpression()); ASSERT(sub1->init("a", baseOperand1["$gt"]).isOK()); - unique_ptr<ComparisonMatchExpression> sub2(new LTMatchExpression(collator)); + unique_ptr<ComparisonMatchExpression> sub2(new LTMatchExpression()); ASSERT(sub2->init("a", baseOperand2["$lt"]).isOK()); - unique_ptr<ComparisonMatchExpression> sub3(new LTMatchExpression(collator)); + unique_ptr<ComparisonMatchExpression> sub3(new LTMatchExpression()); ASSERT(sub3->init("b", baseOperand3["$lt"]).isOK()); AndMatchExpression andOp; @@ -197,11 +191,10 @@ TEST(AndOp, ElemMatchKey) { BSONObj baseOperand1 = BSON("a" << 1); BSONObj baseOperand2 = BSON("b" << 2); - const CollatorInterface* collator = nullptr; - unique_ptr<ComparisonMatchExpression> sub1(new EqualityMatchExpression(collator)); + unique_ptr<ComparisonMatchExpression> sub1(new EqualityMatchExpression()); ASSERT(sub1->init("a", baseOperand1["a"]).isOK()); - unique_ptr<ComparisonMatchExpression> sub2(new EqualityMatchExpression(collator)); + unique_ptr<ComparisonMatchExpression> sub2(new EqualityMatchExpression()); ASSERT(sub2->init("b", baseOperand2["b"]).isOK()); AndMatchExpression andOp; @@ -318,8 +311,7 @@ TEST( OrOp, MatchesElementThreeClauses ) { */ TEST(OrOp, MatchesSingleClause) { BSONObj baseOperand = BSON("$ne" << 5); - const CollatorInterface* collator = nullptr; - unique_ptr<ComparisonMatchExpression> eq(new EqualityMatchExpression(collator)); + unique_ptr<ComparisonMatchExpression> eq(new EqualityMatchExpression()); ASSERT(eq->init("a", baseOperand["$ne"]).isOK()); unique_ptr<NotMatchExpression> ne(new NotMatchExpression()); ASSERT(ne->init(eq.release()).isOK()); @@ -337,12 +329,11 @@ TEST(OrOp, MatchesThreeClauses) { BSONObj baseOperand1 = BSON("$gt" << 10); BSONObj baseOperand2 = BSON("$lt" << 0); BSONObj baseOperand3 = BSON("b" << 100); - const CollatorInterface* collator = nullptr; - unique_ptr<ComparisonMatchExpression> sub1(new GTMatchExpression(collator)); + unique_ptr<ComparisonMatchExpression> sub1(new GTMatchExpression()); ASSERT(sub1->init("a", baseOperand1["$gt"]).isOK()); - unique_ptr<ComparisonMatchExpression> sub2(new LTMatchExpression(collator)); + unique_ptr<ComparisonMatchExpression> sub2(new LTMatchExpression()); ASSERT(sub2->init("a", baseOperand2["$lt"]).isOK()); - unique_ptr<ComparisonMatchExpression> sub3(new EqualityMatchExpression(collator)); + unique_ptr<ComparisonMatchExpression> sub3(new EqualityMatchExpression()); ASSERT(sub3->init("b", baseOperand3["b"]).isOK()); OrMatchExpression orOp; @@ -362,10 +353,9 @@ TEST(OrOp, MatchesThreeClauses) { TEST(OrOp, ElemMatchKey) { BSONObj baseOperand1 = BSON("a" << 1); BSONObj baseOperand2 = BSON("b" << 2); - const CollatorInterface* collator = nullptr; - unique_ptr<ComparisonMatchExpression> sub1(new EqualityMatchExpression(collator)); + unique_ptr<ComparisonMatchExpression> sub1(new EqualityMatchExpression()); ASSERT(sub1->init("a", baseOperand1["a"]).isOK()); - unique_ptr<ComparisonMatchExpression> sub2(new EqualityMatchExpression(collator)); + unique_ptr<ComparisonMatchExpression> sub2(new EqualityMatchExpression()); ASSERT(sub2->init("b", baseOperand2["b"]).isOK()); OrMatchExpression orOp; @@ -482,8 +472,7 @@ TEST( NorOp, MatchesElementThreeClauses ) { TEST(NorOp, MatchesSingleClause) { BSONObj baseOperand = BSON("$ne" << 5); - const CollatorInterface* collator = nullptr; - unique_ptr<ComparisonMatchExpression> eq(new EqualityMatchExpression(collator)); + unique_ptr<ComparisonMatchExpression> eq(new EqualityMatchExpression()); ASSERT(eq->init("a", baseOperand["$ne"]).isOK()); unique_ptr<NotMatchExpression> ne(new NotMatchExpression()); ASSERT(ne->init(eq.release()).isOK()); @@ -502,12 +491,11 @@ TEST(NorOp, MatchesThreeClauses) { BSONObj baseOperand2 = BSON("$lt" << 0); BSONObj baseOperand3 = BSON("b" << 100); - const CollatorInterface* collator = nullptr; - unique_ptr<ComparisonMatchExpression> sub1(new GTMatchExpression(collator)); + unique_ptr<ComparisonMatchExpression> sub1(new GTMatchExpression()); ASSERT(sub1->init("a", baseOperand1["$gt"]).isOK()); - unique_ptr<ComparisonMatchExpression> sub2(new LTMatchExpression(collator)); + unique_ptr<ComparisonMatchExpression> sub2(new LTMatchExpression()); ASSERT(sub2->init("a", baseOperand2["$lt"]).isOK()); - unique_ptr<ComparisonMatchExpression> sub3(new EqualityMatchExpression(collator)); + unique_ptr<ComparisonMatchExpression> sub3(new EqualityMatchExpression()); ASSERT(sub3->init("b", baseOperand3["b"]).isOK()); NorMatchExpression norOp; @@ -527,10 +515,9 @@ TEST(NorOp, MatchesThreeClauses) { TEST(NorOp, ElemMatchKey) { BSONObj baseOperand1 = BSON("a" << 1); BSONObj baseOperand2 = BSON("b" << 2); - const CollatorInterface* collator = nullptr; - unique_ptr<ComparisonMatchExpression> sub1(new EqualityMatchExpression(collator)); + unique_ptr<ComparisonMatchExpression> sub1(new EqualityMatchExpression()); ASSERT(sub1->init("a", baseOperand1["a"]).isOK()); - unique_ptr<ComparisonMatchExpression> sub2(new EqualityMatchExpression(collator)); + unique_ptr<ComparisonMatchExpression> sub2(new EqualityMatchExpression()); ASSERT(sub2->init("b", baseOperand2["b"]).isOK()); NorMatchExpression norOp; @@ -552,10 +539,9 @@ TEST(NorOp, ElemMatchKey) { TEST(NorOp, Equivalent) { BSONObj baseOperand1 = BSON("a" << 1); BSONObj baseOperand2 = BSON("b" << 2); - const CollatorInterface* collator = nullptr; - EqualityMatchExpression sub1(collator); + EqualityMatchExpression sub1; ASSERT(sub1.init("a", baseOperand1["a"]).isOK()); - EqualityMatchExpression sub2(collator); + EqualityMatchExpression sub2; ASSERT(sub2.init("b", baseOperand2["b"]).isOK()); NorMatchExpression e1; |
