summaryrefslogtreecommitdiff
path: root/src/mongo/bson
diff options
context:
space:
mode:
authorDavid Hatch <david.hatch@mongodb.com>2016-07-21 13:27:49 -0400
committerDavid Hatch <david.hatch@mongodb.com>2016-07-22 16:21:19 -0400
commit4e1dacf63d435c91b8ae33c2982d13b3ca87a6d9 (patch)
tree99d70764b310e66df4e9e9d441f96fd1d8c218e0 /src/mongo/bson
parentf7c13e7396803e56ea46fe2d4418dbcf59b9eb57 (diff)
downloadmongo-4e1dacf63d435c91b8ae33c2982d13b3ca87a6d9.tar.gz
SERVER-24873 Remove StringData::ComparatorInterface default argument.
Diffstat (limited to 'src/mongo/bson')
-rw-r--r--src/mongo/bson/mutable/algorithm.h37
-rw-r--r--src/mongo/bson/mutable/const_element-inl.h27
-rw-r--r--src/mongo/bson/mutable/const_element.h25
-rw-r--r--src/mongo/bson/mutable/document-inl.h12
-rw-r--r--src/mongo/bson/mutable/document.cpp22
-rw-r--r--src/mongo/bson/mutable/document.h11
-rw-r--r--src/mongo/bson/mutable/element.h12
-rw-r--r--src/mongo/bson/mutable/mutable_bson_algo_test.cpp10
-rw-r--r--src/mongo/bson/mutable/mutable_bson_test.cpp58
-rw-r--r--src/mongo/bson/mutable/mutable_bson_test_utils.cpp16
10 files changed, 110 insertions, 120 deletions
diff --git a/src/mongo/bson/mutable/algorithm.h b/src/mongo/bson/mutable/algorithm.h
index de1134e0162..768469deff4 100644
--- a/src/mongo/bson/mutable/algorithm.h
+++ b/src/mongo/bson/mutable/algorithm.h
@@ -167,51 +167,48 @@ void deduplicateChildren(Element parent, EqualityComparator equal) {
class woLess {
// TODO: This should possibly derive from std::binary_function.
public:
- woLess(bool considerFieldName = true,
- const StringData::ComparatorInterface* comparator = nullptr)
- : _considerFieldName(considerFieldName), _comp(comparator) {}
+ woLess(const StringData::ComparatorInterface* comparator, bool considerFieldName = true)
+ : _comp(comparator), _considerFieldName(considerFieldName) {}
inline bool operator()(const ConstElement& left, const ConstElement& right) const {
- return left.compareWithElement(right, _considerFieldName, _comp) < 0;
+ return left.compareWithElement(right, _comp, _considerFieldName) < 0;
}
private:
- const bool _considerFieldName;
const StringData::ComparatorInterface* _comp = nullptr;
+ const bool _considerFieldName;
};
/** A greater-than ordering for Elements that compares based on woCompare */
class woGreater {
// TODO: This should possibly derive from std::binary_function.
public:
- woGreater(bool considerFieldName = true,
- const StringData::ComparatorInterface* comparator = nullptr)
- : _considerFieldName(considerFieldName), _comp(comparator) {}
+ woGreater(const StringData::ComparatorInterface* comparator, bool considerFieldName = true)
+ : _comp(comparator), _considerFieldName(considerFieldName) {}
inline bool operator()(const ConstElement& left, const ConstElement& right) const {
- return left.compareWithElement(right, _considerFieldName, _comp) > 0;
+ return left.compareWithElement(right, _comp, _considerFieldName) > 0;
}
private:
- const bool _considerFieldName;
const StringData::ComparatorInterface* _comp = nullptr;
+ const bool _considerFieldName;
};
/** An equality predicate for elements that compares based on woCompare */
class woEqual {
// TODO: This should possibly derive from std::binary_function.
public:
- woEqual(bool considerFieldName = true,
- const StringData::ComparatorInterface* comparator = nullptr)
- : _considerFieldName(considerFieldName), _comp(comparator) {}
+ woEqual(const StringData::ComparatorInterface* comparator, bool considerFieldName = true)
+ : _comp(comparator), _considerFieldName(considerFieldName) {}
inline bool operator()(const ConstElement& left, const ConstElement& right) const {
- return left.compareWithElement(right, _considerFieldName, _comp) == 0;
+ return left.compareWithElement(right, _comp, _considerFieldName) == 0;
}
private:
- const bool _considerFieldName;
const StringData::ComparatorInterface* _comp = nullptr;
+ const bool _considerFieldName;
};
/** An equality predicate for elements that compares based on woCompare */
@@ -219,18 +216,18 @@ class woEqualTo {
// TODO: This should possibly derive from std::binary_function.
public:
woEqualTo(const ConstElement& value,
- bool considerFieldName = true,
- const StringData::ComparatorInterface* comparator = nullptr)
- : _value(value), _considerFieldName(considerFieldName), _comp(comparator) {}
+ const StringData::ComparatorInterface* comparator,
+ bool considerFieldName = true)
+ : _value(value), _comp(comparator), _considerFieldName(considerFieldName) {}
inline bool operator()(const ConstElement& elt) const {
- return _value.compareWithElement(elt, _considerFieldName, _comp) == 0;
+ return _value.compareWithElement(elt, _comp, _considerFieldName) == 0;
}
private:
const ConstElement _value;
- const bool _considerFieldName;
const StringData::ComparatorInterface* _comp = nullptr;
+ const bool _considerFieldName;
};
// NOTE: Originally, these truly were algorithms, in that they executed the loop over a
diff --git a/src/mongo/bson/mutable/const_element-inl.h b/src/mongo/bson/mutable/const_element-inl.h
index 2d00ec0b797..84a140e0117 100644
--- a/src/mongo/bson/mutable/const_element-inl.h
+++ b/src/mongo/bson/mutable/const_element-inl.h
@@ -164,25 +164,22 @@ inline SafeNum ConstElement::getValueSafeNum() const {
return _basis.getValueSafeNum();
}
-inline int ConstElement::compareWithElement(
- const ConstElement& other,
- bool considerFieldName,
- const StringData::ComparatorInterface* comparator) const {
- return _basis.compareWithElement(other, considerFieldName, comparator);
+inline int ConstElement::compareWithElement(const ConstElement& other,
+ const StringData::ComparatorInterface* comparator,
+ bool considerFieldName) const {
+ return _basis.compareWithElement(other, comparator, considerFieldName);
}
-inline int ConstElement::compareWithBSONElement(
- const BSONElement& other,
- bool considerFieldName,
- const StringData::ComparatorInterface* comparator) const {
- return _basis.compareWithBSONElement(other, considerFieldName, comparator);
+inline int ConstElement::compareWithBSONElement(const BSONElement& other,
+ const StringData::ComparatorInterface* comparator,
+ bool considerFieldName) const {
+ return _basis.compareWithBSONElement(other, comparator, considerFieldName);
}
-inline int ConstElement::compareWithBSONObj(
- const BSONObj& other,
- bool considerFieldName,
- const StringData::ComparatorInterface* comparator) const {
- return _basis.compareWithBSONObj(other, considerFieldName, comparator);
+inline int ConstElement::compareWithBSONObj(const BSONObj& other,
+ const StringData::ComparatorInterface* comparator,
+ bool considerFieldName) const {
+ return _basis.compareWithBSONObj(other, comparator, considerFieldName);
}
inline void ConstElement::writeTo(BSONObjBuilder* builder) const {
diff --git a/src/mongo/bson/mutable/const_element.h b/src/mongo/bson/mutable/const_element.h
index d9798309204..c570f398095 100644
--- a/src/mongo/bson/mutable/const_element.h
+++ b/src/mongo/bson/mutable/const_element.h
@@ -88,20 +88,17 @@ public:
inline bool isValueMaxKey() const;
inline SafeNum getValueSafeNum() const;
- inline int compareWithElement(
- const ConstElement& other,
- bool considerFieldName = true,
- const StringData::ComparatorInterface* comparator = nullptr) const;
-
- inline int compareWithBSONElement(
- const BSONElement& other,
- bool considerFieldName = true,
- const StringData::ComparatorInterface* comparator = nullptr) const;
-
- inline int compareWithBSONObj(
- const BSONObj& other,
- bool considerFieldName = true,
- const StringData::ComparatorInterface* comparator = nullptr) const;
+ inline int compareWithElement(const ConstElement& other,
+ const StringData::ComparatorInterface* comparator,
+ bool considerFieldName = true) const;
+
+ inline int compareWithBSONElement(const BSONElement& other,
+ const StringData::ComparatorInterface* comparator,
+ bool considerFieldName = true) const;
+
+ inline int compareWithBSONObj(const BSONObj& other,
+ const StringData::ComparatorInterface* comparator,
+ bool considerFieldName = true) const;
inline void writeTo(BSONObjBuilder* builder) const;
inline void writeArrayTo(BSONArrayBuilder* builder) const;
diff --git a/src/mongo/bson/mutable/document-inl.h b/src/mongo/bson/mutable/document-inl.h
index 6942283ceb1..e6f9b60ec64 100644
--- a/src/mongo/bson/mutable/document-inl.h
+++ b/src/mongo/bson/mutable/document-inl.h
@@ -31,18 +31,18 @@ namespace mongo {
namespace mutablebson {
inline int Document::compareWith(const Document& other,
- bool considerFieldName,
- const StringData::ComparatorInterface* comparator) const {
+ const StringData::ComparatorInterface* comparator,
+ bool considerFieldName) const {
// We cheat and use Element::compareWithElement since we know that 'other' is a
// Document and has a 'hidden' fieldname that is always indentical across all Document
// instances.
- return root().compareWithElement(other.root(), considerFieldName, comparator);
+ return root().compareWithElement(other.root(), comparator, considerFieldName);
}
inline int Document::compareWithBSONObj(const BSONObj& other,
- bool considerFieldName,
- const StringData::ComparatorInterface* comparator) const {
- return root().compareWithBSONObj(other, considerFieldName, comparator);
+ const StringData::ComparatorInterface* comparator,
+ bool considerFieldName) const {
+ return root().compareWithBSONObj(other, comparator, considerFieldName);
}
inline void Document::writeTo(BSONObjBuilder* builder) const {
diff --git a/src/mongo/bson/mutable/document.cpp b/src/mongo/bson/mutable/document.cpp
index 10817ab0050..ddf1f83281d 100644
--- a/src/mongo/bson/mutable/document.cpp
+++ b/src/mongo/bson/mutable/document.cpp
@@ -1487,8 +1487,8 @@ SafeNum Element::getValueSafeNum() const {
}
int Element::compareWithElement(const ConstElement& other,
- bool considerFieldName,
- const StringData::ComparatorInterface* comparator) const {
+ const StringData::ComparatorInterface* comparator,
+ bool considerFieldName) const {
invariant(ok());
invariant(other.ok());
@@ -1511,14 +1511,14 @@ int Element::compareWithElement(const ConstElement& other,
// in all cases.
if (impl.hasValue(thisRep))
return -other.compareWithBSONElement(
- impl.getSerializedElement(thisRep), considerFieldName, comparator);
+ impl.getSerializedElement(thisRep), comparator, considerFieldName);
const Document::Impl& oimpl = other.getDocument().getImpl();
const ElementRep& otherRep = oimpl.getElementRep(other.getIdx());
if (oimpl.hasValue(otherRep))
return compareWithBSONElement(
- oimpl.getSerializedElement(otherRep), considerFieldName, comparator);
+ oimpl.getSerializedElement(otherRep), comparator, considerFieldName);
// Leaf elements should always have a value, so we should only be dealing with Objects
// or Arrays here.
@@ -1560,7 +1560,7 @@ int Element::compareWithElement(const ConstElement& other,
return 1;
const int result =
- thisIter.compareWithElement(otherIter, considerChildFieldNames, comparator);
+ thisIter.compareWithElement(otherIter, comparator, considerChildFieldNames);
if (result != 0)
return result;
@@ -1570,8 +1570,8 @@ int Element::compareWithElement(const ConstElement& other,
}
int Element::compareWithBSONElement(const BSONElement& other,
- bool considerFieldName,
- const StringData::ComparatorInterface* comparator) const {
+ const StringData::ComparatorInterface* comparator,
+ bool considerFieldName) const {
invariant(ok());
const Document::Impl& impl = getDocument().getImpl();
@@ -1607,12 +1607,12 @@ int Element::compareWithBSONElement(const BSONElement& other,
const bool considerChildFieldNames =
(impl.getType(thisRep) != mongo::Array) && (other.type() != mongo::Array);
- return compareWithBSONObj(other.Obj(), considerChildFieldNames, comparator);
+ return compareWithBSONObj(other.Obj(), comparator, considerChildFieldNames);
}
int Element::compareWithBSONObj(const BSONObj& other,
- bool considerFieldName,
- const StringData::ComparatorInterface* comparator) const {
+ const StringData::ComparatorInterface* comparator,
+ bool considerFieldName) const {
invariant(ok());
const Document::Impl& impl = getDocument().getImpl();
@@ -1634,7 +1634,7 @@ int Element::compareWithBSONObj(const BSONObj& other,
if (otherVal.eoo())
return 1;
- const int result = thisIter.compareWithBSONElement(otherVal, considerFieldName, comparator);
+ const int result = thisIter.compareWithBSONElement(otherVal, comparator, considerFieldName);
if (result != 0)
return result;
diff --git a/src/mongo/bson/mutable/document.h b/src/mongo/bson/mutable/document.h
index 60cbaab3cde..443cee1bebc 100644
--- a/src/mongo/bson/mutable/document.h
+++ b/src/mongo/bson/mutable/document.h
@@ -278,14 +278,13 @@ public:
/** Compare this Document to 'other' with the semantics of BSONObj::woCompare. */
inline int compareWith(const Document& other,
- bool considerFieldName = true,
- const StringData::ComparatorInterface* comparator = nullptr) const;
+ const StringData::ComparatorInterface* comparator,
+ bool considerFieldName = true) const;
/** Compare this Document to 'other' with the semantics of BSONObj::woCompare. */
- inline int compareWithBSONObj(
- const BSONObj& other,
- bool considerFieldName = true,
- const StringData::ComparatorInterface* comparator = nullptr) const;
+ inline int compareWithBSONObj(const BSONObj& other,
+ const StringData::ComparatorInterface* comparator,
+ bool considerFieldName = true) const;
//
diff --git a/src/mongo/bson/mutable/element.h b/src/mongo/bson/mutable/element.h
index 690894b285d..270d990e1ac 100644
--- a/src/mongo/bson/mutable/element.h
+++ b/src/mongo/bson/mutable/element.h
@@ -351,8 +351,8 @@ public:
* Returns 1 if this > other according to BSONElement::woCompare
*/
int compareWithElement(const ConstElement& other,
- bool considerFieldName = true,
- const StringData::ComparatorInterface* comparator = nullptr) const;
+ const StringData::ComparatorInterface* comparator,
+ bool considerFieldName = true) const;
/** Compare this Element with BSONElement 'other'. You should not call this on the root
* Element of the Document because the root Element does not have a field name. Use
@@ -363,8 +363,8 @@ public:
* Returns 1 if this > other according to BSONElement::woCompare
*/
int compareWithBSONElement(const BSONElement& other,
- bool considerFieldName = true,
- const StringData::ComparatorInterface* comparator = nullptr) const;
+ const StringData::ComparatorInterface* comparator,
+ bool considerFieldName = true) const;
/** Compare this Element, which must be an Object or an Array, with 'other'.
*
@@ -373,8 +373,8 @@ public:
* Returns 1 if this object > other according to BSONElement::woCompare
*/
int compareWithBSONObj(const BSONObj& other,
- bool considerFieldName = true,
- const StringData::ComparatorInterface* comparator = nullptr) const;
+ const StringData::ComparatorInterface* comparator,
+ bool considerFieldName = true) const;
//
diff --git a/src/mongo/bson/mutable/mutable_bson_algo_test.cpp b/src/mongo/bson/mutable/mutable_bson_algo_test.cpp
index ade055a543f..727a10689f7 100644
--- a/src/mongo/bson/mutable/mutable_bson_algo_test.cpp
+++ b/src/mongo/bson/mutable/mutable_bson_algo_test.cpp
@@ -311,7 +311,7 @@ TEST_F(CountTest, CountSiblingsMany) {
TEST(DeduplicateTest, ManyDuplicates) {
Document doc(mongo::fromjson("{ x : [ 1, 2, 2, 3, 3, 3, 4, 4, 4 ] }"));
- deduplicateChildren(doc.root().leftChild(), woEqual(false));
+ deduplicateChildren(doc.root().leftChild(), woEqual(nullptr, false));
ASSERT_TRUE(checkDoc(doc, mongo::fromjson("{x : [ 1, 2, 3, 4 ]}")));
}
@@ -336,7 +336,7 @@ TEST(WoLessTest, CollationAware) {
Document less(mongo::fromjson("{ x: 'cbc' }"));
Document greater(mongo::fromjson("{ x: 'abd' }"));
- woLess comp(true, &collator);
+ woLess comp(&collator, true);
ASSERT_TRUE(comp(less.root(), greater.root()));
ASSERT_FALSE(comp(greater.root(), less.root()));
}
@@ -346,7 +346,7 @@ TEST(WoGreaterTest, CollationAware) {
Document less(mongo::fromjson("{ x: 'cbc' }"));
Document greater(mongo::fromjson("{ x: 'abd' }"));
- woGreater comp(true, &collator);
+ woGreater comp(&collator, true);
ASSERT_TRUE(comp(greater.root(), less.root()));
ASSERT_FALSE(comp(less.root(), greater.root()));
}
@@ -356,7 +356,7 @@ TEST(WoEqualTest, CollationAware) {
Document docA(mongo::fromjson("{ x: 'not' }"));
Document docB(mongo::fromjson("{ x: 'equal' }"));
- woEqual comp(true, &collator);
+ woEqual comp(&collator, true);
ASSERT_TRUE(comp(docA.root(), docB.root()));
ASSERT_TRUE(comp(docB.root(), docA.root()));
}
@@ -366,7 +366,7 @@ TEST(WoEqualToTest, CollationAware) {
Document docA(mongo::fromjson("{ x: 'not' }"));
Document docB(mongo::fromjson("{ x: 'equal' }"));
- woEqualTo comp(docA.root(), true, &collator);
+ woEqualTo comp(docA.root(), &collator, true);
ASSERT_TRUE(comp(docB.root()));
}
diff --git a/src/mongo/bson/mutable/mutable_bson_test.cpp b/src/mongo/bson/mutable/mutable_bson_test.cpp
index 3c865cea71a..24629617926 100644
--- a/src/mongo/bson/mutable/mutable_bson_test.cpp
+++ b/src/mongo/bson/mutable/mutable_bson_test.cpp
@@ -3186,10 +3186,10 @@ TEST(DocumentComparison, SimpleComparison) {
mongo::fromjson("{ a : 'a', b : ['b', 'b', 'b'], c : { one : 1.0 } }");
const mmb::Document doc1(obj.getOwned());
- ASSERT_EQUALS(0, doc1.compareWithBSONObj(obj));
+ ASSERT_EQUALS(0, doc1.compareWithBSONObj(obj, nullptr));
const mmb::Document doc2(obj.getOwned());
- ASSERT_EQUALS(0, doc1.compareWith(doc2));
- ASSERT_EQUALS(0, doc2.compareWith(doc1));
+ ASSERT_EQUALS(0, doc1.compareWith(doc2, nullptr));
+ ASSERT_EQUALS(0, doc2.compareWith(doc1, nullptr));
}
TEST(DocumentComparison, SimpleComparisonWithDeserializedElements) {
@@ -3207,10 +3207,10 @@ TEST(DocumentComparison, SimpleComparisonWithDeserializedElements) {
ASSERT_OK(b0.remove());
ASSERT_OK(b.pushBack(b0));
// Ensure that it compares correctly against the source object.
- ASSERT_EQUALS(0, doc1.compareWithBSONObj(obj));
+ ASSERT_EQUALS(0, doc1.compareWithBSONObj(obj, nullptr));
// Ensure that it compares correctly against a pristine document.
- ASSERT_EQUALS(0, doc1.compareWith(doc1Copy));
- ASSERT_EQUALS(0, doc1Copy.compareWith(doc1));
+ ASSERT_EQUALS(0, doc1.compareWith(doc1Copy, nullptr));
+ ASSERT_EQUALS(0, doc1Copy.compareWith(doc1, nullptr));
// Perform an operation on 'c' that doesn't change the serialized value, but
// deserializeds the node.
@@ -3223,14 +3223,14 @@ TEST(DocumentComparison, SimpleComparisonWithDeserializedElements) {
ASSERT_OK(c1.remove());
ASSERT_OK(c.pushBack(c1));
// Ensure that it compares correctly against the source object
- ASSERT_EQUALS(0, doc2.compareWithBSONObj(obj));
+ ASSERT_EQUALS(0, doc2.compareWithBSONObj(obj, nullptr));
// Ensure that it compares correctly against a pristine document.
- ASSERT_EQUALS(0, doc2.compareWith(doc2Copy));
- ASSERT_EQUALS(0, doc2Copy.compareWith(doc2));
+ ASSERT_EQUALS(0, doc2.compareWith(doc2Copy, nullptr));
+ ASSERT_EQUALS(0, doc2Copy.compareWith(doc2, nullptr));
// Ensure that the two deserialized documents compare with each other correctly.
- ASSERT_EQUALS(0, doc1.compareWith(doc2));
- ASSERT_EQUALS(0, doc2.compareWith(doc1));
+ ASSERT_EQUALS(0, doc1.compareWith(doc2, nullptr));
+ ASSERT_EQUALS(0, doc2.compareWith(doc1, nullptr));
}
TEST(DocumentComparison, DocumentCompareWithRespectsCollation) {
@@ -3239,8 +3239,8 @@ TEST(DocumentComparison, DocumentCompareWithRespectsCollation) {
const mmb::Document doc2(mongo::fromjson("{a: 'bar'}"));
// Pass true to indicate that we should compare field names. The two documents should be unequal
// without the collator, but equal when using the "always equal" collator.
- ASSERT_NE(0, doc1.compareWith(doc2, true));
- ASSERT_EQ(0, doc1.compareWith(doc2, true, &collator));
+ ASSERT_NE(0, doc1.compareWith(doc2, nullptr, true));
+ ASSERT_EQ(0, doc1.compareWith(doc2, &collator, true));
}
TEST(DocumentComparison, DocumentCompareWithBSONObjRespectsCollation) {
@@ -3249,8 +3249,8 @@ TEST(DocumentComparison, DocumentCompareWithBSONObjRespectsCollation) {
const mongo::BSONObj doc2 = mongo::fromjson("{a: 'bar'}");
// Pass true to indicate that we should compare field names. The two documents should be unequal
// without the collator, but equal when using the "always equal" collator.
- ASSERT_NE(0, doc1.compareWithBSONObj(doc2, true));
- ASSERT_EQ(0, doc1.compareWithBSONObj(doc2, true, &collator));
+ ASSERT_NE(0, doc1.compareWithBSONObj(doc2, nullptr, true));
+ ASSERT_EQ(0, doc1.compareWithBSONObj(doc2, &collator, true));
}
TEST(DocumentComparison, ElementCompareWithElementRespectsCollator) {
@@ -3261,8 +3261,8 @@ TEST(DocumentComparison, ElementCompareWithElementRespectsCollator) {
const mmb::ConstElement element2 = doc2.root().leftChild();
// Pass true to indicate that we should compare field names. The two documents should be unequal
// without the collator, but equal when using the "always equal" collator.
- ASSERT_NE(0, element1.compareWithElement(element2, true));
- ASSERT_EQ(0, element1.compareWithElement(element2, true, &collator));
+ ASSERT_NE(0, element1.compareWithElement(element2, nullptr, true));
+ ASSERT_EQ(0, element1.compareWithElement(element2, &collator, true));
}
TEST(DocumentComparison, ElementCompareWithBSONElementRespectsCollator) {
@@ -3273,8 +3273,8 @@ TEST(DocumentComparison, ElementCompareWithBSONElementRespectsCollator) {
const mongo::BSONElement element2 = doc2["a"];
// Pass true to indicate that we should compare field names. The two documents should be unequal
// without the collator, but equal when using the "always equal" collator.
- ASSERT_NE(0, element1.compareWithBSONElement(element2, true));
- ASSERT_EQ(0, element1.compareWithBSONElement(element2, true, &collator));
+ ASSERT_NE(0, element1.compareWithBSONElement(element2, nullptr, true));
+ ASSERT_EQ(0, element1.compareWithBSONElement(element2, &collator, true));
}
TEST(DocumentComparison, ElementCompareWithBSONObjRespectsCollator) {
@@ -3284,8 +3284,8 @@ TEST(DocumentComparison, ElementCompareWithBSONObjRespectsCollator) {
const mmb::ConstElement element1 = doc1.root().leftChild();
// Pass true to indicate that we should compare field names. The two documents should be unequal
// without the collator, but equal when using the "always equal" collator.
- ASSERT_NE(0, element1.compareWithBSONObj(doc2, true));
- ASSERT_EQ(0, element1.compareWithBSONObj(doc2, true, &collator));
+ ASSERT_NE(0, element1.compareWithBSONObj(doc2, nullptr, true));
+ ASSERT_EQ(0, element1.compareWithBSONObj(doc2, &collator, true));
}
TEST(DocumentComparison, DocumentCompareWithRespectsCollationRecursively) {
@@ -3294,8 +3294,8 @@ TEST(DocumentComparison, DocumentCompareWithRespectsCollationRecursively) {
const mmb::Document doc2(mongo::fromjson("{a: [{b: 'notFoo'}, {b: 'notBar'}]}"));
// Pass true to indicate that we should compare field names. The two documents should be unequal
// without the collator, but equal when using the "always equal" collator.
- ASSERT_NE(0, doc1.compareWith(doc2, true));
- ASSERT_EQ(0, doc1.compareWith(doc2, true, &collator));
+ ASSERT_NE(0, doc1.compareWith(doc2, nullptr, true));
+ ASSERT_EQ(0, doc1.compareWith(doc2, &collator, true));
}
TEST(DocumentComparison, DocumentCompareWithRespectsCollationWithDeserializedElement) {
@@ -3304,8 +3304,8 @@ TEST(DocumentComparison, DocumentCompareWithRespectsCollationWithDeserializedEle
mmb::Document doc2(mongo::fromjson("{a: ['bar', 'bar']}"));
// With the always equal collator, the documents should start out comparing equal.
- ASSERT_EQ(0, doc1.compareWith(doc2, true, &collator));
- ASSERT_EQ(0, doc2.compareWith(doc1, true, &collator));
+ ASSERT_EQ(0, doc1.compareWith(doc2, &collator, true));
+ ASSERT_EQ(0, doc2.compareWith(doc1, &collator, true));
// They should still be equal after causing deserialization of one of the leaf elements of
// 'doc1'.
@@ -3316,8 +3316,8 @@ TEST(DocumentComparison, DocumentCompareWithRespectsCollationWithDeserializedEle
ASSERT_TRUE(elementA0.ok());
ASSERT_OK(elementA0.remove());
ASSERT_OK(elementA.pushBack(elementA0));
- ASSERT_EQ(0, doc1.compareWith(doc2, true, &collator));
- ASSERT_EQ(0, doc2.compareWith(doc1, true, &collator));
+ ASSERT_EQ(0, doc1.compareWith(doc2, &collator, true));
+ ASSERT_EQ(0, doc2.compareWith(doc1, &collator, true));
}
// And they should remain equal after doing the same to 'doc2'.
@@ -3328,8 +3328,8 @@ TEST(DocumentComparison, DocumentCompareWithRespectsCollationWithDeserializedEle
ASSERT_TRUE(elementA0.ok());
ASSERT_OK(elementA0.remove());
ASSERT_OK(elementA.pushBack(elementA0));
- ASSERT_EQ(0, doc1.compareWith(doc2, true, &collator));
- ASSERT_EQ(0, doc2.compareWith(doc1, true, &collator));
+ ASSERT_EQ(0, doc1.compareWith(doc2, &collator, true));
+ ASSERT_EQ(0, doc2.compareWith(doc1, &collator, true));
}
}
diff --git a/src/mongo/bson/mutable/mutable_bson_test_utils.cpp b/src/mongo/bson/mutable/mutable_bson_test_utils.cpp
index 3102c48eb54..5ad657d66b9 100644
--- a/src/mongo/bson/mutable/mutable_bson_test_utils.cpp
+++ b/src/mongo/bson/mutable/mutable_bson_test_utils.cpp
@@ -142,7 +142,7 @@ bool checkDocNoOrderingImpl(ConstElement lhs, ConstElement rhs) {
} else {
// This is some leaf type. We've already checked or ignored field names, so
// don't recheck it here.
- return lhs.compareWithElement(rhs, false) == 0;
+ return lhs.compareWithElement(rhs, nullptr, false) == 0;
}
}
@@ -158,30 +158,30 @@ bool checkDoc(const Document& lhs, const BSONObj& rhs) {
const int primaryResult = fromLhs.woCompare(rhs);
// Validate primary result via other comparison paths.
- const int secondaryResult = lhs.compareWithBSONObj(rhs);
+ const int secondaryResult = lhs.compareWithBSONObj(rhs, nullptr);
assertSameSign(primaryResult, secondaryResult);
// Check that mutables serialized result matches against its origin.
- ASSERT_EQUALS(0, lhs.compareWithBSONObj(fromLhs));
+ ASSERT_EQUALS(0, lhs.compareWithBSONObj(fromLhs, nullptr));
return (primaryResult == 0);
}
bool checkDoc(const Document& lhs, const Document& rhs) {
- const int primaryResult = lhs.compareWith(rhs);
+ const int primaryResult = lhs.compareWith(rhs, nullptr);
const BSONObj fromLhs = lhs.getObject();
const BSONObj fromRhs = rhs.getObject();
- const int result_d_o = lhs.compareWithBSONObj(fromRhs);
- const int result_o_d = rhs.compareWithBSONObj(fromLhs);
+ const int result_d_o = lhs.compareWithBSONObj(fromRhs, nullptr);
+ const int result_o_d = rhs.compareWithBSONObj(fromLhs, nullptr);
assertSameSign(primaryResult, result_d_o);
assertOppositeSign(primaryResult, result_o_d);
- ASSERT_EQUALS(0, lhs.compareWithBSONObj(fromLhs));
- ASSERT_EQUALS(0, rhs.compareWithBSONObj(fromRhs));
+ ASSERT_EQUALS(0, lhs.compareWithBSONObj(fromLhs, nullptr));
+ ASSERT_EQUALS(0, rhs.compareWithBSONObj(fromRhs, nullptr));
return (primaryResult == 0);
}