aboutsummaryrefslogtreecommitdiff
path: root/test/std/re/re.alg/re.alg.search/grep.pass.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/std/re/re.alg/re.alg.search/grep.pass.cpp')
-rw-r--r--test/std/re/re.alg/re.alg.search/grep.pass.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/std/re/re.alg/re.alg.search/grep.pass.cpp b/test/std/re/re.alg/re.alg.search/grep.pass.cpp
index 113243ecd349..9d74c2417d2d 100644
--- a/test/std/re/re.alg/re.alg.search/grep.pass.cpp
+++ b/test/std/re/re.alg/re.alg.search/grep.pass.cpp
@@ -7,6 +7,7 @@
//
//===----------------------------------------------------------------------===//
+// XFAIL: libcpp-no-exceptions
// <regex>
// template <class BidirectionalIterator, class Allocator, class charT, class traits>
@@ -19,8 +20,34 @@
#include <regex>
#include <cassert>
+#include "test_macros.h"
#include "test_iterators.h"
+extern "C" void LLVMFuzzerTestOneInput(const char *data)
+{
+ size_t size = strlen(data);
+ if (size > 0)
+ {
+ try
+ {
+ std::regex::flag_type flag = std::regex_constants::grep;
+ std::string s((const char *)data, size);
+ std::regex re(s, flag);
+ std::regex_match(s, re);
+ }
+ catch (std::regex_error &ex) {}
+ }
+}
+
+
+void fuzz_tests() // patterns that the fuzzer has found
+{
+// Raw string literals are a C++11 feature.
+#if TEST_STD_VER >= 11
+ LLVMFuzzerTestOneInput(R"XX(Õ)_%()()((\8'_%()_%()_%()_%(()_%()_%()_%(.t;)()¥f()_%()(.)_%;)()!¥f(((()()XX");
+#endif
+}
+
int main()
{
{
@@ -55,4 +82,5 @@ int main()
assert(m.position(0) == 0);
assert(m.str(0) == "");
}
+ fuzz_tests();
}