summaryrefslogtreecommitdiff
path: root/src/mongo/util/pcre_util_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/util/pcre_util_test.cpp')
-rw-r--r--src/mongo/util/pcre_util_test.cpp23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/mongo/util/pcre_util_test.cpp b/src/mongo/util/pcre_util_test.cpp
index 720ff5c31ad..66029835c54 100644
--- a/src/mongo/util/pcre_util_test.cpp
+++ b/src/mongo/util/pcre_util_test.cpp
@@ -42,9 +42,9 @@ namespace {
using namespace fmt::literals;
// Test compares `CompileOptions` as integers.
-TEST(PcreUtilTest, ParseOptions) {
+TEST(PcreUtilTest, FlagsToOptions) {
using namespace pcre::options;
- auto parse = [](StringData flags) { return static_cast<uint32_t>(parseOptions(flags)); };
+ auto parse = [](StringData flags) { return static_cast<uint32_t>(flagsToOptions(flags)); };
auto expect = [](pcre::CompileOptions o) { return static_cast<uint32_t>(o); };
ASSERT_EQ(parse(""), expect(UTF)) << " UTF is on by default";
ASSERT_EQ(parse("i"), expect(UTF | CASELESS));
@@ -60,6 +60,25 @@ TEST(PcreUtilTest, ParseOptions) {
ASSERT_THROWS_WITH_CHECK(parse("iz"), DBException, isBadFlagException);
}
+// Test compares `CompileOptions` as strings of option flags.
+TEST(PcreUtilTest, OptionsToFlags) {
+ using namespace pcre::options;
+ auto parse = [](pcre::CompileOptions flags) {
+ return static_cast<std::string>(optionsToFlags(flags));
+ };
+ auto expect = [](std::string o) { return (o); };
+ ASSERT_EQ(parse(UTF | CASELESS), expect("i"));
+ ASSERT_EQ(parse(UTF | MULTILINE), expect("m"));
+ ASSERT_EQ(parse(UTF | DOTALL), expect("s"));
+ ASSERT_EQ(parse(UTF), expect("")) << " UTF is on by default";
+ ASSERT_EQ(parse(UTF | EXTENDED), expect("x"));
+ ASSERT_EQ(parse(UTF | CASELESS | MULTILINE | DOTALL | EXTENDED), expect("imsx"));
+ ASSERT_EQ(parse(UTF | CASELESS | MULTILINE | DOTALL), expect("ims"));
+ ASSERT_EQ(parse(UTF | CASELESS | MULTILINE | EXTENDED), expect("imx"));
+ ASSERT_EQ(parse(UTF | CASELESS | DOTALL | EXTENDED), expect("isx"));
+ ASSERT_EQ(parse(UTF | MULTILINE | DOTALL | EXTENDED), expect("msx"));
+}
+
TEST(PcreUtilTest, QuoteMeta) {
ASSERT_EQ(quoteMeta(""), "");
ASSERT_EQ(quoteMeta("abc_def_123"_sd), "abc_def_123");