summaryrefslogtreecommitdiff
path: root/src/mongo/db/matcher
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/matcher')
-rw-r--r--src/mongo/db/matcher/expression_array.cpp8
-rw-r--r--src/mongo/db/matcher/expression_array_test.cpp53
-rw-r--r--src/mongo/db/matcher/expression_geo.cpp6
-rw-r--r--src/mongo/db/matcher/expression_leaf.cpp8
-rw-r--r--src/mongo/db/matcher/expression_leaf_test.cpp374
-rw-r--r--src/mongo/db/matcher/expression_serialization_test.cpp2
-rw-r--r--src/mongo/db/matcher/expression_text_base.cpp2
-rw-r--r--src/mongo/db/matcher/expression_tree.cpp4
-rw-r--r--src/mongo/db/matcher/expression_tree.h10
-rw-r--r--src/mongo/db/matcher/expression_tree_test.cpp78
-rw-r--r--src/mongo/db/matcher/expression_type_test.cpp74
-rw-r--r--src/mongo/db/matcher/expression_where.cpp4
-rw-r--r--src/mongo/db/matcher/matcher.h2
-rw-r--r--src/mongo/db/matcher/path.cpp2
14 files changed, 314 insertions, 313 deletions
diff --git a/src/mongo/db/matcher/expression_array.cpp b/src/mongo/db/matcher/expression_array.cpp
index af7205ef822..c00d5899eda 100644
--- a/src/mongo/db/matcher/expression_array.cpp
+++ b/src/mongo/db/matcher/expression_array.cpp
@@ -77,7 +77,7 @@ bool ElemMatchObjectMatchExpression::matchesArray(const BSONObj& anArray,
BSONElement inner = i.next();
if (!inner.isABSONObj())
continue;
- if (_sub->matchesBSON(inner.Obj(), NULL)) {
+ if (_sub->matchesBSON(inner.Obj(), nullptr)) {
if (details && details->needRecord()) {
details->setElemMatchKey(inner.fieldName());
}
@@ -92,7 +92,7 @@ void ElemMatchObjectMatchExpression::debugString(StringBuilder& debug, int inden
debug << path() << " $elemMatch (obj)";
MatchExpression::TagData* td = getTag();
- if (NULL != td) {
+ if (nullptr != td) {
debug << " ";
td->debugString(&debug);
}
@@ -165,7 +165,7 @@ void ElemMatchValueMatchExpression::debugString(StringBuilder& debug, int indent
debug << path() << " $elemMatch (value)";
MatchExpression::TagData* td = getTag();
- if (NULL != td) {
+ if (nullptr != td) {
debug << " ";
td->debugString(&debug);
}
@@ -218,7 +218,7 @@ void SizeMatchExpression::debugString(StringBuilder& debug, int indentationLevel
debug << path() << " $size : " << _size << "\n";
MatchExpression::TagData* td = getTag();
- if (NULL != td) {
+ if (nullptr != td) {
debug << " ";
td->debugString(&debug);
}
diff --git a/src/mongo/db/matcher/expression_array_test.cpp b/src/mongo/db/matcher/expression_array_test.cpp
index 6c9ac139edd..40e94ef38ee 100644
--- a/src/mongo/db/matcher/expression_array_test.cpp
+++ b/src/mongo/db/matcher/expression_array_test.cpp
@@ -92,29 +92,30 @@ TEST(ElemMatchObjectMatchExpression, MatchesNonArray) {
ElemMatchObjectMatchExpression op("a", eq.release());
// Directly nested objects are not matched with $elemMatch. An intervening array is
// required.
- ASSERT(!op.matchesBSON(BSON("a" << BSON("b" << 5)), NULL));
- ASSERT(!op.matchesBSON(BSON("a" << BSON("0" << (BSON("b" << 5)))), NULL));
- ASSERT(!op.matchesBSON(BSON("a" << 4), NULL));
+ ASSERT(!op.matchesBSON(BSON("a" << BSON("b" << 5)), nullptr));
+ ASSERT(!op.matchesBSON(BSON("a" << BSON("0" << (BSON("b" << 5)))), nullptr));
+ ASSERT(!op.matchesBSON(BSON("a" << 4), nullptr));
}
TEST(ElemMatchObjectMatchExpression, MatchesArrayObject) {
BSONObj baseOperand = BSON("b" << 5);
unique_ptr<ComparisonMatchExpression> eq(new EqualityMatchExpression("b", baseOperand["b"]));
ElemMatchObjectMatchExpression op("a", eq.release());
- ASSERT(op.matchesBSON(BSON("a" << BSON_ARRAY(BSON("b" << 5))), NULL));
- ASSERT(op.matchesBSON(BSON("a" << BSON_ARRAY(4 << BSON("b" << 5))), NULL));
- ASSERT(op.matchesBSON(BSON("a" << BSON_ARRAY(BSONObj() << BSON("b" << 5))), NULL));
- ASSERT(op.matchesBSON(BSON("a" << BSON_ARRAY(BSON("b" << 6) << BSON("b" << 5))), NULL));
+ ASSERT(op.matchesBSON(BSON("a" << BSON_ARRAY(BSON("b" << 5))), nullptr));
+ ASSERT(op.matchesBSON(BSON("a" << BSON_ARRAY(4 << BSON("b" << 5))), nullptr));
+ ASSERT(op.matchesBSON(BSON("a" << BSON_ARRAY(BSONObj() << BSON("b" << 5))), nullptr));
+ ASSERT(op.matchesBSON(BSON("a" << BSON_ARRAY(BSON("b" << 6) << BSON("b" << 5))), nullptr));
}
TEST(ElemMatchObjectMatchExpression, MatchesMultipleNamedValues) {
BSONObj baseOperand = BSON("c" << 5);
unique_ptr<ComparisonMatchExpression> eq(new EqualityMatchExpression("c", baseOperand["c"]));
ElemMatchObjectMatchExpression op("a.b", eq.release());
- ASSERT(op.matchesBSON(BSON("a" << BSON_ARRAY(BSON("b" << BSON_ARRAY(BSON("c" << 5))))), NULL));
+ ASSERT(
+ op.matchesBSON(BSON("a" << BSON_ARRAY(BSON("b" << BSON_ARRAY(BSON("c" << 5))))), nullptr));
ASSERT(op.matchesBSON(BSON("a" << BSON_ARRAY(BSON("b" << BSON_ARRAY(BSON("c" << 1)))
<< BSON("b" << BSON_ARRAY(BSON("c" << 5))))),
- NULL));
+ nullptr));
}
TEST(ElemMatchObjectMatchExpression, ElemMatchKey) {
@@ -202,27 +203,27 @@ TEST(ElemMatchValueMatchExpression, MatchesNonArray) {
ElemMatchObjectMatchExpression op("a", gt.release());
// Directly nested objects are not matched with $elemMatch. An intervening array is
// required.
- ASSERT(!op.matchesBSON(BSON("a" << 6), NULL));
- ASSERT(!op.matchesBSON(BSON("a" << BSON("0" << 6)), NULL));
+ ASSERT(!op.matchesBSON(BSON("a" << 6), nullptr));
+ ASSERT(!op.matchesBSON(BSON("a" << BSON("0" << 6)), nullptr));
}
TEST(ElemMatchValueMatchExpression, MatchesArrayScalar) {
BSONObj baseOperand = BSON("$gt" << 5);
unique_ptr<ComparisonMatchExpression> gt(new GTMatchExpression("", baseOperand["$gt"]));
ElemMatchValueMatchExpression op("a", gt.release());
- ASSERT(op.matchesBSON(BSON("a" << BSON_ARRAY(6)), NULL));
- ASSERT(op.matchesBSON(BSON("a" << BSON_ARRAY(4 << 6)), NULL));
- ASSERT(op.matchesBSON(BSON("a" << BSON_ARRAY(BSONObj() << 7)), NULL));
+ ASSERT(op.matchesBSON(BSON("a" << BSON_ARRAY(6)), nullptr));
+ ASSERT(op.matchesBSON(BSON("a" << BSON_ARRAY(4 << 6)), nullptr));
+ ASSERT(op.matchesBSON(BSON("a" << BSON_ARRAY(BSONObj() << 7)), nullptr));
}
TEST(ElemMatchValueMatchExpression, MatchesMultipleNamedValues) {
BSONObj baseOperand = BSON("$gt" << 5);
unique_ptr<ComparisonMatchExpression> gt(new GTMatchExpression("", baseOperand["$gt"]));
ElemMatchValueMatchExpression op("a.b", gt.release());
- ASSERT(op.matchesBSON(BSON("a" << BSON_ARRAY(BSON("b" << BSON_ARRAY(6)))), NULL));
+ ASSERT(op.matchesBSON(BSON("a" << BSON_ARRAY(BSON("b" << BSON_ARRAY(6)))), nullptr));
ASSERT(op.matchesBSON(
BSON("a" << BSON_ARRAY(BSON("b" << BSON_ARRAY(4)) << BSON("b" << BSON_ARRAY(4 << 6)))),
- NULL));
+ nullptr));
}
TEST(ElemMatchValueMatchExpression, ElemMatchKey) {
@@ -345,19 +346,19 @@ TEST(AndOfElemMatch, Matches) {
andOfEM->add(elemMatch2.release());
BSONObj nonArray = BSON("x" << 4);
- ASSERT(!andOfEM->matchesBSON(nonArray, NULL));
+ ASSERT(!andOfEM->matchesBSON(nonArray, nullptr));
BSONObj emptyArray = BSON("x" << BSONArray());
- ASSERT(!andOfEM->matchesBSON(emptyArray, NULL));
+ ASSERT(!andOfEM->matchesBSON(emptyArray, nullptr));
BSONObj nonNumberArray = BSON("x" << BSON_ARRAY("q"));
- ASSERT(!andOfEM->matchesBSON(nonNumberArray, NULL));
+ ASSERT(!andOfEM->matchesBSON(nonNumberArray, nullptr));
BSONObj singleMatch = BSON("x" << BSON_ARRAY(5));
- ASSERT(!andOfEM->matchesBSON(singleMatch, NULL));
+ ASSERT(!andOfEM->matchesBSON(singleMatch, nullptr));
BSONObj otherMatch = BSON("x" << BSON_ARRAY(105));
- ASSERT(!andOfEM->matchesBSON(otherMatch, NULL));
+ ASSERT(!andOfEM->matchesBSON(otherMatch, nullptr));
BSONObj bothMatch = BSON("x" << BSON_ARRAY(5 << 105));
- ASSERT(andOfEM->matchesBSON(bothMatch, NULL));
+ ASSERT(andOfEM->matchesBSON(bothMatch, nullptr));
BSONObj neitherMatch = BSON("x" << BSON_ARRAY(0 << 200));
- ASSERT(!andOfEM->matchesBSON(neitherMatch, NULL));
+ ASSERT(!andOfEM->matchesBSON(neitherMatch, nullptr));
}
TEST(SizeMatchExpression, MatchesElement) {
@@ -382,15 +383,15 @@ TEST(SizeMatchExpression, MatchesNonArray) {
TEST(SizeMatchExpression, MatchesArray) {
SizeMatchExpression size("a", 2);
- ASSERT(size.matchesBSON(BSON("a" << BSON_ARRAY(4 << 5.5)), NULL));
+ ASSERT(size.matchesBSON(BSON("a" << BSON_ARRAY(4 << 5.5)), nullptr));
// Arrays are not unwound to look for matching subarrays.
- ASSERT(!size.matchesBSON(BSON("a" << BSON_ARRAY(4 << 5.5 << BSON_ARRAY(1 << 2))), NULL));
+ ASSERT(!size.matchesBSON(BSON("a" << BSON_ARRAY(4 << 5.5 << BSON_ARRAY(1 << 2))), nullptr));
}
TEST(SizeMatchExpression, MatchesNestedArray) {
SizeMatchExpression size("a.2", 2);
// A numerically referenced nested array is matched.
- ASSERT(size.matchesBSON(BSON("a" << BSON_ARRAY(4 << 5.5 << BSON_ARRAY(1 << 2))), NULL));
+ ASSERT(size.matchesBSON(BSON("a" << BSON_ARRAY(4 << 5.5 << BSON_ARRAY(1 << 2))), nullptr));
}
TEST(SizeMatchExpression, ElemMatchKey) {
diff --git a/src/mongo/db/matcher/expression_geo.cpp b/src/mongo/db/matcher/expression_geo.cpp
index 18e38b319f0..67ee37060d7 100644
--- a/src/mongo/db/matcher/expression_geo.cpp
+++ b/src/mongo/db/matcher/expression_geo.cpp
@@ -89,7 +89,7 @@ Status GeoExpression::parseQuery(const BSONObj& obj) {
}
}
- if (geoContainer == NULL) {
+ if (geoContainer == nullptr) {
return Status(ErrorCodes::BadValue, "geo query doesn't have any geometry");
}
@@ -376,7 +376,7 @@ void GeoMatchExpression::debugString(StringBuilder& debug, int indentationLevel)
debug << "GEO raw = " << builder.obj().toString();
MatchExpression::TagData* td = getTag();
- if (NULL != td) {
+ if (nullptr != td) {
debug << " ";
td->debugString(&debug);
}
@@ -434,7 +434,7 @@ void GeoNearMatchExpression::debugString(StringBuilder& debug, int indentationLe
_debugAddSpace(debug, indentationLevel);
debug << "GEONEAR " << _query->toString();
MatchExpression::TagData* td = getTag();
- if (NULL != td) {
+ if (nullptr != td) {
debug << " ";
td->debugString(&debug);
}
diff --git a/src/mongo/db/matcher/expression_leaf.cpp b/src/mongo/db/matcher/expression_leaf.cpp
index ee43237617e..3001eb59ba8 100644
--- a/src/mongo/db/matcher/expression_leaf.cpp
+++ b/src/mongo/db/matcher/expression_leaf.cpp
@@ -263,7 +263,7 @@ void RegexMatchExpression::debugString(StringBuilder& debug, int indentationLeve
debug << path() << " regex /" << _regex << "/" << _flags;
MatchExpression::TagData* td = getTag();
- if (NULL != td) {
+ if (nullptr != td) {
debug << " ";
td->debugString(&debug);
}
@@ -306,7 +306,7 @@ void ModMatchExpression::debugString(StringBuilder& debug, int indentationLevel)
_debugAddSpace(debug, indentationLevel);
debug << path() << " mod " << _divisor << " % x == " << _remainder;
MatchExpression::TagData* td = getTag();
- if (NULL != td) {
+ if (nullptr != td) {
debug << " ";
td->debugString(&debug);
}
@@ -340,7 +340,7 @@ void ExistsMatchExpression::debugString(StringBuilder& debug, int indentationLev
_debugAddSpace(debug, indentationLevel);
debug << path() << " exists";
MatchExpression::TagData* td = getTag();
- if (NULL != td) {
+ if (nullptr != td) {
debug << " ";
td->debugString(&debug);
}
@@ -416,7 +416,7 @@ void InMatchExpression::debugString(StringBuilder& debug, int indentationLevel)
}
debug << "]";
MatchExpression::TagData* td = getTag();
- if (NULL != td) {
+ if (nullptr != td) {
debug << " ";
td->debugString(&debug);
}
diff --git a/src/mongo/db/matcher/expression_leaf_test.cpp b/src/mongo/db/matcher/expression_leaf_test.cpp
index bb06d26b7f7..859fbe3bc98 100644
--- a/src/mongo/db/matcher/expression_leaf_test.cpp
+++ b/src/mongo/db/matcher/expression_leaf_test.cpp
@@ -71,7 +71,7 @@ TEST(ComparisonMatchExpression, StringMatchingWithNullCollatorUsesBinaryComparis
EqualityMatchExpression eq("a", operand["a"]);
ASSERT(!eq.matchesBSON(BSON("a"
<< "string2"),
- NULL));
+ nullptr));
}
TEST(ComparisonMatchExpression, StringMatchingRespectsCollation) {
@@ -82,7 +82,7 @@ TEST(ComparisonMatchExpression, StringMatchingRespectsCollation) {
eq.setCollator(&collator);
ASSERT(eq.matchesBSON(BSON("a"
<< "string2"),
- NULL));
+ nullptr));
}
TEST(EqOp, MatchesElement) {
@@ -105,40 +105,40 @@ DEATH_TEST(EqOp, InvalidEooOperand, "Invariant failure _rhs") {
TEST(EqOp, MatchesScalar) {
BSONObj operand = BSON("a" << 5);
EqualityMatchExpression eq("a", operand["a"]);
- ASSERT(eq.matchesBSON(BSON("a" << 5.0), NULL));
- ASSERT(!eq.matchesBSON(BSON("a" << 4), NULL));
+ ASSERT(eq.matchesBSON(BSON("a" << 5.0), nullptr));
+ ASSERT(!eq.matchesBSON(BSON("a" << 4), nullptr));
}
TEST(EqOp, MatchesArrayValue) {
BSONObj operand = BSON("a" << 5);
EqualityMatchExpression eq("a", operand["a"]);
- ASSERT(eq.matchesBSON(BSON("a" << BSON_ARRAY(5.0 << 6)), NULL));
- ASSERT(!eq.matchesBSON(BSON("a" << BSON_ARRAY(6 << 7)), NULL));
+ ASSERT(eq.matchesBSON(BSON("a" << BSON_ARRAY(5.0 << 6)), nullptr));
+ ASSERT(!eq.matchesBSON(BSON("a" << BSON_ARRAY(6 << 7)), nullptr));
}
TEST(EqOp, MatchesReferencedObjectValue) {
BSONObj operand = BSON("a.b" << 5);
EqualityMatchExpression eq("a.b", operand["a.b"]);
- ASSERT(eq.matchesBSON(BSON("a" << BSON("b" << 5)), NULL));
- ASSERT(eq.matchesBSON(BSON("a" << BSON("b" << BSON_ARRAY(5))), NULL));
- ASSERT(eq.matchesBSON(BSON("a" << BSON_ARRAY(BSON("b" << 5))), NULL));
+ ASSERT(eq.matchesBSON(BSON("a" << BSON("b" << 5)), nullptr));
+ ASSERT(eq.matchesBSON(BSON("a" << BSON("b" << BSON_ARRAY(5))), nullptr));
+ ASSERT(eq.matchesBSON(BSON("a" << BSON_ARRAY(BSON("b" << 5))), nullptr));
}
TEST(EqOp, MatchesReferencedArrayValue) {
BSONObj operand = BSON("a.0" << 5);
EqualityMatchExpression eq("a.0", operand["a.0"]);
- ASSERT(eq.matchesBSON(BSON("a" << BSON_ARRAY(5)), NULL));
- ASSERT(!eq.matchesBSON(BSON("a" << BSON_ARRAY(BSON_ARRAY(5))), NULL));
+ ASSERT(eq.matchesBSON(BSON("a" << BSON_ARRAY(5)), nullptr));
+ ASSERT(!eq.matchesBSON(BSON("a" << BSON_ARRAY(BSON_ARRAY(5))), nullptr));
}
TEST(EqOp, MatchesNull) {
BSONObj operand = BSON("a" << BSONNULL);
EqualityMatchExpression eq("a", operand["a"]);
- ASSERT(eq.matchesBSON(BSONObj(), NULL));
- ASSERT(eq.matchesBSON(BSON("a" << BSONNULL), NULL));
- ASSERT(!eq.matchesBSON(BSON("a" << 4), NULL));
+ ASSERT(eq.matchesBSON(BSONObj(), nullptr));
+ ASSERT(eq.matchesBSON(BSON("a" << BSONNULL), nullptr));
+ ASSERT(!eq.matchesBSON(BSON("a" << 4), nullptr));
// A non-existent field is treated same way as an empty bson object
- ASSERT(eq.matchesBSON(BSON("b" << 4), NULL));
+ ASSERT(eq.matchesBSON(BSON("b" << 4), nullptr));
}
// This test documents how the matcher currently works,
@@ -147,19 +147,19 @@ TEST(EqOp, MatchesNestedNull) {
BSONObj operand = BSON("a.b" << BSONNULL);
EqualityMatchExpression eq("a.b", operand["a.b"]);
// null matches any empty object that is on a subpath of a.b
- ASSERT(eq.matchesBSON(BSONObj(), NULL));
- ASSERT(eq.matchesBSON(BSON("a" << BSONObj()), NULL));
- ASSERT(eq.matchesBSON(BSON("a" << BSON_ARRAY(BSONObj())), NULL));
- ASSERT(eq.matchesBSON(BSON("a" << BSON("b" << BSONNULL)), NULL));
+ ASSERT(eq.matchesBSON(BSONObj(), nullptr));
+ ASSERT(eq.matchesBSON(BSON("a" << BSONObj()), nullptr));
+ ASSERT(eq.matchesBSON(BSON("a" << BSON_ARRAY(BSONObj())), nullptr));
+ ASSERT(eq.matchesBSON(BSON("a" << BSON("b" << BSONNULL)), nullptr));
// b does not exist as an element in array under a.
- ASSERT(!eq.matchesBSON(BSON("a" << BSONArray()), NULL));
- ASSERT(!eq.matchesBSON(BSON("a" << BSON_ARRAY(BSONNULL)), NULL));
- ASSERT(!eq.matchesBSON(BSON("a" << BSON_ARRAY(1 << 2)), NULL));
+ ASSERT(!eq.matchesBSON(BSON("a" << BSONArray()), nullptr));
+ ASSERT(!eq.matchesBSON(BSON("a" << BSON_ARRAY(BSONNULL)), nullptr));
+ ASSERT(!eq.matchesBSON(BSON("a" << BSON_ARRAY(1 << 2)), nullptr));
// a.b exists but is not null.
- ASSERT(!eq.matchesBSON(BSON("a" << BSON("b" << 4)), NULL));
- ASSERT(!eq.matchesBSON(BSON("a" << BSON("b" << BSONObj())), NULL));
+ ASSERT(!eq.matchesBSON(BSON("a" << BSON("b" << 4)), nullptr));
+ ASSERT(!eq.matchesBSON(BSON("a" << BSON("b" << BSONObj())), nullptr));
// A non-existent field is treated same way as an empty bson object
- ASSERT(eq.matchesBSON(BSON("b" << 4), NULL));
+ ASSERT(eq.matchesBSON(BSON("b" << 4), nullptr));
}
TEST(EqOp, MatchesMinKey) {
@@ -169,9 +169,9 @@ TEST(EqOp, MatchesMinKey) {
BSONObj maxKeyObj = BSON("a" << MaxKey);
BSONObj numObj = BSON("a" << 4);
- ASSERT(eq.matchesBSON(minKeyObj, NULL));
- ASSERT(!eq.matchesBSON(maxKeyObj, NULL));
- ASSERT(!eq.matchesBSON(numObj, NULL));
+ ASSERT(eq.matchesBSON(minKeyObj, nullptr));
+ ASSERT(!eq.matchesBSON(maxKeyObj, nullptr));
+ ASSERT(!eq.matchesBSON(numObj, nullptr));
ASSERT(eq.matchesSingleElement(minKeyObj.firstElement()));
ASSERT(!eq.matchesSingleElement(maxKeyObj.firstElement()));
@@ -186,9 +186,9 @@ TEST(EqOp, MatchesMaxKey) {
BSONObj maxKeyObj = BSON("a" << MaxKey);
BSONObj numObj = BSON("a" << 4);
- ASSERT(!eq.matchesBSON(minKeyObj, NULL));
- ASSERT(eq.matchesBSON(maxKeyObj, NULL));
- ASSERT(!eq.matchesBSON(numObj, NULL));
+ ASSERT(!eq.matchesBSON(minKeyObj, nullptr));
+ ASSERT(eq.matchesBSON(maxKeyObj, nullptr));
+ ASSERT(!eq.matchesBSON(numObj, nullptr));
ASSERT(!eq.matchesSingleElement(minKeyObj.firstElement()));
ASSERT(eq.matchesSingleElement(maxKeyObj.firstElement()));
@@ -198,17 +198,17 @@ TEST(EqOp, MatchesMaxKey) {
TEST(EqOp, MatchesFullArray) {
BSONObj operand = BSON("a" << BSON_ARRAY(1 << 2));
EqualityMatchExpression eq("a", operand["a"]);
- ASSERT(eq.matchesBSON(BSON("a" << BSON_ARRAY(1 << 2)), NULL));
- ASSERT(!eq.matchesBSON(BSON("a" << BSON_ARRAY(1 << 2 << 3)), NULL));
- ASSERT(!eq.matchesBSON(BSON("a" << BSON_ARRAY(1)), NULL));
- ASSERT(!eq.matchesBSON(BSON("a" << 1), NULL));
+ ASSERT(eq.matchesBSON(BSON("a" << BSON_ARRAY(1 << 2)), nullptr));
+ ASSERT(!eq.matchesBSON(BSON("a" << BSON_ARRAY(1 << 2 << 3)), nullptr));
+ ASSERT(!eq.matchesBSON(BSON("a" << BSON_ARRAY(1)), nullptr));
+ ASSERT(!eq.matchesBSON(BSON("a" << 1), nullptr));
}
TEST(EqOp, MatchesThroughNestedArray) {
BSONObj operand = BSON("a.b.c.d" << 3);
EqualityMatchExpression eq("a.b.c.d", operand["a.b.c.d"]);
BSONObj obj = fromjson("{a:{b:[{c:[{d:1},{d:2}]},{c:[{d:3}]}]}}");
- ASSERT(eq.matchesBSON(obj, NULL));
+ ASSERT(eq.matchesBSON(obj, nullptr));
}
TEST(EqOp, ElemMatchKey) {
@@ -273,57 +273,57 @@ DEATH_TEST(LtOp, InvalidEooOperand, "Invariant failure _rhs") {
TEST(LtOp, MatchesScalar) {
BSONObj operand = BSON("$lt" << 5);
LTMatchExpression lt("a", operand["$lt"]);
- ASSERT(lt.matchesBSON(BSON("a" << 4.5), NULL));
- ASSERT(!lt.matchesBSON(BSON("a" << 6), NULL));
+ ASSERT(lt.matchesBSON(BSON("a" << 4.5), nullptr));
+ ASSERT(!lt.matchesBSON(BSON("a" << 6), nullptr));
}
TEST(LtOp, MatchesScalarEmptyKey) {
BSONObj operand = BSON("$lt" << 5);
LTMatchExpression lt("", operand["$lt"]);
- ASSERT(lt.matchesBSON(BSON("" << 4.5), NULL));
- ASSERT(!lt.matchesBSON(BSON("" << 6), NULL));
+ ASSERT(lt.matchesBSON(BSON("" << 4.5), nullptr));
+ ASSERT(!lt.matchesBSON(BSON("" << 6), nullptr));
}
TEST(LtOp, MatchesArrayValue) {
BSONObj operand = BSON("$lt" << 5);
LTMatchExpression lt("a", operand["$lt"]);
- ASSERT(lt.matchesBSON(BSON("a" << BSON_ARRAY(6 << 4.5)), NULL));
- ASSERT(!lt.matchesBSON(BSON("a" << BSON_ARRAY(6 << 7)), NULL));
+ ASSERT(lt.matchesBSON(BSON("a" << BSON_ARRAY(6 << 4.5)), nullptr));
+ ASSERT(!lt.matchesBSON(BSON("a" << BSON_ARRAY(6 << 7)), nullptr));
}
TEST(LtOp, MatchesWholeArray) {
BSONObj operand = BSON("$lt" << BSON_ARRAY(5));
LTMatchExpression lt("a", operand["$lt"]);
- ASSERT(lt.matchesBSON(BSON("a" << BSON_ARRAY(4)), NULL));
- ASSERT(!lt.matchesBSON(BSON("a" << BSON_ARRAY(5)), NULL));
- ASSERT(!lt.matchesBSON(BSON("a" << BSON_ARRAY(6)), NULL));
+ ASSERT(lt.matchesBSON(BSON("a" << BSON_ARRAY(4)), nullptr));
+ ASSERT(!lt.matchesBSON(BSON("a" << BSON_ARRAY(5)), nullptr));
+ ASSERT(!lt.matchesBSON(BSON("a" << BSON_ARRAY(6)), nullptr));
// Nested array.
- ASSERT(lt.matchesBSON(BSON("a" << BSON_ARRAY(BSON_ARRAY(4))), NULL));
- ASSERT(!lt.matchesBSON(BSON("a" << BSON_ARRAY(BSON_ARRAY(5))), NULL));
- ASSERT(!lt.matchesBSON(BSON("a" << BSON_ARRAY(BSON_ARRAY(6))), NULL));
+ ASSERT(lt.matchesBSON(BSON("a" << BSON_ARRAY(BSON_ARRAY(4))), nullptr));
+ ASSERT(!lt.matchesBSON(BSON("a" << BSON_ARRAY(BSON_ARRAY(5))), nullptr));
+ ASSERT(!lt.matchesBSON(BSON("a" << BSON_ARRAY(BSON_ARRAY(6))), nullptr));
}
TEST(LtOp, MatchesNull) {
BSONObj operand = BSON("$lt" << BSONNULL);
LTMatchExpression lt("a", operand["$lt"]);
- ASSERT(!lt.matchesBSON(BSONObj(), NULL));
- ASSERT(!lt.matchesBSON(BSON("a" << BSONNULL), NULL));
- ASSERT(!lt.matchesBSON(BSON("a" << 4), NULL));
+ ASSERT(!lt.matchesBSON(BSONObj(), nullptr));
+ ASSERT(!lt.matchesBSON(BSON("a" << BSONNULL), nullptr));
+ ASSERT(!lt.matchesBSON(BSON("a" << 4), nullptr));
// A non-existent field is treated same way as an empty bson object
- ASSERT(!lt.matchesBSON(BSON("b" << 4), NULL));
+ ASSERT(!lt.matchesBSON(BSON("b" << 4), nullptr));
}
TEST(LtOp, MatchesDotNotationNull) {
BSONObj operand = BSON("$lt" << BSONNULL);
LTMatchExpression lt("a.b", operand["$lt"]);
- ASSERT(!lt.matchesBSON(BSONObj(), NULL));
- ASSERT(!lt.matchesBSON(BSON("a" << BSONNULL), NULL));
- ASSERT(!lt.matchesBSON(BSON("a" << 4), NULL));
- ASSERT(!lt.matchesBSON(BSON("a" << BSONObj()), NULL));
- ASSERT(!lt.matchesBSON(BSON("a" << BSON_ARRAY(BSON("b" << BSONNULL))), NULL));
- ASSERT(!lt.matchesBSON(BSON("a" << BSON_ARRAY(BSON("a" << 4) << BSON("b" << 4))), NULL));
- ASSERT(!lt.matchesBSON(BSON("a" << BSON_ARRAY(4)), NULL));
- ASSERT(!lt.matchesBSON(BSON("a" << BSON_ARRAY(BSON("b" << 4))), NULL));
+ ASSERT(!lt.matchesBSON(BSONObj(), nullptr));
+ ASSERT(!lt.matchesBSON(BSON("a" << BSONNULL), nullptr));
+ ASSERT(!lt.matchesBSON(BSON("a" << 4), nullptr));
+ ASSERT(!lt.matchesBSON(BSON("a" << BSONObj()), nullptr));
+ ASSERT(!lt.matchesBSON(BSON("a" << BSON_ARRAY(BSON("b" << BSONNULL))), nullptr));
+ ASSERT(!lt.matchesBSON(BSON("a" << BSON_ARRAY(BSON("a" << 4) << BSON("b" << 4))), nullptr));
+ ASSERT(!lt.matchesBSON(BSON("a" << BSON_ARRAY(4)), nullptr));
+ ASSERT(!lt.matchesBSON(BSON("a" << BSON_ARRAY(BSON("b" << 4))), nullptr));
}
TEST(LtOp, MatchesMinKey) {
@@ -333,9 +333,9 @@ TEST(LtOp, MatchesMinKey) {
BSONObj maxKeyObj = BSON("a" << MaxKey);
BSONObj numObj = BSON("a" << 4);
- ASSERT(!lt.matchesBSON(minKeyObj, NULL));
- ASSERT(!lt.matchesBSON(maxKeyObj, NULL));
- ASSERT(!lt.matchesBSON(numObj, NULL));
+ ASSERT(!lt.matchesBSON(minKeyObj, nullptr));
+ ASSERT(!lt.matchesBSON(maxKeyObj, nullptr));
+ ASSERT(!lt.matchesBSON(numObj, nullptr));
ASSERT(!lt.matchesSingleElement(minKeyObj.firstElement()));
ASSERT(!lt.matchesSingleElement(maxKeyObj.firstElement()));
@@ -349,9 +349,9 @@ TEST(LtOp, MatchesMaxKey) {
BSONObj maxKeyObj = BSON("a" << MaxKey);
BSONObj numObj = BSON("a" << 4);
- ASSERT(lt.matchesBSON(minKeyObj, NULL));
- ASSERT(!lt.matchesBSON(maxKeyObj, NULL));
- ASSERT(lt.matchesBSON(numObj, NULL));
+ ASSERT(lt.matchesBSON(minKeyObj, nullptr));
+ ASSERT(!lt.matchesBSON(maxKeyObj, nullptr));
+ ASSERT(lt.matchesBSON(numObj, nullptr));
ASSERT(lt.matchesSingleElement(minKeyObj.firstElement()));
ASSERT(!lt.matchesSingleElement(maxKeyObj.firstElement()));
@@ -394,50 +394,50 @@ DEATH_TEST(LteOp, InvalidEooOperand, "Invariant failure _rhs") {
TEST(LteOp, MatchesScalar) {
BSONObj operand = BSON("$lte" << 5);
LTEMatchExpression lte("a", operand["$lte"]);
- ASSERT(lte.matchesBSON(BSON("a" << 4.5), NULL));
- ASSERT(!lte.matchesBSON(BSON("a" << 6), NULL));
+ ASSERT(lte.matchesBSON(BSON("a" << 4.5), nullptr));
+ ASSERT(!lte.matchesBSON(BSON("a" << 6), nullptr));
}
TEST(LteOp, MatchesArrayValue) {
BSONObj operand = BSON("$lte" << 5);
LTEMatchExpression lte("a", operand["$lte"]);
- ASSERT(lte.matchesBSON(BSON("a" << BSON_ARRAY(6 << 4.5)), NULL));
- ASSERT(!lte.matchesBSON(BSON("a" << BSON_ARRAY(6 << 7)), NULL));
+ ASSERT(lte.matchesBSON(BSON("a" << BSON_ARRAY(6 << 4.5)), nullptr));
+ ASSERT(!lte.matchesBSON(BSON("a" << BSON_ARRAY(6 << 7)), nullptr));
}
TEST(LteOp, MatchesWholeArray) {
BSONObj operand = BSON("$lte" << BSON_ARRAY(5));
LTEMatchExpression lte("a", operand["$lte"]);
- ASSERT(lte.matchesBSON(BSON("a" << BSON_ARRAY(4)), NULL));
- ASSERT(lte.matchesBSON(BSON("a" << BSON_ARRAY(5)), NULL));
- ASSERT(!lte.matchesBSON(BSON("a" << BSON_ARRAY(6)), NULL));
+ ASSERT(lte.matchesBSON(BSON("a" << BSON_ARRAY(4)), nullptr));
+ ASSERT(lte.matchesBSON(BSON("a" << BSON_ARRAY(5)), nullptr));
+ ASSERT(!lte.matchesBSON(BSON("a" << BSON_ARRAY(6)), nullptr));
// Nested array.
- ASSERT(lte.matchesBSON(BSON("a" << BSON_ARRAY(BSON_ARRAY(4))), NULL));
- ASSERT(lte.matchesBSON(BSON("a" << BSON_ARRAY(BSON_ARRAY(5))), NULL));
- ASSERT(!lte.matchesBSON(BSON("a" << BSON_ARRAY(BSON_ARRAY(6))), NULL));
+ ASSERT(lte.matchesBSON(BSON("a" << BSON_ARRAY(BSON_ARRAY(4))), nullptr));
+ ASSERT(lte.matchesBSON(BSON("a" << BSON_ARRAY(BSON_ARRAY(5))), nullptr));
+ ASSERT(!lte.matchesBSON(BSON("a" << BSON_ARRAY(BSON_ARRAY(6))), nullptr));
}
TEST(LteOp, MatchesNull) {
BSONObj operand = BSON("$lte" << BSONNULL);
LTEMatchExpression lte("a", operand["$lte"]);
- ASSERT(lte.matchesBSON(BSONObj(), NULL));
- ASSERT(lte.matchesBSON(BSON("a" << BSONNULL), NULL));
- ASSERT(!lte.matchesBSON(BSON("a" << 4), NULL));
+ ASSERT(lte.matchesBSON(BSONObj(), nullptr));
+ ASSERT(lte.matchesBSON(BSON("a" << BSONNULL), nullptr));
+ ASSERT(!lte.matchesBSON(BSON("a" << 4), nullptr));
// A non-existent field is treated same way as an empty bson object
- ASSERT(lte.matchesBSON(BSON("b" << 4), NULL));
+ ASSERT(lte.matchesBSON(BSON("b" << 4), nullptr));
}
TEST(LteOp, MatchesDotNotationNull) {
BSONObj operand = BSON("$lte" << BSONNULL);
LTEMatchExpression lte("a.b", operand["$lte"]);
- ASSERT(lte.matchesBSON(BSONObj(), NULL));
- ASSERT(lte.matchesBSON(BSON("a" << BSONNULL), NULL));
- ASSERT(lte.matchesBSON(BSON("a" << 4), NULL));
- ASSERT(lte.matchesBSON(BSON("a" << BSONObj()), NULL));
- ASSERT(lte.matchesBSON(BSON("a" << BSON_ARRAY(BSON("b" << BSONNULL))), NULL));
- ASSERT(lte.matchesBSON(BSON("a" << BSON_ARRAY(BSON("a" << 4) << BSON("b" << 4))), NULL));
- ASSERT(!lte.matchesBSON(BSON("a" << BSON_ARRAY(4)), NULL));
- ASSERT(!lte.matchesBSON(BSON("a" << BSON_ARRAY(BSON("b" << 4))), NULL));
+ ASSERT(lte.matchesBSON(BSONObj(), nullptr));
+ ASSERT(lte.matchesBSON(BSON("a" << BSONNULL), nullptr));
+ ASSERT(lte.matchesBSON(BSON("a" << 4), nullptr));
+ ASSERT(lte.matchesBSON(BSON("a" << BSONObj()), nullptr));
+ ASSERT(lte.matchesBSON(BSON("a" << BSON_ARRAY(BSON("b" << BSONNULL))), nullptr));
+ ASSERT(lte.matchesBSON(BSON("a" << BSON_ARRAY(BSON("a" << 4) << BSON("b" << 4))), nullptr));
+ ASSERT(!lte.matchesBSON(BSON("a" << BSON_ARRAY(4)), nullptr));
+ ASSERT(!lte.matchesBSON(BSON("a" << BSON_ARRAY(BSON("b" << 4))), nullptr));
}
TEST(LteOp, MatchesMinKey) {
@@ -447,9 +447,9 @@ TEST(LteOp, MatchesMinKey) {
BSONObj maxKeyObj = BSON("a" << MaxKey);
BSONObj numObj = BSON("a" << 4);
- ASSERT(lte.matchesBSON(minKeyObj, NULL));
- ASSERT(!lte.matchesBSON(maxKeyObj, NULL));
- ASSERT(!lte.matchesBSON(numObj, NULL));
+ ASSERT(lte.matchesBSON(minKeyObj, nullptr));
+ ASSERT(!lte.matchesBSON(maxKeyObj, nullptr));
+ ASSERT(!lte.matchesBSON(numObj, nullptr));
ASSERT(lte.matchesSingleElement(minKeyObj.firstElement()));
ASSERT(!lte.matchesSingleElement(maxKeyObj.firstElement()));
@@ -463,9 +463,9 @@ TEST(LteOp, MatchesMaxKey) {
BSONObj maxKeyObj = BSON("a" << MaxKey);
BSONObj numObj = BSON("a" << 4);
- ASSERT(lte.matchesBSON(minKeyObj, NULL));
- ASSERT(lte.matchesBSON(maxKeyObj, NULL));
- ASSERT(lte.matchesBSON(numObj, NULL));
+ ASSERT(lte.matchesBSON(minKeyObj, nullptr));
+ ASSERT(lte.matchesBSON(maxKeyObj, nullptr));
+ ASSERT(lte.matchesBSON(numObj, nullptr));
ASSERT(lte.matchesSingleElement(minKeyObj.firstElement()));
ASSERT(lte.matchesSingleElement(maxKeyObj.firstElement()));
@@ -495,52 +495,52 @@ DEATH_TEST(GtOp, InvalidEooOperand, "Invariant failure _rhs") {
TEST(GtOp, MatchesScalar) {
BSONObj operand = BSON("$gt" << 5);
GTMatchExpression gt("a", operand["$gt"]);
- ASSERT(gt.matchesBSON(BSON("a" << 5.5), NULL));
- ASSERT(!gt.matchesBSON(BSON("a" << 4), NULL));
+ ASSERT(gt.matchesBSON(BSON("a" << 5.5), nullptr));
+ ASSERT(!gt.matchesBSON(BSON("a" << 4), nullptr));
}
TEST(GtOp, MatchesArrayValue) {
BSONObj operand = BSON("$gt" << 5);
GTMatchExpression gt("a", operand["$gt"]);
- ASSERT(gt.matchesBSON(BSON("a" << BSON_ARRAY(3 << 5.5)), NULL));
- ASSERT(!gt.matchesBSON(BSON("a" << BSON_ARRAY(2 << 4)), NULL));
+ ASSERT(gt.matchesBSON(BSON("a" << BSON_ARRAY(3 << 5.5)), nullptr));
+ ASSERT(!gt.matchesBSON(BSON("a" << BSON_ARRAY(2 << 4)), nullptr));
}
TEST(GtOp, MatchesWholeArray) {
BSONObj operand = BSON("$gt" << BSON_ARRAY(5));
GTMatchExpression gt("a", operand["$gt"]);
- ASSERT(!gt.matchesBSON(BSON("a" << BSON_ARRAY(4)), NULL));
- ASSERT(!gt.matchesBSON(BSON("a" << BSON_ARRAY(5)), NULL));
- ASSERT(gt.matchesBSON(BSON("a" << BSON_ARRAY(6)), NULL));
+ ASSERT(!gt.matchesBSON(BSON("a" << BSON_ARRAY(4)), nullptr));
+ ASSERT(!gt.matchesBSON(BSON("a" << BSON_ARRAY(5)), nullptr));
+ ASSERT(gt.matchesBSON(BSON("a" << BSON_ARRAY(6)), nullptr));
// Nested array.
// XXX: The following assertion documents current behavior.
- ASSERT(gt.matchesBSON(BSON("a" << BSON_ARRAY(BSON_ARRAY(4))), NULL));
+ ASSERT(gt.matchesBSON(BSON("a" << BSON_ARRAY(BSON_ARRAY(4))), nullptr));
// XXX: The following assertion documents current behavior.
- ASSERT(gt.matchesBSON(BSON("a" << BSON_ARRAY(BSON_ARRAY(5))), NULL));
- ASSERT(gt.matchesBSON(BSON("a" << BSON_ARRAY(BSON_ARRAY(6))), NULL));
+ ASSERT(gt.matchesBSON(BSON("a" << BSON_ARRAY(BSON_ARRAY(5))), nullptr));
+ ASSERT(gt.matchesBSON(BSON("a" << BSON_ARRAY(BSON_ARRAY(6))), nullptr));
}
TEST(GtOp, MatchesNull) {
BSONObj operand = BSON("$gt" << BSONNULL);
GTMatchExpression gt("a", operand["$gt"]);
- ASSERT(!gt.matchesBSON(BSONObj(), NULL));
- ASSERT(!gt.matchesBSON(BSON("a" << BSONNULL), NULL));
- ASSERT(!gt.matchesBSON(BSON("a" << 4), NULL));
+ ASSERT(!gt.matchesBSON(BSONObj(), nullptr));
+ ASSERT(!gt.matchesBSON(BSON("a" << BSONNULL), nullptr));
+ ASSERT(!gt.matchesBSON(BSON("a" << 4), nullptr));
// A non-existent field is treated same way as an empty bson object
- ASSERT(!gt.matchesBSON(BSON("b" << 4), NULL));
+ ASSERT(!gt.matchesBSON(BSON("b" << 4), nullptr));
}
TEST(GtOp, MatchesDotNotationNull) {
BSONObj operand = BSON("$gt" << BSONNULL);
GTMatchExpression gt("a.b", operand["$gt"]);
- ASSERT(!gt.matchesBSON(BSONObj(), NULL));
- ASSERT(!gt.matchesBSON(BSON("a" << BSONNULL), NULL));
- ASSERT(!gt.matchesBSON(BSON("a" << 4), NULL));
- ASSERT(!gt.matchesBSON(BSON("a" << BSONObj()), NULL));
- ASSERT(!gt.matchesBSON(BSON("a" << BSON_ARRAY(BSON("b" << BSONNULL))), NULL));
- ASSERT(!gt.matchesBSON(BSON("a" << BSON_ARRAY(BSON("a" << 4) << BSON("b" << 4))), NULL));
- ASSERT(!gt.matchesBSON(BSON("a" << BSON_ARRAY(4)), NULL));
- ASSERT(!gt.matchesBSON(BSON("a" << BSON_ARRAY(BSON("b" << 4))), NULL));
+ ASSERT(!gt.matchesBSON(BSONObj(), nullptr));
+ ASSERT(!gt.matchesBSON(BSON("a" << BSONNULL), nullptr));
+ ASSERT(!gt.matchesBSON(BSON("a" << 4), nullptr));
+ ASSERT(!gt.matchesBSON(BSON("a" << BSONObj()), nullptr));
+ ASSERT(!gt.matchesBSON(BSON("a" << BSON_ARRAY(BSON("b" << BSONNULL))), nullptr));
+ ASSERT(!gt.matchesBSON(BSON("a" << BSON_ARRAY(BSON("a" << 4) << BSON("b" << 4))), nullptr));
+ ASSERT(!gt.matchesBSON(BSON("a" << BSON_ARRAY(4)), nullptr));
+ ASSERT(!gt.matchesBSON(BSON("a" << BSON_ARRAY(BSON("b" << 4))), nullptr));
}
TEST(GtOp, MatchesMinKey) {
@@ -550,9 +550,9 @@ TEST(GtOp, MatchesMinKey) {
BSONObj maxKeyObj = BSON("a" << MaxKey);
BSONObj numObj = BSON("a" << 4);
- ASSERT(!gt.matchesBSON(minKeyObj, NULL));
- ASSERT(gt.matchesBSON(maxKeyObj, NULL));
- ASSERT(gt.matchesBSON(numObj, NULL));
+ ASSERT(!gt.matchesBSON(minKeyObj, nullptr));
+ ASSERT(gt.matchesBSON(maxKeyObj, nullptr));
+ ASSERT(gt.matchesBSON(numObj, nullptr));
ASSERT(!gt.matchesSingleElement(minKeyObj.firstElement()));
ASSERT(gt.matchesSingleElement(maxKeyObj.firstElement()));
@@ -566,9 +566,9 @@ TEST(GtOp, MatchesMaxKey) {
BSONObj maxKeyObj = BSON("a" << MaxKey);
BSONObj numObj = BSON("a" << 4);
- ASSERT(!gt.matchesBSON(minKeyObj, NULL));
- ASSERT(!gt.matchesBSON(maxKeyObj, NULL));
- ASSERT(!gt.matchesBSON(numObj, NULL));
+ ASSERT(!gt.matchesBSON(minKeyObj, nullptr));
+ ASSERT(!gt.matchesBSON(maxKeyObj, nullptr));
+ ASSERT(!gt.matchesBSON(numObj, nullptr));
ASSERT(!gt.matchesSingleElement(minKeyObj.firstElement()));
ASSERT(!gt.matchesSingleElement(maxKeyObj.firstElement()));
@@ -611,51 +611,51 @@ DEATH_TEST(GteOp, InvalidEooOperand, "Invariant failure _rhs") {
TEST(GteOp, MatchesScalar) {
BSONObj operand = BSON("$gte" << 5);
GTEMatchExpression gte("a", operand["$gte"]);
- ASSERT(gte.matchesBSON(BSON("a" << 5.5), NULL));
- ASSERT(!gte.matchesBSON(BSON("a" << 4), NULL));
+ ASSERT(gte.matchesBSON(BSON("a" << 5.5), nullptr));
+ ASSERT(!gte.matchesBSON(BSON("a" << 4), nullptr));
}
TEST(GteOp, MatchesArrayValue) {
BSONObj operand = BSON("$gte" << 5);
GTEMatchExpression gte("a", operand["$gte"]);
- ASSERT(gte.matchesBSON(BSON("a" << BSON_ARRAY(4 << 5.5)), NULL));
- ASSERT(!gte.matchesBSON(BSON("a" << BSON_ARRAY(1 << 2)), NULL));
+ ASSERT(gte.matchesBSON(BSON("a" << BSON_ARRAY(4 << 5.5)), nullptr));
+ ASSERT(!gte.matchesBSON(BSON("a" << BSON_ARRAY(1 << 2)), nullptr));
}
TEST(GteOp, MatchesWholeArray) {
BSONObj operand = BSON("$gte" << BSON_ARRAY(5));
GTEMatchExpression gte("a", operand["$gte"]);
- ASSERT(!gte.matchesBSON(BSON("a" << BSON_ARRAY(4)), NULL));
- ASSERT(gte.matchesBSON(BSON("a" << BSON_ARRAY(5)), NULL));
- ASSERT(gte.matchesBSON(BSON("a" << BSON_ARRAY(6)), NULL));
+ ASSERT(!gte.matchesBSON(BSON("a" << BSON_ARRAY(4)), nullptr));
+ ASSERT(gte.matchesBSON(BSON("a" << BSON_ARRAY(5)), nullptr));
+ ASSERT(gte.matchesBSON(BSON("a" << BSON_ARRAY(6)), nullptr));
// Nested array.
// XXX: The following assertion documents current behavior.
- ASSERT(gte.matchesBSON(BSON("a" << BSON_ARRAY(BSON_ARRAY(4))), NULL));
- ASSERT(gte.matchesBSON(BSON("a" << BSON_ARRAY(BSON_ARRAY(5))), NULL));
- ASSERT(gte.matchesBSON(BSON("a" << BSON_ARRAY(BSON_ARRAY(6))), NULL));
+ ASSERT(gte.matchesBSON(BSON("a" << BSON_ARRAY(BSON_ARRAY(4))), nullptr));
+ ASSERT(gte.matchesBSON(BSON("a" << BSON_ARRAY(BSON_ARRAY(5))), nullptr));
+ ASSERT(gte.matchesBSON(BSON("a" << BSON_ARRAY(BSON_ARRAY(6))), nullptr));
}
TEST(GteOp, MatchesNull) {
BSONObj operand = BSON("$gte" << BSONNULL);
GTEMatchExpression gte("a", operand["$gte"]);
- ASSERT(gte.matchesBSON(BSONObj(), NULL));
- ASSERT(gte.matchesBSON(BSON("a" << BSONNULL), NULL));
- ASSERT(!gte.matchesBSON(BSON("a" << 4), NULL));
+ ASSERT(gte.matchesBSON(BSONObj(), nullptr));
+ ASSERT(gte.matchesBSON(BSON("a" << BSONNULL), nullptr));
+ ASSERT(!gte.matchesBSON(BSON("a" << 4), nullptr));
// A non-existent field is treated same way as an empty bson object
- ASSERT(gte.matchesBSON(BSON("b" << 4), NULL));
+ ASSERT(gte.matchesBSON(BSON("b" << 4), nullptr));
}
TEST(GteOp, MatchesDotNotationNull) {
BSONObj operand = BSON("$gte" << BSONNULL);
GTEMatchExpression gte("a.b", operand["$gte"]);
- ASSERT(gte.matchesBSON(BSONObj(), NULL));
- ASSERT(gte.matchesBSON(BSON("a" << BSONNULL), NULL));
- ASSERT(gte.matchesBSON(BSON("a" << 4), NULL));
- ASSERT(gte.matchesBSON(BSON("a" << BSONObj()), NULL));
- ASSERT(gte.matchesBSON(BSON("a" << BSON_ARRAY(BSON("b" << BSONNULL))), NULL));
- ASSERT(gte.matchesBSON(BSON("a" << BSON_ARRAY(BSON("a" << 4) << BSON("b" << 4))), NULL));
- ASSERT(!gte.matchesBSON(BSON("a" << BSON_ARRAY(4)), NULL));
- ASSERT(!gte.matchesBSON(BSON("a" << BSON_ARRAY(BSON("b" << 4))), NULL));
+ ASSERT(gte.matchesBSON(BSONObj(), nullptr));
+ ASSERT(gte.matchesBSON(BSON("a" << BSONNULL), nullptr));
+ ASSERT(gte.matchesBSON(BSON("a" << 4), nullptr));
+ ASSERT(gte.matchesBSON(BSON("a" << BSONObj()), nullptr));
+ ASSERT(gte.matchesBSON(BSON("a" << BSON_ARRAY(BSON("b" << BSONNULL))), nullptr));
+ ASSERT(gte.matchesBSON(BSON("a" << BSON_ARRAY(BSON("a" << 4) << BSON("b" << 4))), nullptr));
+ ASSERT(!gte.matchesBSON(BSON("a" << BSON_ARRAY(4)), nullptr));
+ ASSERT(!gte.matchesBSON(BSON("a" << BSON_ARRAY(BSON("b" << 4))), nullptr));
}
TEST(GteOp, MatchesMinKey) {
@@ -665,9 +665,9 @@ TEST(GteOp, MatchesMinKey) {
BSONObj maxKeyObj = BSON("a" << MaxKey);
BSONObj numObj = BSON("a" << 4);
- ASSERT(gte.matchesBSON(minKeyObj, NULL));
- ASSERT(gte.matchesBSON(maxKeyObj, NULL));
- ASSERT(gte.matchesBSON(numObj, NULL));
+ ASSERT(gte.matchesBSON(minKeyObj, nullptr));
+ ASSERT(gte.matchesBSON(maxKeyObj, nullptr));
+ ASSERT(gte.matchesBSON(numObj, nullptr));
ASSERT(gte.matchesSingleElement(minKeyObj.firstElement()));
ASSERT(gte.matchesSingleElement(maxKeyObj.firstElement()));
@@ -681,9 +681,9 @@ TEST(GteOp, MatchesMaxKey) {
BSONObj maxKeyObj = BSON("a" << MaxKey);
BSONObj numObj = BSON("a" << 4);
- ASSERT(!gte.matchesBSON(minKeyObj, NULL));
- ASSERT(gte.matchesBSON(maxKeyObj, NULL));
- ASSERT(!gte.matchesBSON(numObj, NULL));
+ ASSERT(!gte.matchesBSON(minKeyObj, nullptr));
+ ASSERT(gte.matchesBSON(maxKeyObj, nullptr));
+ ASSERT(!gte.matchesBSON(numObj, nullptr));
ASSERT(!gte.matchesSingleElement(minKeyObj.firstElement()));
ASSERT(gte.matchesSingleElement(maxKeyObj.firstElement()));
@@ -862,26 +862,26 @@ TEST(RegexMatchExpression, MatchesScalar) {
RegexMatchExpression regex("a", "b", "");
ASSERT(regex.matchesBSON(BSON("a"
<< "b"),
- NULL));
+ nullptr));
ASSERT(!regex.matchesBSON(BSON("a"
<< "c"),
- NULL));
+ nullptr));
}
TEST(RegexMatchExpression, MatchesArrayValue) {
RegexMatchExpression regex("a", "b", "");
ASSERT(regex.matchesBSON(BSON("a" << BSON_ARRAY("c"
<< "b")),
- NULL));
+ nullptr));
ASSERT(!regex.matchesBSON(BSON("a" << BSON_ARRAY("d"
<< "c")),
- NULL));
+ nullptr));
}
TEST(RegexMatchExpression, MatchesNull) {
RegexMatchExpression regex("a", "b", "");
- ASSERT(!regex.matchesBSON(BSONObj(), NULL));
- ASSERT(!regex.matchesBSON(BSON("a" << BSONNULL), NULL));
+ ASSERT(!regex.matchesBSON(BSONObj(), nullptr));
+ ASSERT(!regex.matchesBSON(BSON("a" << BSONNULL), nullptr));
}
TEST(RegexMatchExpression, ElemMatchKey) {
@@ -1034,20 +1034,20 @@ TEST(ModMatchExpression, ZeroDivisor) {
TEST(ModMatchExpression, MatchesScalar) {
ModMatchExpression mod("a", 5, 2);
- ASSERT(mod.matchesBSON(BSON("a" << 7.0), NULL));
- ASSERT(!mod.matchesBSON(BSON("a" << 4), NULL));
+ ASSERT(mod.matchesBSON(BSON("a" << 7.0), nullptr));
+ ASSERT(!mod.matchesBSON(BSON("a" << 4), nullptr));
}
TEST(ModMatchExpression, MatchesArrayValue) {
ModMatchExpression mod("a", 5, 2);
- ASSERT(mod.matchesBSON(BSON("a" << BSON_ARRAY(5 << 12LL)), NULL));
- ASSERT(!mod.matchesBSON(BSON("a" << BSON_ARRAY(6 << 8)), NULL));
+ ASSERT(mod.matchesBSON(BSON("a" << BSON_ARRAY(5 << 12LL)), nullptr));
+ ASSERT(!mod.matchesBSON(BSON("a" << BSON_ARRAY(6 << 8)), nullptr));
}
TEST(ModMatchExpression, MatchesNull) {
ModMatchExpression mod("a", 5, 2);
- ASSERT(!mod.matchesBSON(BSONObj(), NULL));
- ASSERT(!mod.matchesBSON(BSON("a" << BSONNULL), NULL));
+ ASSERT(!mod.matchesBSON(BSONObj(), nullptr));
+ ASSERT(!mod.matchesBSON(BSON("a" << BSONNULL), nullptr));
}
TEST(ModMatchExpression, ElemMatchKey) {
@@ -1095,14 +1095,14 @@ TEST(ExistsMatchExpression, MatchesElementExistsTrueValue) {
TEST(ExistsMatchExpression, MatchesScalar) {
ExistsMatchExpression exists("a");
- ASSERT(exists.matchesBSON(BSON("a" << 1), NULL));
- ASSERT(exists.matchesBSON(BSON("a" << BSONNULL), NULL));
- ASSERT(!exists.matchesBSON(BSON("b" << 1), NULL));
+ ASSERT(exists.matchesBSON(BSON("a" << 1), nullptr));
+ ASSERT(exists.matchesBSON(BSON("a" << BSONNULL), nullptr));
+ ASSERT(!exists.matchesBSON(BSON("b" << 1), nullptr));
}
TEST(ExistsMatchExpression, MatchesArray) {
ExistsMatchExpression exists("a");
- ASSERT(exists.matchesBSON(BSON("a" << BSON_ARRAY(4 << 5.5)), NULL));
+ ASSERT(exists.matchesBSON(BSON("a" << BSON_ARRAY(4 << 5.5)), nullptr));
}
TEST(ExistsMatchExpression, ElemMatchKey) {
@@ -1142,8 +1142,8 @@ TEST(InMatchExpression, MatchesEmpty) {
BSONObj notMatch = BSON("a" << 2);
ASSERT(!in.matchesSingleElement(notMatch["a"]));
- ASSERT(!in.matchesBSON(BSON("a" << 1), NULL));
- ASSERT(!in.matchesBSON(BSONObj(), NULL));
+ ASSERT(!in.matchesBSON(BSON("a" << 1), nullptr));
+ ASSERT(!in.matchesBSON(BSONObj(), nullptr));
}
TEST(InMatchExpression, MatchesElementMultiple) {
@@ -1170,8 +1170,8 @@ TEST(InMatchExpression, MatchesScalar) {
std::vector<BSONElement> equalities{operand.firstElement()};
ASSERT_OK(in.setEqualities(std::move(equalities)));
- ASSERT(in.matchesBSON(BSON("a" << 5.0), NULL));
- ASSERT(!in.matchesBSON(BSON("a" << 4), NULL));
+ ASSERT(in.matchesBSON(BSON("a" << 5.0), nullptr));
+ ASSERT(!in.matchesBSON(BSON("a" << 4), nullptr));
}
TEST(InMatchExpression, MatchesArrayValue) {
@@ -1180,9 +1180,9 @@ TEST(InMatchExpression, MatchesArrayValue) {
std::vector<BSONElement> equalities{operand.firstElement()};
ASSERT_OK(in.setEqualities(std::move(equalities)));
- ASSERT(in.matchesBSON(BSON("a" << BSON_ARRAY(5.0 << 6)), NULL));
- ASSERT(!in.matchesBSON(BSON("a" << BSON_ARRAY(6 << 7)), NULL));
- ASSERT(!in.matchesBSON(BSON("a" << BSON_ARRAY(BSON_ARRAY(5))), NULL));
+ ASSERT(in.matchesBSON(BSON("a" << BSON_ARRAY(5.0 << 6)), nullptr));
+ ASSERT(!in.matchesBSON(BSON("a" << BSON_ARRAY(6 << 7)), nullptr));
+ ASSERT(!in.matchesBSON(BSON("a" << BSON_ARRAY(BSON_ARRAY(5))), nullptr));
}
TEST(InMatchExpression, MatchesNull) {
@@ -1192,11 +1192,11 @@ TEST(InMatchExpression, MatchesNull) {
std::vector<BSONElement> equalities{operand.firstElement()};
ASSERT_OK(in.setEqualities(std::move(equalities)));
- ASSERT(in.matchesBSON(BSONObj(), NULL));
- ASSERT(in.matchesBSON(BSON("a" << BSONNULL), NULL));
- ASSERT(!in.matchesBSON(BSON("a" << 4), NULL));
+ ASSERT(in.matchesBSON(BSONObj(), nullptr));
+ ASSERT(in.matchesBSON(BSON("a" << BSONNULL), nullptr));
+ ASSERT(!in.matchesBSON(BSON("a" << 4), nullptr));
// A non-existent field is treated same way as an empty bson object
- ASSERT(in.matchesBSON(BSON("b" << 4), NULL));
+ ASSERT(in.matchesBSON(BSON("b" << 4), nullptr));
}
TEST(InMatchExpression, MatchesUndefined) {
@@ -1213,9 +1213,9 @@ TEST(InMatchExpression, MatchesMinKey) {
std::vector<BSONElement> equalities{operand.firstElement()};
ASSERT_OK(in.setEqualities(std::move(equalities)));
- ASSERT(in.matchesBSON(BSON("a" << MinKey), NULL));
- ASSERT(!in.matchesBSON(BSON("a" << MaxKey), NULL));
- ASSERT(!in.matchesBSON(BSON("a" << 4), NULL));
+ ASSERT(in.matchesBSON(BSON("a" << MinKey), nullptr));
+ ASSERT(!in.matchesBSON(BSON("a" << MaxKey), nullptr));
+ ASSERT(!in.matchesBSON(BSON("a" << 4), nullptr));
}
TEST(InMatchExpression, MatchesMaxKey) {
@@ -1224,9 +1224,9 @@ TEST(InMatchExpression, MatchesMaxKey) {
std::vector<BSONElement> equalities{operand.firstElement()};
ASSERT_OK(in.setEqualities(std::move(equalities)));
- ASSERT(in.matchesBSON(BSON("a" << MaxKey), NULL));
- ASSERT(!in.matchesBSON(BSON("a" << MinKey), NULL));
- ASSERT(!in.matchesBSON(BSON("a" << 4), NULL));
+ ASSERT(in.matchesBSON(BSON("a" << MaxKey), nullptr));
+ ASSERT(!in.matchesBSON(BSON("a" << MinKey), nullptr));
+ ASSERT(!in.matchesBSON(BSON("a" << 4), nullptr));
}
TEST(InMatchExpression, MatchesFullArray) {
@@ -1235,10 +1235,10 @@ TEST(InMatchExpression, MatchesFullArray) {
std::vector<BSONElement> equalities{operand[0], operand[1], operand[2]};
ASSERT_OK(in.setEqualities(std::move(equalities)));
- ASSERT(in.matchesBSON(BSON("a" << BSON_ARRAY(1 << 2)), NULL));
- ASSERT(!in.matchesBSON(BSON("a" << BSON_ARRAY(1 << 2 << 3)), NULL));
- ASSERT(!in.matchesBSON(BSON("a" << BSON_ARRAY(1)), NULL));
- ASSERT(!in.matchesBSON(BSON("a" << 1), NULL));
+ ASSERT(in.matchesBSON(BSON("a" << BSON_ARRAY(1 << 2)), nullptr));
+ ASSERT(!in.matchesBSON(BSON("a" << BSON_ARRAY(1 << 2 << 3)), nullptr));
+ ASSERT(!in.matchesBSON(BSON("a" << BSON_ARRAY(1)), nullptr));
+ ASSERT(!in.matchesBSON(BSON("a" << 1), nullptr));
}
TEST(InMatchExpression, ElemMatchKey) {
diff --git a/src/mongo/db/matcher/expression_serialization_test.cpp b/src/mongo/db/matcher/expression_serialization_test.cpp
index 7384c53e410..862b955423c 100644
--- a/src/mongo/db/matcher/expression_serialization_test.cpp
+++ b/src/mongo/db/matcher/expression_serialization_test.cpp
@@ -1695,7 +1695,7 @@ TEST(SerializeInternalBinDataSubType, ExpressionBinDataSubTypeSerializesCorrectl
fromjson("{x: {$_internalSchemaBinDataSubType: 1}}"));
ASSERT_BSONOBJ_EQ(*reserialized.getQuery(), serialize(reserialized.getMatchExpression()));
- BSONObj obj = BSON("x" << BSONBinData(NULL, 0, BinDataType::bdtCustom));
+ BSONObj obj = BSON("x" << BSONBinData(nullptr, 0, BinDataType::bdtCustom));
ASSERT_EQ(original.matches(obj), reserialized.matches(obj));
uint8_t bytes[] = {0, 1, 2, 10, 11, 12};
diff --git a/src/mongo/db/matcher/expression_text_base.cpp b/src/mongo/db/matcher/expression_text_base.cpp
index ea3fa147de2..e9d18bb2e2e 100644
--- a/src/mongo/db/matcher/expression_text_base.cpp
+++ b/src/mongo/db/matcher/expression_text_base.cpp
@@ -48,7 +48,7 @@ void TextMatchExpressionBase::debugString(StringBuilder& debug, int indentationL
<< ", caseSensitive=" << ftsQuery.getCaseSensitive()
<< ", diacriticSensitive=" << ftsQuery.getDiacriticSensitive() << ", tag=";
MatchExpression::TagData* td = getTag();
- if (NULL != td) {
+ if (nullptr != td) {
td->debugString(&debug);
} else {
debug << "NULL";
diff --git a/src/mongo/db/matcher/expression_tree.cpp b/src/mongo/db/matcher/expression_tree.cpp
index b56e96f4924..1fb9cbc4af5 100644
--- a/src/mongo/db/matcher/expression_tree.cpp
+++ b/src/mongo/db/matcher/expression_tree.cpp
@@ -241,7 +241,7 @@ bool AndMatchExpression::isTriviallyTrue() const {
bool OrMatchExpression::matches(const MatchableDocument* doc, MatchDetails* details) const {
for (size_t i = 0; i < numChildren(); i++) {
- if (getChild(i)->matches(doc, NULL)) {
+ if (getChild(i)->matches(doc, nullptr)) {
return true;
}
}
@@ -284,7 +284,7 @@ bool OrMatchExpression::isTriviallyFalse() const {
bool NorMatchExpression::matches(const MatchableDocument* doc, MatchDetails* details) const {
for (size_t i = 0; i < numChildren(); i++) {
- if (getChild(i)->matches(doc, NULL)) {
+ if (getChild(i)->matches(doc, nullptr)) {
return false;
}
}
diff --git a/src/mongo/db/matcher/expression_tree.h b/src/mongo/db/matcher/expression_tree.h
index afecd935d79..b08ce6b03fb 100644
--- a/src/mongo/db/matcher/expression_tree.h
+++ b/src/mongo/db/matcher/expression_tree.h
@@ -110,7 +110,7 @@ public:
AndMatchExpression() : ListOfMatchExpression(AND) {}
virtual ~AndMatchExpression() {}
- virtual bool matches(const MatchableDocument* doc, MatchDetails* details = 0) const;
+ virtual bool matches(const MatchableDocument* doc, MatchDetails* details = nullptr) const;
bool matchesSingleElement(const BSONElement&, MatchDetails* details = nullptr) const final;
@@ -139,7 +139,7 @@ public:
OrMatchExpression() : ListOfMatchExpression(OR) {}
virtual ~OrMatchExpression() {}
- virtual bool matches(const MatchableDocument* doc, MatchDetails* details = 0) const;
+ virtual bool matches(const MatchableDocument* doc, MatchDetails* details = nullptr) const;
bool matchesSingleElement(const BSONElement&, MatchDetails* details = nullptr) const final;
@@ -168,7 +168,7 @@ public:
NorMatchExpression() : ListOfMatchExpression(NOR) {}
virtual ~NorMatchExpression() {}
- virtual bool matches(const MatchableDocument* doc, MatchDetails* details = 0) const;
+ virtual bool matches(const MatchableDocument* doc, MatchDetails* details = nullptr) const;
bool matchesSingleElement(const BSONElement&, MatchDetails* details = nullptr) const final;
@@ -201,8 +201,8 @@ public:
return std::move(self);
}
- virtual bool matches(const MatchableDocument* doc, MatchDetails* details = 0) const {
- return !_exp->matches(doc, NULL);
+ virtual bool matches(const MatchableDocument* doc, MatchDetails* details = nullptr) const {
+ return !_exp->matches(doc, nullptr);
}
bool matchesSingleElement(const BSONElement& elt, MatchDetails* details = nullptr) const final {
diff --git a/src/mongo/db/matcher/expression_tree_test.cpp b/src/mongo/db/matcher/expression_tree_test.cpp
index a0770c2a4df..33bf9352e33 100644
--- a/src/mongo/db/matcher/expression_tree_test.cpp
+++ b/src/mongo/db/matcher/expression_tree_test.cpp
@@ -46,18 +46,18 @@ TEST(NotMatchExpression, MatchesScalar) {
BSONObj baseOperand = BSON("$lt" << 5);
unique_ptr<ComparisonMatchExpression> lt(new LTMatchExpression("a", baseOperand["$lt"]));
NotMatchExpression notOp(lt.release());
- ASSERT(notOp.matchesBSON(BSON("a" << 6), NULL));
- ASSERT(!notOp.matchesBSON(BSON("a" << 4), NULL));
+ ASSERT(notOp.matchesBSON(BSON("a" << 6), nullptr));
+ ASSERT(!notOp.matchesBSON(BSON("a" << 4), nullptr));
}
TEST(NotMatchExpression, MatchesArray) {
BSONObj baseOperand = BSON("$lt" << 5);
unique_ptr<ComparisonMatchExpression> lt(new LTMatchExpression("a", baseOperand["$lt"]));
NotMatchExpression notOp(lt.release());
- ASSERT(notOp.matchesBSON(BSON("a" << BSON_ARRAY(6)), NULL));
- ASSERT(!notOp.matchesBSON(BSON("a" << BSON_ARRAY(4)), NULL));
+ ASSERT(notOp.matchesBSON(BSON("a" << BSON_ARRAY(6)), nullptr));
+ ASSERT(!notOp.matchesBSON(BSON("a" << BSON_ARRAY(4)), nullptr));
// All array elements must match.
- ASSERT(!notOp.matchesBSON(BSON("a" << BSON_ARRAY(4 << 5 << 6)), NULL));
+ ASSERT(!notOp.matchesBSON(BSON("a" << BSON_ARRAY(4 << 5 << 6)), nullptr));
}
TEST(NotMatchExpression, ElemMatchKey) {
@@ -89,7 +89,7 @@ TEST(NotMatchExpression, SetCollatorPropagatesToChild) {
TEST(AndOp, NoClauses) {
AndMatchExpression andMatchExpression;
- ASSERT(andMatchExpression.matchesBSON(BSONObj(), NULL));
+ ASSERT(andMatchExpression.matchesBSON(BSONObj(), nullptr));
}
TEST(AndOp, MatchesElementThreeClauses) {
@@ -129,10 +129,10 @@ TEST(AndOp, MatchesSingleClause) {
AndMatchExpression andOp;
andOp.add(ne.release());
- ASSERT(andOp.matchesBSON(BSON("a" << 4), NULL));
- ASSERT(andOp.matchesBSON(BSON("a" << BSON_ARRAY(4 << 6)), NULL));
- ASSERT(!andOp.matchesBSON(BSON("a" << 5), NULL));
- ASSERT(!andOp.matchesBSON(BSON("a" << BSON_ARRAY(4 << 5)), NULL));
+ ASSERT(andOp.matchesBSON(BSON("a" << 4), nullptr));
+ ASSERT(andOp.matchesBSON(BSON("a" << BSON_ARRAY(4 << 6)), nullptr));
+ ASSERT(!andOp.matchesBSON(BSON("a" << 5), nullptr));
+ ASSERT(!andOp.matchesBSON(BSON("a" << BSON_ARRAY(4 << 5)), nullptr));
}
TEST(AndOp, MatchesThreeClauses) {
@@ -149,11 +149,11 @@ TEST(AndOp, MatchesThreeClauses) {
andOp.add(sub2.release());
andOp.add(sub3.release());
- ASSERT(andOp.matchesBSON(BSON("a" << 5 << "b" << 6), NULL));
- ASSERT(!andOp.matchesBSON(BSON("a" << 5), NULL));
- ASSERT(!andOp.matchesBSON(BSON("b" << 6), NULL));
- ASSERT(!andOp.matchesBSON(BSON("a" << 1 << "b" << 6), NULL));
- ASSERT(!andOp.matchesBSON(BSON("a" << 10 << "b" << 6), NULL));
+ ASSERT(andOp.matchesBSON(BSON("a" << 5 << "b" << 6), nullptr));
+ ASSERT(!andOp.matchesBSON(BSON("a" << 5), nullptr));
+ ASSERT(!andOp.matchesBSON(BSON("b" << 6), nullptr));
+ ASSERT(!andOp.matchesBSON(BSON("a" << 1 << "b" << 6), nullptr));
+ ASSERT(!andOp.matchesBSON(BSON("a" << 10 << "b" << 6), nullptr));
}
TEST(AndOp, ElemMatchKey) {
@@ -181,7 +181,7 @@ TEST(AndOp, ElemMatchKey) {
TEST(OrOp, NoClauses) {
OrMatchExpression orOp;
- ASSERT(!orOp.matchesBSON(BSONObj(), NULL));
+ ASSERT(!orOp.matchesBSON(BSONObj(), nullptr));
}
TEST(OrOp, MatchesSingleClause) {
@@ -192,10 +192,10 @@ TEST(OrOp, MatchesSingleClause) {
OrMatchExpression orOp;
orOp.add(ne.release());
- ASSERT(orOp.matchesBSON(BSON("a" << 4), NULL));
- ASSERT(orOp.matchesBSON(BSON("a" << BSON_ARRAY(4 << 6)), NULL));
- ASSERT(!orOp.matchesBSON(BSON("a" << 5), NULL));
- ASSERT(!orOp.matchesBSON(BSON("a" << BSON_ARRAY(4 << 5)), NULL));
+ ASSERT(orOp.matchesBSON(BSON("a" << 4), nullptr));
+ ASSERT(orOp.matchesBSON(BSON("a" << BSON_ARRAY(4 << 6)), nullptr));
+ ASSERT(!orOp.matchesBSON(BSON("a" << 5), nullptr));
+ ASSERT(!orOp.matchesBSON(BSON("a" << BSON_ARRAY(4 << 5)), nullptr));
}
TEST(OrOp, MatchesThreeClauses) {
@@ -211,13 +211,13 @@ TEST(OrOp, MatchesThreeClauses) {
orOp.add(sub2.release());
orOp.add(sub3.release());
- ASSERT(orOp.matchesBSON(BSON("a" << -1), NULL));
- ASSERT(orOp.matchesBSON(BSON("a" << 11), NULL));
- ASSERT(!orOp.matchesBSON(BSON("a" << 5), NULL));
- ASSERT(orOp.matchesBSON(BSON("b" << 100), NULL));
- ASSERT(!orOp.matchesBSON(BSON("b" << 101), NULL));
- ASSERT(!orOp.matchesBSON(BSONObj(), NULL));
- ASSERT(orOp.matchesBSON(BSON("a" << 11 << "b" << 100), NULL));
+ ASSERT(orOp.matchesBSON(BSON("a" << -1), nullptr));
+ ASSERT(orOp.matchesBSON(BSON("a" << 11), nullptr));
+ ASSERT(!orOp.matchesBSON(BSON("a" << 5), nullptr));
+ ASSERT(orOp.matchesBSON(BSON("b" << 100), nullptr));
+ ASSERT(!orOp.matchesBSON(BSON("b" << 101), nullptr));
+ ASSERT(!orOp.matchesBSON(BSONObj(), nullptr));
+ ASSERT(orOp.matchesBSON(BSON("a" << 11 << "b" << 100), nullptr));
}
TEST(OrOp, ElemMatchKey) {
@@ -243,7 +243,7 @@ TEST(OrOp, ElemMatchKey) {
TEST(NorOp, NoClauses) {
NorMatchExpression norOp;
- ASSERT(norOp.matchesBSON(BSONObj(), NULL));
+ ASSERT(norOp.matchesBSON(BSONObj(), nullptr));
}
TEST(NorOp, MatchesSingleClause) {
@@ -254,10 +254,10 @@ TEST(NorOp, MatchesSingleClause) {
NorMatchExpression norOp;
norOp.add(ne.release());
- ASSERT(!norOp.matchesBSON(BSON("a" << 4), NULL));
- ASSERT(!norOp.matchesBSON(BSON("a" << BSON_ARRAY(4 << 6)), NULL));
- ASSERT(norOp.matchesBSON(BSON("a" << 5), NULL));
- ASSERT(norOp.matchesBSON(BSON("a" << BSON_ARRAY(4 << 5)), NULL));
+ ASSERT(!norOp.matchesBSON(BSON("a" << 4), nullptr));
+ ASSERT(!norOp.matchesBSON(BSON("a" << BSON_ARRAY(4 << 6)), nullptr));
+ ASSERT(norOp.matchesBSON(BSON("a" << 5), nullptr));
+ ASSERT(norOp.matchesBSON(BSON("a" << BSON_ARRAY(4 << 5)), nullptr));
}
TEST(NorOp, MatchesThreeClauses) {
@@ -274,13 +274,13 @@ TEST(NorOp, MatchesThreeClauses) {
norOp.add(sub2.release());
norOp.add(sub3.release());
- ASSERT(!norOp.matchesBSON(BSON("a" << -1), NULL));
- ASSERT(!norOp.matchesBSON(BSON("a" << 11), NULL));
- ASSERT(norOp.matchesBSON(BSON("a" << 5), NULL));
- ASSERT(!norOp.matchesBSON(BSON("b" << 100), NULL));
- ASSERT(norOp.matchesBSON(BSON("b" << 101), NULL));
- ASSERT(norOp.matchesBSON(BSONObj(), NULL));
- ASSERT(!norOp.matchesBSON(BSON("a" << 11 << "b" << 100), NULL));
+ ASSERT(!norOp.matchesBSON(BSON("a" << -1), nullptr));
+ ASSERT(!norOp.matchesBSON(BSON("a" << 11), nullptr));
+ ASSERT(norOp.matchesBSON(BSON("a" << 5), nullptr));
+ ASSERT(!norOp.matchesBSON(BSON("b" << 100), nullptr));
+ ASSERT(norOp.matchesBSON(BSON("b" << 101), nullptr));
+ ASSERT(norOp.matchesBSON(BSONObj(), nullptr));
+ ASSERT(!norOp.matchesBSON(BSON("a" << 11 << "b" << 100), nullptr));
}
TEST(NorOp, ElemMatchKey) {
diff --git a/src/mongo/db/matcher/expression_type_test.cpp b/src/mongo/db/matcher/expression_type_test.cpp
index 403a60ee9f4..b4e9ed4b405 100644
--- a/src/mongo/db/matcher/expression_type_test.cpp
+++ b/src/mongo/db/matcher/expression_type_test.cpp
@@ -75,17 +75,17 @@ TEST(ExpressionTypeTest, MatchesElementNumber) {
TEST(ExpressionTypeTest, MatchesScalar) {
TypeMatchExpression type("a", Bool);
- ASSERT(type.matchesBSON(BSON("a" << true), NULL));
- ASSERT(!type.matchesBSON(BSON("a" << 1), NULL));
+ ASSERT(type.matchesBSON(BSON("a" << true), nullptr));
+ ASSERT(!type.matchesBSON(BSON("a" << 1), nullptr));
}
TEST(ExpressionTypeTest, MatchesArray) {
TypeMatchExpression type("a", NumberInt);
- ASSERT(type.matchesBSON(BSON("a" << BSON_ARRAY(4)), NULL));
- ASSERT(type.matchesBSON(BSON("a" << BSON_ARRAY(4 << "a")), NULL));
- ASSERT(type.matchesBSON(BSON("a" << BSON_ARRAY("a" << 4)), NULL));
- ASSERT(!type.matchesBSON(BSON("a" << BSON_ARRAY("a")), NULL));
- ASSERT(!type.matchesBSON(BSON("a" << BSON_ARRAY(BSON_ARRAY(4))), NULL));
+ ASSERT(type.matchesBSON(BSON("a" << BSON_ARRAY(4)), nullptr));
+ ASSERT(type.matchesBSON(BSON("a" << BSON_ARRAY(4 << "a")), nullptr));
+ ASSERT(type.matchesBSON(BSON("a" << BSON_ARRAY("a" << 4)), nullptr));
+ ASSERT(!type.matchesBSON(BSON("a" << BSON_ARRAY("a")), nullptr));
+ ASSERT(!type.matchesBSON(BSON("a" << BSON_ARRAY(BSON_ARRAY(4))), nullptr));
}
TEST(ExpressionTypeTest, TypeArrayMatchesOuterAndInnerArray) {
@@ -100,39 +100,39 @@ TEST(ExpressionTypeTest, TypeArrayMatchesOuterAndInnerArray) {
TEST(ExpressionTypeTest, MatchesObject) {
TypeMatchExpression type("a", Object);
- ASSERT(type.matchesBSON(BSON("a" << BSON("b" << 1)), NULL));
- ASSERT(!type.matchesBSON(BSON("a" << 1), NULL));
+ ASSERT(type.matchesBSON(BSON("a" << BSON("b" << 1)), nullptr));
+ ASSERT(!type.matchesBSON(BSON("a" << 1), nullptr));
}
TEST(ExpressionTypeTest, MatchesDotNotationFieldObject) {
TypeMatchExpression type("a.b", Object);
- ASSERT(type.matchesBSON(BSON("a" << BSON("b" << BSON("c" << 1))), NULL));
- ASSERT(!type.matchesBSON(BSON("a" << BSON("b" << 1)), NULL));
+ ASSERT(type.matchesBSON(BSON("a" << BSON("b" << BSON("c" << 1))), nullptr));
+ ASSERT(!type.matchesBSON(BSON("a" << BSON("b" << 1)), nullptr));
}
TEST(ExpressionTypeTest, MatchesDotNotationArrayElementArray) {
TypeMatchExpression type("a.0", Array);
- ASSERT(type.matchesBSON(BSON("a" << BSON_ARRAY(BSON_ARRAY(1))), NULL));
- ASSERT(!type.matchesBSON(BSON("a" << BSON_ARRAY("b")), NULL));
+ ASSERT(type.matchesBSON(BSON("a" << BSON_ARRAY(BSON_ARRAY(1))), nullptr));
+ ASSERT(!type.matchesBSON(BSON("a" << BSON_ARRAY("b")), nullptr));
}
TEST(ExpressionTypeTest, MatchesDotNotationArrayElementScalar) {
TypeMatchExpression type("a.0", String);
- ASSERT(type.matchesBSON(BSON("a" << BSON_ARRAY("b")), NULL));
- ASSERT(!type.matchesBSON(BSON("a" << BSON_ARRAY(1)), NULL));
+ ASSERT(type.matchesBSON(BSON("a" << BSON_ARRAY("b")), nullptr));
+ ASSERT(!type.matchesBSON(BSON("a" << BSON_ARRAY(1)), nullptr));
}
TEST(ExpressionTypeTest, MatchesDotNotationArrayElementObject) {
TypeMatchExpression type("a.0", Object);
- ASSERT(type.matchesBSON(BSON("a" << BSON_ARRAY(BSON("b" << 1))), NULL));
- ASSERT(!type.matchesBSON(BSON("a" << BSON_ARRAY(1)), NULL));
+ ASSERT(type.matchesBSON(BSON("a" << BSON_ARRAY(BSON("b" << 1))), nullptr));
+ ASSERT(!type.matchesBSON(BSON("a" << BSON_ARRAY(1)), nullptr));
}
TEST(ExpressionTypeTest, MatchesNull) {
TypeMatchExpression type("a", jstNULL);
- ASSERT(type.matchesBSON(BSON("a" << BSONNULL), NULL));
- ASSERT(!type.matchesBSON(BSON("a" << 4), NULL));
- ASSERT(!type.matchesBSON(BSONObj(), NULL));
+ ASSERT(type.matchesBSON(BSON("a" << BSONNULL), nullptr));
+ ASSERT(!type.matchesBSON(BSON("a" << 4), nullptr));
+ ASSERT(!type.matchesBSON(BSONObj(), nullptr));
}
TEST(ExpressionTypeTest, ElemMatchKey) {
@@ -218,48 +218,48 @@ TEST(ExpressionTypeTest, InternalSchemaTypeExprWithMultipleTypesMatchesAllSuchTy
}
TEST(ExpressionBinDataSubTypeTest, MatchesBinDataGeneral) {
- BSONObj match = BSON("a" << BSONBinData(NULL, 0, BinDataType::BinDataGeneral));
- BSONObj notMatch = BSON("a" << BSONBinData(NULL, 0, BinDataType::bdtCustom));
+ BSONObj match = BSON("a" << BSONBinData(nullptr, 0, BinDataType::BinDataGeneral));
+ BSONObj notMatch = BSON("a" << BSONBinData(nullptr, 0, BinDataType::bdtCustom));
InternalSchemaBinDataSubTypeExpression type("", BinDataType::BinDataGeneral);
ASSERT_TRUE(type.matchesSingleElement(match["a"]));
ASSERT_FALSE(type.matchesSingleElement(notMatch["a"]));
}
TEST(ExpressionBinDataSubTypeTest, MatchesBinDataFunction) {
- BSONObj match = BSON("a" << BSONBinData(NULL, 0, BinDataType::Function));
- BSONObj notMatch = BSON("a" << BSONBinData(NULL, 0, BinDataType::MD5Type));
+ BSONObj match = BSON("a" << BSONBinData(nullptr, 0, BinDataType::Function));
+ BSONObj notMatch = BSON("a" << BSONBinData(nullptr, 0, BinDataType::MD5Type));
InternalSchemaBinDataSubTypeExpression type("", BinDataType::Function);
ASSERT_TRUE(type.matchesSingleElement(match["a"]));
ASSERT_FALSE(type.matchesSingleElement(notMatch["a"]));
}
TEST(ExpressionBinDataSubTypeTest, MatchesBinDataNewUUID) {
- BSONObj match = BSON("a" << BSONBinData(NULL, 0, BinDataType::newUUID));
- BSONObj notMatch = BSON("a" << BSONBinData(NULL, 0, BinDataType::BinDataGeneral));
+ BSONObj match = BSON("a" << BSONBinData(nullptr, 0, BinDataType::newUUID));
+ BSONObj notMatch = BSON("a" << BSONBinData(nullptr, 0, BinDataType::BinDataGeneral));
InternalSchemaBinDataSubTypeExpression type("", BinDataType::newUUID);
ASSERT_TRUE(type.matchesSingleElement(match["a"]));
ASSERT_FALSE(type.matchesSingleElement(notMatch["a"]));
}
TEST(ExpressionBinDataSubTypeTest, MatchesBinDataMD5Type) {
- BSONObj match = BSON("a" << BSONBinData(NULL, 0, BinDataType::MD5Type));
- BSONObj notMatch = BSON("a" << BSONBinData(NULL, 0, BinDataType::newUUID));
+ BSONObj match = BSON("a" << BSONBinData(nullptr, 0, BinDataType::MD5Type));
+ BSONObj notMatch = BSON("a" << BSONBinData(nullptr, 0, BinDataType::newUUID));
InternalSchemaBinDataSubTypeExpression type("", BinDataType::MD5Type);
ASSERT_TRUE(type.matchesSingleElement(match["a"]));
ASSERT_FALSE(type.matchesSingleElement(notMatch["a"]));
}
TEST(ExpressionBinDataSubTypeTest, MatchesBinDataEncryptType) {
- BSONObj match = BSON("a" << BSONBinData(NULL, 0, BinDataType::Encrypt));
- BSONObj notMatch = BSON("a" << BSONBinData(NULL, 0, BinDataType::newUUID));
+ BSONObj match = BSON("a" << BSONBinData(nullptr, 0, BinDataType::Encrypt));
+ BSONObj notMatch = BSON("a" << BSONBinData(nullptr, 0, BinDataType::newUUID));
InternalSchemaBinDataSubTypeExpression type("", BinDataType::Encrypt);
ASSERT_TRUE(type.matchesSingleElement(match["a"]));
ASSERT_FALSE(type.matchesSingleElement(notMatch["a"]));
}
TEST(ExpressionBinDataSubTypeTest, MatchesBinDataBdtCustom) {
- BSONObj match = BSON("a" << BSONBinData(NULL, 0, BinDataType::bdtCustom));
- BSONObj notMatch = BSON("a" << BSONBinData(NULL, 0, BinDataType::Function));
+ BSONObj match = BSON("a" << BSONBinData(nullptr, 0, BinDataType::bdtCustom));
+ BSONObj notMatch = BSON("a" << BSONBinData(nullptr, 0, BinDataType::Function));
InternalSchemaBinDataSubTypeExpression type("", BinDataType::bdtCustom);
ASSERT_TRUE(type.matchesSingleElement(match["a"]));
ASSERT_FALSE(type.matchesSingleElement(notMatch["a"]));
@@ -268,11 +268,11 @@ TEST(ExpressionBinDataSubTypeTest, MatchesBinDataBdtCustom) {
TEST(ExpressionBinDataSubTypeTest, DoesNotMatchArrays) {
InternalSchemaBinDataSubTypeExpression type("a", BinDataType::BinDataGeneral);
ASSERT_FALSE(type.matchesBSON(
- BSON("a" << BSON_ARRAY(BSONBinData(NULL, 0, BinDataType::BinDataGeneral)
- << BSONBinData(NULL, 0, BinDataType::BinDataGeneral)))));
- ASSERT_FALSE(
- type.matchesBSON(BSON("a" << BSON_ARRAY(BSONBinData(NULL, 0, BinDataType::BinDataGeneral)
- << BSONBinData(NULL, 0, BinDataType::Function)))));
+ BSON("a" << BSON_ARRAY(BSONBinData(nullptr, 0, BinDataType::BinDataGeneral)
+ << BSONBinData(nullptr, 0, BinDataType::BinDataGeneral)))));
+ ASSERT_FALSE(type.matchesBSON(
+ BSON("a" << BSON_ARRAY(BSONBinData(nullptr, 0, BinDataType::BinDataGeneral)
+ << BSONBinData(nullptr, 0, BinDataType::Function)))));
}
TEST(ExpressionBinDataSubTypeTest, DoesNotMatchString) {
diff --git a/src/mongo/db/matcher/expression_where.cpp b/src/mongo/db/matcher/expression_where.cpp
index ff2069fe9ed..a171c10c140 100644
--- a/src/mongo/db/matcher/expression_where.cpp
+++ b/src/mongo/db/matcher/expression_where.cpp
@@ -54,7 +54,7 @@ WhereMatchExpression::WhereMatchExpression(OperationContext* opCtx,
WhereParams params,
StringData dbName)
: WhereMatchExpressionBase(std::move(params)), _dbName(dbName.toString()), _opCtx(opCtx) {
- invariant(_opCtx != NULL);
+ invariant(_opCtx != nullptr);
uassert(
ErrorCodes::BadValue, "no globalScriptEngine in $where parsing", getGlobalScriptEngine());
@@ -87,7 +87,7 @@ bool WhereMatchExpression::matches(const MatchableDocument* doc, MatchDetails* d
_scope->setObject("obj", const_cast<BSONObj&>(obj));
_scope->setBoolean("fullObject", true); // this is a hack b/c fullObject used to be relevant
- int err = _scope->invoke(_func, 0, &obj, 1000 * 60, false);
+ int err = _scope->invoke(_func, nullptr, &obj, 1000 * 60, false);
if (err == -3) { // INVOKE_ERROR
stringstream ss;
ss << "error on invocation of $where function:\n" << _scope->getError();
diff --git a/src/mongo/db/matcher/matcher.h b/src/mongo/db/matcher/matcher.h
index ae39f597bf3..ff7aeaa60dc 100644
--- a/src/mongo/db/matcher/matcher.h
+++ b/src/mongo/db/matcher/matcher.h
@@ -59,7 +59,7 @@ public:
MatchExpressionParser::AllowedFeatureSet allowedFeatures =
MatchExpressionParser::kDefaultSpecialFeatures);
- bool matches(const BSONObj& doc, MatchDetails* details = NULL) const;
+ bool matches(const BSONObj& doc, MatchDetails* details = nullptr) const;
const BSONObj* getQuery() const {
return &_pattern;
diff --git a/src/mongo/db/matcher/path.cpp b/src/mongo/db/matcher/path.cpp
index efd2c69aa06..e06412814df 100644
--- a/src/mongo/db/matcher/path.cpp
+++ b/src/mongo/db/matcher/path.cpp
@@ -78,7 +78,7 @@ ElementIterator::Context SimpleArrayElementIterator::next() {
// ------
BSONElementIterator::BSONElementIterator() {
- _path = NULL;
+ _path = nullptr;
}
BSONElementIterator::BSONElementIterator(const ElementPath* path,