diff options
author | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2020-02-24 19:34:40 -0500 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-02-25 01:03:52 +0000 |
commit | 60f8edf788f75ac1a32bf702aae882b409767448 (patch) | |
tree | 8349abc7fce731c8f85e5ac2ed6894e900ba1763 /src/mongo/unittest/unittest.h | |
parent | 383d7183532929620cf31d7f89a0a37daaea8b8e (diff) | |
download | mongo-60f8edf788f75ac1a32bf702aae882b409767448.tar.gz |
SERVER-46219 Unit Tests should log with json
Diffstat (limited to 'src/mongo/unittest/unittest.h')
-rw-r--r-- | src/mongo/unittest/unittest.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/mongo/unittest/unittest.h b/src/mongo/unittest/unittest.h index f3582d319a0..9e2c2fd0518 100644 --- a/src/mongo/unittest/unittest.h +++ b/src/mongo/unittest/unittest.h @@ -39,6 +39,7 @@ #include <cmath> #include <fmt/format.h> #include <functional> +#include <pcrecpp.h> #include <sstream> #include <string> #include <tuple> @@ -277,6 +278,20 @@ haystack); \ }())) +#define ASSERT_STRING_SEARCH_REGEX(BIG_STRING, REGEX) \ + if (auto tup_ = std::tuple(std::string(BIG_STRING), std::string(REGEX)); \ + pcrecpp::RE(std::get<1>(tup_)).PartialMatch(std::get<0>(tup_))) { \ + } else \ + FAIL(([&] { \ + const auto& [haystack, sub] = tup_; \ + return format(FMT_STRING("Expected to find regular expression {} /{}/ in {} ({})"), \ + #REGEX, \ + sub, \ + #BIG_STRING, \ + haystack); \ + }())) + + /** * Construct a single test, named `TEST_NAME` within the test Suite `SUITE_NAME`. * |