diff options
Diffstat (limited to 'src/mongo/db/matcher/expression_parser_array_test.cpp')
-rw-r--r-- | src/mongo/db/matcher/expression_parser_array_test.cpp | 152 |
1 files changed, 109 insertions, 43 deletions
diff --git a/src/mongo/db/matcher/expression_parser_array_test.cpp b/src/mongo/db/matcher/expression_parser_array_test.cpp index e37f6e8adc6..2a9d0467ce3 100644 --- a/src/mongo/db/matcher/expression_parser_array_test.cpp +++ b/src/mongo/db/matcher/expression_parser_array_test.cpp @@ -214,12 +214,16 @@ TEST(MatchExpressionParserArrayTest, ElemMatchDBRef1) { OID oid = OID::gen(); BSONObj match = BSON("$ref" << "coll" - << "$id" << oid << "$db" + << "$id" + << oid + << "$db" << "db"); OID oidx = OID::gen(); BSONObj notMatch = BSON("$ref" << "coll" - << "$id" << oidx << "$db" + << "$id" + << oidx + << "$db" << "db"); BSONObj query = BSON("x" << BSON("$elemMatch" << BSON("$eq" << match))); @@ -237,12 +241,16 @@ TEST(MatchExpressionParserArrayTest, ElemMatchDBRef2) { OID oid = OID::gen(); BSONObj match = BSON("$ref" << "coll" - << "$id" << oid << "$db" + << "$id" + << oid + << "$db" << "db"); OID oidx = OID::gen(); BSONObj notMatch = BSON("$ref" << "coll" - << "$id" << oidx << "$db" + << "$id" + << oidx + << "$db" << "db"); BSONObj query = BSON("x" << BSON("$elemMatch" << match)); @@ -261,11 +269,17 @@ TEST(MatchExpressionParserArrayTest, ElemMatchDBRef3) { OID oid = OID::gen(); BSONObj match = BSON("$ref" << "coll" - << "$id" << oid << "foo" << 12345); + << "$id" + << oid + << "foo" + << 12345); OID oidx = OID::gen(); BSONObj notMatch = BSON("$ref" << "coll" - << "$id" << oidx << "foo" << 12345); + << "$id" + << oidx + << "foo" + << 12345); BSONObj query = BSON("x" << BSON("$elemMatch" << match)); const CollatorInterface* collator = nullptr; @@ -278,10 +292,14 @@ TEST(MatchExpressionParserArrayTest, ElemMatchDBRef3) { ASSERT(result.getValue()->matchesBSON(BSON("x" << BSON_ARRAY(match)))); // Document contains fields not referred to in $elemMatch query. - ASSERT(result.getValue()->matchesBSON( - BSON("x" << BSON_ARRAY(BSON("$ref" - << "coll" - << "$id" << oid << "foo" << 12345 << "bar" << 678))))); + ASSERT(result.getValue()->matchesBSON(BSON("x" << BSON_ARRAY(BSON("$ref" + << "coll" + << "$id" + << oid + << "foo" + << 12345 + << "bar" + << 678))))); } // Query with DBRef fields out of order. @@ -289,16 +307,22 @@ TEST(MatchExpressionParserArrayTest, ElemMatchDBRef4) { OID oid = OID::gen(); BSONObj match = BSON("$ref" << "coll" - << "$id" << oid << "$db" + << "$id" + << oid + << "$db" << "db"); BSONObj matchOutOfOrder = BSON("$db" << "db" - << "$id" << oid << "$ref" + << "$id" + << oid + << "$ref" << "coll"); OID oidx = OID::gen(); BSONObj notMatch = BSON("$ref" << "coll" - << "$id" << oidx << "$db" + << "$id" + << oidx + << "$db" << "db"); BSONObj query = BSON("x" << BSON("$elemMatch" << matchOutOfOrder)); @@ -318,13 +342,19 @@ TEST(MatchExpressionParserArrayTest, ElemMatchDBRef5) { OID oid = OID::gen(); BSONObj match = BSON("$ref" << "coll" - << "$id" << oid << "foo" << 12345); + << "$id" + << oid + << "foo" + << 12345); BSONObj matchOutOfOrder = BSON("foo" << 12345 << "$id" << oid << "$ref" << "coll"); OID oidx = OID::gen(); BSONObj notMatch = BSON("$ref" << "coll" - << "$id" << oidx << "foo" << 12345); + << "$id" + << oidx + << "foo" + << 12345); BSONObj query = BSON("x" << BSON("$elemMatch" << matchOutOfOrder)); const CollatorInterface* collator = nullptr; @@ -337,10 +367,14 @@ TEST(MatchExpressionParserArrayTest, ElemMatchDBRef5) { ASSERT(result.getValue()->matchesBSON(BSON("x" << BSON_ARRAY(match)))); // Document contains fields not referred to in $elemMatch query. - ASSERT(result.getValue()->matchesBSON( - BSON("x" << BSON_ARRAY(BSON("$ref" - << "coll" - << "$id" << oid << "foo" << 12345 << "bar" << 678))))); + ASSERT(result.getValue()->matchesBSON(BSON("x" << BSON_ARRAY(BSON("$ref" + << "coll" + << "$id" + << oid + << "foo" + << 12345 + << "bar" + << 678))))); } // Incomplete DBRef - $id missing. @@ -348,13 +382,20 @@ TEST(MatchExpressionParserArrayTest, ElemMatchDBRef6) { OID oid = OID::gen(); BSONObj match = BSON("$ref" << "coll" - << "$id" << oid << "foo" << 12345); + << "$id" + << oid + << "foo" + << 12345); BSONObj matchMissingID = BSON("$ref" << "coll" - << "foo" << 12345); + << "foo" + << 12345); BSONObj notMatch = BSON("$ref" << "collx" - << "$id" << oid << "foo" << 12345); + << "$id" + << oid + << "foo" + << 12345); BSONObj query = BSON("x" << BSON("$elemMatch" << matchMissingID)); const CollatorInterface* collator = nullptr; @@ -367,10 +408,14 @@ TEST(MatchExpressionParserArrayTest, ElemMatchDBRef6) { ASSERT(result.getValue()->matchesBSON(BSON("x" << BSON_ARRAY(match)))); // Document contains fields not referred to in $elemMatch query. - ASSERT(result.getValue()->matchesBSON( - BSON("x" << BSON_ARRAY(BSON("$ref" - << "coll" - << "$id" << oid << "foo" << 12345 << "bar" << 678))))); + ASSERT(result.getValue()->matchesBSON(BSON("x" << BSON_ARRAY(BSON("$ref" + << "coll" + << "$id" + << oid + << "foo" + << 12345 + << "bar" + << 678))))); } // Incomplete DBRef - $ref missing. @@ -378,12 +423,18 @@ TEST(MatchExpressionParserArrayTest, ElemMatchDBRef7) { OID oid = OID::gen(); BSONObj match = BSON("$ref" << "coll" - << "$id" << oid << "foo" << 12345); + << "$id" + << oid + << "foo" + << 12345); BSONObj matchMissingRef = BSON("$id" << oid << "foo" << 12345); OID oidx = OID::gen(); BSONObj notMatch = BSON("$ref" << "coll" - << "$id" << oidx << "foo" << 12345); + << "$id" + << oidx + << "foo" + << 12345); BSONObj query = BSON("x" << BSON("$elemMatch" << matchMissingRef)); const CollatorInterface* collator = nullptr; @@ -396,10 +447,14 @@ TEST(MatchExpressionParserArrayTest, ElemMatchDBRef7) { ASSERT(result.getValue()->matchesBSON(BSON("x" << BSON_ARRAY(match)))); // Document contains fields not referred to in $elemMatch query. - ASSERT(result.getValue()->matchesBSON( - BSON("x" << BSON_ARRAY(BSON("$ref" - << "coll" - << "$id" << oid << "foo" << 12345 << "bar" << 678))))); + ASSERT(result.getValue()->matchesBSON(BSON("x" << BSON_ARRAY(BSON("$ref" + << "coll" + << "$id" + << oid + << "foo" + << 12345 + << "bar" + << 678))))); } // Incomplete DBRef - $db only. @@ -407,17 +462,24 @@ TEST(MatchExpressionParserArrayTest, ElemMatchDBRef8) { OID oid = OID::gen(); BSONObj match = BSON("$ref" << "coll" - << "$id" << oid << "$db" + << "$id" + << oid + << "$db" << "db" - << "foo" << 12345); + << "foo" + << 12345); BSONObj matchDBOnly = BSON("$db" << "db" - << "foo" << 12345); + << "foo" + << 12345); BSONObj notMatch = BSON("$ref" << "coll" - << "$id" << oid << "$db" + << "$id" + << oid + << "$db" << "dbx" - << "foo" << 12345); + << "foo" + << 12345); BSONObj query = BSON("x" << BSON("$elemMatch" << matchDBOnly)); const CollatorInterface* collator = nullptr; @@ -430,12 +492,16 @@ TEST(MatchExpressionParserArrayTest, ElemMatchDBRef8) { ASSERT(result.getValue()->matchesBSON(BSON("x" << BSON_ARRAY(match)))); // Document contains fields not referred to in $elemMatch query. - ASSERT(result.getValue()->matchesBSON( - BSON("x" << BSON_ARRAY(BSON("$ref" - << "coll" - << "$id" << oid << "$db" - << "db" - << "foo" << 12345 << "bar" << 678))))); + ASSERT(result.getValue()->matchesBSON(BSON("x" << BSON_ARRAY(BSON("$ref" + << "coll" + << "$id" + << oid + << "$db" + << "db" + << "foo" + << 12345 + << "bar" + << 678))))); } TEST(MatchExpressionParserArrayTest, All1) { |