diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/db/matcher/expression_leaf_test.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/mongo/db/matcher/expression_leaf_test.cpp b/src/mongo/db/matcher/expression_leaf_test.cpp index 87ac6861f7f..762ffa21279 100644 --- a/src/mongo/db/matcher/expression_leaf_test.cpp +++ b/src/mongo/db/matcher/expression_leaf_test.cpp @@ -896,6 +896,24 @@ TEST(RegexMatchExpression, RegexOptionsStringCannotContainEmbeddedNullByte) { } } +TEST(RegexMatchExpression, MalformedRegexAcceptedButMatchesNothing) { + RegexMatchExpression regex("a", "[(*ACCEPT)", ""); + ASSERT_FALSE(regex.matchesBSON(BSON("a" + << ""))); + ASSERT_FALSE(regex.matchesBSON(BSON("a" + << "["))); +} + +TEST(RegexMatchExpression, RegexAcceptsUCPOption) { + RegexMatchExpression regex("a", "(*UCP)(\\w|\u304C)", ""); + ASSERT(regex.matchesBSON(BSON("a" + << "k"))); + ASSERT(regex.matchesBSON(BSON("a" + << "\u304B"))); + ASSERT(regex.matchesBSON(BSON("a" + << "\u304C"))); +} + TEST(ModMatchExpression, MatchesElement) { BSONObj match = BSON("a" << 1); BSONObj largerMatch = BSON("a" << 4.0); |