From 26543060c852aac22f26143a04bf7789ec8fec53 Mon Sep 17 00:00:00 2001 From: David Storch Date: Fri, 12 Aug 2016 15:58:56 -0400 Subject: SERVER-24508 BSONObj::ComparatorInterface BSONObj instances should now be compared via the comparator interface's evaluate() method. This preferred over using BSONObj::woCompare() directly. If the comparison doesn't require any database semantics (e.g. there is no collation), there is a global instance of the SimpleBSONObjComparator which should be used for BSONObj comparisons. If the comparison requires special semantics, then callers must instantiate their own comparator object. --- src/mongo/db/field_parser_test.cpp | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'src/mongo/db/field_parser_test.cpp') diff --git a/src/mongo/db/field_parser_test.cpp b/src/mongo/db/field_parser_test.cpp index 428699484b9..7ceb01d66a6 100644 --- a/src/mongo/db/field_parser_test.cpp +++ b/src/mongo/db/field_parser_test.cpp @@ -44,9 +44,9 @@ using mongo::BSONObjBuilder; using mongo::Date_t; using mongo::FieldParser; using mongo::OID; +using std::map; using std::string; using std::vector; -using std::map; class ExtractionFixture : public mongo::unittest::Test { protected: @@ -112,11 +112,11 @@ TEST_F(ExtractionFixture, GetBSONArray) { BSONField wrongType(aString.name()); BSONArray val; ASSERT_TRUE(FieldParser::extract(doc, anArray, &val)); - ASSERT_EQUALS(val, valArray); + ASSERT_BSONOBJ_EQ(val, valArray); ASSERT_TRUE(FieldParser::extract(doc, notThere, &val)); - ASSERT_EQUALS(val, - BSON_ARRAY("a" - << "b")); + ASSERT_BSONOBJ_EQ(val, + BSON_ARRAY("a" + << "b")); ASSERT_FALSE(FieldParser::extract(doc, wrongType, &val)); } @@ -125,9 +125,9 @@ TEST_F(ExtractionFixture, GetBSONObj) { BSONField wrongType(aString.name()); BSONObj val; ASSERT_TRUE(FieldParser::extract(doc, anObj, &val)); - ASSERT_EQUALS(val, valObj); + ASSERT_BSONOBJ_EQ(val, valObj); ASSERT_TRUE(FieldParser::extract(doc, notThere, &val)); - ASSERT_EQUALS(val, BSON("b" << 1)); + ASSERT_BSONOBJ_EQ(val, BSON("b" << 1)); ASSERT_FALSE(FieldParser::extract(doc, wrongType, &val)); } @@ -237,9 +237,9 @@ TEST(ComplexExtraction, GetObjectVector) { vector parsedVector; ASSERT(FieldParser::extract(obj, vectorField, &parsedVector)); - ASSERT_EQUALS(BSON("a" << 1), parsedVector[0]); - ASSERT_EQUALS(BSON("b" << 1), parsedVector[1]); - ASSERT_EQUALS(BSON("c" << 1), parsedVector[2]); + ASSERT_BSONOBJ_EQ(BSON("a" << 1), parsedVector[0]); + ASSERT_BSONOBJ_EQ(BSON("b" << 1), parsedVector[1]); + ASSERT_BSONOBJ_EQ(BSON("c" << 1), parsedVector[2]); ASSERT_EQUALS(parsedVector.size(), static_cast(3)); } @@ -329,15 +329,15 @@ TEST(ComplexExtraction, GetObjectMap) { map parsedMap; ASSERT(FieldParser::extract(obj, mapField, &parsedMap)); - ASSERT_EQUALS(BSON("a" - << "a"), - parsedMap["a"]); - ASSERT_EQUALS(BSON("b" - << "b"), - parsedMap["b"]); - ASSERT_EQUALS(BSON("c" - << "c"), - parsedMap["c"]); + ASSERT_BSONOBJ_EQ(BSON("a" + << "a"), + parsedMap["a"]); + ASSERT_BSONOBJ_EQ(BSON("b" + << "b"), + parsedMap["b"]); + ASSERT_BSONOBJ_EQ(BSON("c" + << "c"), + parsedMap["c"]); ASSERT_EQUALS(parsedMap.size(), static_cast(3)); } -- cgit v1.2.1