diff --git a/tests/span_tests.cpp b/tests/span_tests.cpp index 8479aa1..2243160 100644 --- a/tests/span_tests.cpp +++ b/tests/span_tests.cpp @@ -23,6 +23,7 @@ #include #include #include +#include using namespace std; using namespace gsl; @@ -1243,6 +1244,29 @@ SUITE(span_tests) }; CHECK_THROW(f(), fail_fast); } + + TEST(interop_with_std_regex) + { + char lat[] = { '1', '2', '3', '4', '5', '6', 'E', 'F', 'G' }; + span s = lat; + auto f_it = s.begin() + 7; + + std::match_results::iterator> match; + + std::regex_match(s.begin(), s.end(), match, std::regex(".*")); + CHECK(match.ready()); + CHECK(!match.empty()); + CHECK(match[0].matched); + CHECK(match[0].first == s.begin()); + CHECK(match[0].second == s.end()); + + std::regex_search(s.begin(), s.end(), match, std::regex("F")); + CHECK(match.ready()); + CHECK(!match.empty()); + CHECK(match[0].matched); + CHECK(match[0].first == f_it); + CHECK(match[0].second == (f_it + 1)); + } } int main(int, const char* []) { return UnitTest::RunAllTests(); }