summaryrefslogtreecommitdiff
path: root/src/mongo/db/matcher/expression_array_test.cpp
diff options
context:
space:
mode:
authorJ. Rassi <rassi@10gen.com>2016-06-06 11:49:23 -0400
committerJ. Rassi <rassi@10gen.com>2016-06-06 16:50:55 -0400
commitc78f95141142e4d13c820a64aa26fe28d07ebb0c (patch)
treeb63ee4fceeaa689bb917467f4b647fe57f371e27 /src/mongo/db/matcher/expression_array_test.cpp
parent38ab06d09b2295d404c7e8d012a8491ed0a0ec1f (diff)
downloadmongo-c78f95141142e4d13c820a64aa26fe28d07ebb0c.tar.gz
SERVER-23611 Add ComparisonMatchExpression::setCollator() method
Also removes collator parameter from ComparisonMatchExpression constructor.
Diffstat (limited to 'src/mongo/db/matcher/expression_array_test.cpp')
-rw-r--r--src/mongo/db/matcher/expression_array_test.cpp63
1 files changed, 24 insertions, 39 deletions
diff --git a/src/mongo/db/matcher/expression_array_test.cpp b/src/mongo/db/matcher/expression_array_test.cpp
index 8fbc971221b..201d11fbed4 100644
--- a/src/mongo/db/matcher/expression_array_test.cpp
+++ b/src/mongo/db/matcher/expression_array_test.cpp
@@ -44,8 +44,7 @@ TEST(ElemMatchObjectMatchExpression, MatchesElementSingle) {
BSONObj baseOperand = BSON("b" << 5);
BSONObj match = BSON("a" << BSON_ARRAY(BSON("b" << 5.0)));
BSONObj notMatch = BSON("a" << BSON_ARRAY(BSON("b" << 6)));
- const CollatorInterface* collator = nullptr;
- unique_ptr<ComparisonMatchExpression> eq(new EqualityMatchExpression(collator));
+ unique_ptr<ComparisonMatchExpression> eq(new EqualityMatchExpression());
ASSERT(eq->init("b", baseOperand["b"]).isOK());
ElemMatchObjectMatchExpression op;
ASSERT(op.init("a", eq.release()).isOK());
@@ -57,8 +56,7 @@ TEST(ElemMatchObjectMatchExpression, MatchesElementArray) {
BSONObj baseOperand = BSON("1" << 5);
BSONObj match = BSON("a" << BSON_ARRAY(BSON_ARRAY('s' << 5.0)));
BSONObj notMatch = BSON("a" << BSON_ARRAY(BSON_ARRAY(5 << 6)));
- const CollatorInterface* collator = nullptr;
- unique_ptr<ComparisonMatchExpression> eq(new EqualityMatchExpression(collator));
+ unique_ptr<ComparisonMatchExpression> eq(new EqualityMatchExpression());
ASSERT(eq->init("1", baseOperand["1"]).isOK());
ElemMatchObjectMatchExpression op;
ASSERT(op.init("a", eq.release()).isOK());
@@ -74,12 +72,11 @@ TEST(ElemMatchObjectMatchExpression, MatchesElementMultiple) {
BSONObj notMatch2 = BSON("a" << BSON_ARRAY(BSON("b" << 6 << "c" << 7)));
BSONObj notMatch3 = BSON("a" << BSON_ARRAY(BSON("b" << BSON_ARRAY(5 << 6))));
BSONObj match = BSON("a" << BSON_ARRAY(BSON("b" << BSON_ARRAY(5 << 6) << "c" << 7)));
- const CollatorInterface* collator = nullptr;
- unique_ptr<ComparisonMatchExpression> eq1(new EqualityMatchExpression(collator));
+ unique_ptr<ComparisonMatchExpression> eq1(new EqualityMatchExpression());
ASSERT(eq1->init("b", baseOperand1["b"]).isOK());
- unique_ptr<ComparisonMatchExpression> eq2(new EqualityMatchExpression(collator));
+ unique_ptr<ComparisonMatchExpression> eq2(new EqualityMatchExpression());
ASSERT(eq2->init("b", baseOperand2["b"]).isOK());
- unique_ptr<ComparisonMatchExpression> eq3(new EqualityMatchExpression(collator));
+ unique_ptr<ComparisonMatchExpression> eq3(new EqualityMatchExpression());
ASSERT(eq3->init("c", baseOperand3["c"]).isOK());
unique_ptr<AndMatchExpression> andOp(new AndMatchExpression());
@@ -97,8 +94,7 @@ TEST(ElemMatchObjectMatchExpression, MatchesElementMultiple) {
TEST(ElemMatchObjectMatchExpression, MatchesNonArray) {
BSONObj baseOperand = BSON("b" << 5);
- const CollatorInterface* collator = nullptr;
- unique_ptr<ComparisonMatchExpression> eq(new EqualityMatchExpression(collator));
+ unique_ptr<ComparisonMatchExpression> eq(new EqualityMatchExpression());
ASSERT(eq->init("b", baseOperand["b"]).isOK());
ElemMatchObjectMatchExpression op;
ASSERT(op.init("a", eq.release()).isOK());
@@ -111,8 +107,7 @@ TEST(ElemMatchObjectMatchExpression, MatchesNonArray) {
TEST(ElemMatchObjectMatchExpression, MatchesArrayObject) {
BSONObj baseOperand = BSON("b" << 5);
- const CollatorInterface* collator = nullptr;
- unique_ptr<ComparisonMatchExpression> eq(new EqualityMatchExpression(collator));
+ unique_ptr<ComparisonMatchExpression> eq(new EqualityMatchExpression());
ASSERT(eq->init("b", baseOperand["b"]).isOK());
ElemMatchObjectMatchExpression op;
ASSERT(op.init("a", eq.release()).isOK());
@@ -124,8 +119,7 @@ TEST(ElemMatchObjectMatchExpression, MatchesArrayObject) {
TEST(ElemMatchObjectMatchExpression, MatchesMultipleNamedValues) {
BSONObj baseOperand = BSON("c" << 5);
- const CollatorInterface* collator = nullptr;
- unique_ptr<ComparisonMatchExpression> eq(new EqualityMatchExpression(collator));
+ unique_ptr<ComparisonMatchExpression> eq(new EqualityMatchExpression());
ASSERT(eq->init("c", baseOperand["c"]).isOK());
ElemMatchObjectMatchExpression op;
ASSERT(op.init("a.b", eq.release()).isOK());
@@ -137,8 +131,7 @@ TEST(ElemMatchObjectMatchExpression, MatchesMultipleNamedValues) {
TEST(ElemMatchObjectMatchExpression, ElemMatchKey) {
BSONObj baseOperand = BSON("c" << 6);
- const CollatorInterface* collator = nullptr;
- unique_ptr<ComparisonMatchExpression> eq(new EqualityMatchExpression(collator));
+ unique_ptr<ComparisonMatchExpression> eq(new EqualityMatchExpression());
ASSERT(eq->init("c", baseOperand["c"]).isOK());
ElemMatchObjectMatchExpression op;
ASSERT(op.init("a.b", eq.release()).isOK());
@@ -178,8 +171,7 @@ TEST(ElemMatchValueMatchExpression, MatchesElementSingle) {
BSONObj baseOperand = BSON("$gt" << 5);
BSONObj match = BSON("a" << BSON_ARRAY(6));
BSONObj notMatch = BSON("a" << BSON_ARRAY(4));
- const CollatorInterface* collator = nullptr;
- unique_ptr<ComparisonMatchExpression> gt(new GTMatchExpression(collator));
+ unique_ptr<ComparisonMatchExpression> gt(new GTMatchExpression());
ASSERT(gt->init("", baseOperand["$gt"]).isOK());
ElemMatchValueMatchExpression op;
ASSERT(op.init("a", gt.release()).isOK());
@@ -193,10 +185,9 @@ TEST(ElemMatchValueMatchExpression, MatchesElementMultiple) {
BSONObj notMatch1 = BSON("a" << BSON_ARRAY(0 << 1));
BSONObj notMatch2 = BSON("a" << BSON_ARRAY(10 << 11));
BSONObj match = BSON("a" << BSON_ARRAY(0 << 5 << 11));
- const CollatorInterface* collator = nullptr;
- unique_ptr<ComparisonMatchExpression> gt(new GTMatchExpression(collator));
+ unique_ptr<ComparisonMatchExpression> gt(new GTMatchExpression());
ASSERT(gt->init("", baseOperand1["$gt"]).isOK());
- unique_ptr<ComparisonMatchExpression> lt(new LTMatchExpression(collator));
+ unique_ptr<ComparisonMatchExpression> lt(new LTMatchExpression());
ASSERT(lt->init("", baseOperand2["$lt"]).isOK());
ElemMatchValueMatchExpression op;
@@ -211,8 +202,7 @@ TEST(ElemMatchValueMatchExpression, MatchesElementMultiple) {
TEST(ElemMatchValueMatchExpression, MatchesNonArray) {
BSONObj baseOperand = BSON("$gt" << 5);
- const CollatorInterface* collator = nullptr;
- unique_ptr<ComparisonMatchExpression> gt(new GTMatchExpression(collator));
+ unique_ptr<ComparisonMatchExpression> gt(new GTMatchExpression());
ASSERT(gt->init("", baseOperand["$gt"]).isOK());
ElemMatchObjectMatchExpression op;
ASSERT(op.init("a", gt.release()).isOK());
@@ -224,8 +214,7 @@ TEST(ElemMatchValueMatchExpression, MatchesNonArray) {
TEST(ElemMatchValueMatchExpression, MatchesArrayScalar) {
BSONObj baseOperand = BSON("$gt" << 5);
- const CollatorInterface* collator = nullptr;
- unique_ptr<ComparisonMatchExpression> gt(new GTMatchExpression(collator));
+ unique_ptr<ComparisonMatchExpression> gt(new GTMatchExpression());
ASSERT(gt->init("", baseOperand["$gt"]).isOK());
ElemMatchValueMatchExpression op;
ASSERT(op.init("a", gt.release()).isOK());
@@ -236,8 +225,7 @@ TEST(ElemMatchValueMatchExpression, MatchesArrayScalar) {
TEST(ElemMatchValueMatchExpression, MatchesMultipleNamedValues) {
BSONObj baseOperand = BSON("$gt" << 5);
- const CollatorInterface* collator = nullptr;
- unique_ptr<ComparisonMatchExpression> gt(new GTMatchExpression(collator));
+ unique_ptr<ComparisonMatchExpression> gt(new GTMatchExpression());
ASSERT(gt->init("", baseOperand["$gt"]).isOK());
ElemMatchValueMatchExpression op;
ASSERT(op.init("a.b", gt.release()).isOK());
@@ -249,8 +237,7 @@ TEST(ElemMatchValueMatchExpression, MatchesMultipleNamedValues) {
TEST(ElemMatchValueMatchExpression, ElemMatchKey) {
BSONObj baseOperand = BSON("$gt" << 6);
- const CollatorInterface* collator = nullptr;
- unique_ptr<ComparisonMatchExpression> gt(new GTMatchExpression(collator));
+ unique_ptr<ComparisonMatchExpression> gt(new GTMatchExpression());
ASSERT(gt->init("", baseOperand["$gt"]).isOK());
ElemMatchValueMatchExpression op;
ASSERT(op.init("a.b", gt.release()).isOK());
@@ -287,12 +274,11 @@ TEST( ElemMatchValueMatchExpression, MatchesIndexKey ) {
TEST(AndOfElemMatch, MatchesElement) {
BSONObj baseOperanda1 = BSON("a" << 1);
- const CollatorInterface* collator = nullptr;
- unique_ptr<ComparisonMatchExpression> eqa1(new EqualityMatchExpression(collator));
+ unique_ptr<ComparisonMatchExpression> eqa1(new EqualityMatchExpression());
ASSERT(eqa1->init("a", baseOperanda1["a"]).isOK());
BSONObj baseOperandb1 = BSON("b" << 1);
- unique_ptr<ComparisonMatchExpression> eqb1(new EqualityMatchExpression(collator));
+ unique_ptr<ComparisonMatchExpression> eqb1(new EqualityMatchExpression());
ASSERT(eqb1->init("b", baseOperandb1["b"]).isOK());
unique_ptr<AndMatchExpression> and1(new AndMatchExpression());
@@ -305,11 +291,11 @@ TEST(AndOfElemMatch, MatchesElement) {
// elemMatch1 = { x : { $elemMatch : { a : 1, b : 1 } } }
BSONObj baseOperanda2 = BSON("a" << 2);
- unique_ptr<ComparisonMatchExpression> eqa2(new EqualityMatchExpression(collator));
+ unique_ptr<ComparisonMatchExpression> eqa2(new EqualityMatchExpression());
ASSERT(eqa2->init("a", baseOperanda2["a"]).isOK());
BSONObj baseOperandb2 = BSON("b" << 2);
- unique_ptr<ComparisonMatchExpression> eqb2(new EqualityMatchExpression(collator));
+ unique_ptr<ComparisonMatchExpression> eqb2(new EqualityMatchExpression());
ASSERT(eqb2->init("b", baseOperandb2["b"]).isOK());
unique_ptr<AndMatchExpression> and2(new AndMatchExpression());
@@ -345,12 +331,11 @@ TEST(AndOfElemMatch, MatchesElement) {
TEST(AndOfElemMatch, Matches) {
BSONObj baseOperandgt1 = BSON("$gt" << 1);
- const CollatorInterface* collator = nullptr;
- unique_ptr<ComparisonMatchExpression> gt1(new GTMatchExpression(collator));
+ unique_ptr<ComparisonMatchExpression> gt1(new GTMatchExpression());
ASSERT(gt1->init("", baseOperandgt1["$gt"]).isOK());
BSONObj baseOperandlt1 = BSON("$lt" << 10);
- unique_ptr<ComparisonMatchExpression> lt1(new LTMatchExpression(collator));
+ unique_ptr<ComparisonMatchExpression> lt1(new LTMatchExpression());
ASSERT(lt1->init("", baseOperandlt1["$lt"]).isOK());
unique_ptr<ElemMatchValueMatchExpression> elemMatch1(new ElemMatchValueMatchExpression());
@@ -360,11 +345,11 @@ TEST(AndOfElemMatch, Matches) {
// elemMatch1 = { x : { $elemMatch : { $gt : 1 , $lt : 10 } } }
BSONObj baseOperandgt2 = BSON("$gt" << 101);
- unique_ptr<ComparisonMatchExpression> gt2(new GTMatchExpression(collator));
+ unique_ptr<ComparisonMatchExpression> gt2(new GTMatchExpression());
ASSERT(gt2->init("", baseOperandgt2["$gt"]).isOK());
BSONObj baseOperandlt2 = BSON("$lt" << 110);
- unique_ptr<ComparisonMatchExpression> lt2(new LTMatchExpression(collator));
+ unique_ptr<ComparisonMatchExpression> lt2(new LTMatchExpression());
ASSERT(lt2->init("", baseOperandlt2["$lt"]).isOK());
unique_ptr<ElemMatchValueMatchExpression> elemMatch2(new ElemMatchValueMatchExpression());