aboutsummaryrefslogtreecommitdiff
path: root/tests/span_tests.cpp
diff options
context:
space:
mode:
authorNeil MacIntosh <neilmac@microsoft.com>2016-08-10 19:39:48 -0700
committerGitHub <noreply@github.com>2016-08-10 19:39:48 -0700
commitf3e660a5a535e88e9b77f2c6f57db4c1140530e0 (patch)
treea80224611bf8ae7d1a1e8b00c1b897eecb9cd3c1 /tests/span_tests.cpp
parent85b5c3770cea26f8b33dd07ce51eba0d935d6e3c (diff)
parentd6ac64027194678bba8f7b518d729075bac27a2d (diff)
downloadMicrosoft-GSL-f3e660a5a535e88e9b77f2c6f57db4c1140530e0.tar.gz
Added basic test for interop with std::regex as per Issue #271.
Diffstat (limited to 'tests/span_tests.cpp')
-rw-r--r--tests/span_tests.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/span_tests.cpp b/tests/span_tests.cpp
index 05386b2..712492f 100644
--- a/tests/span_tests.cpp
+++ b/tests/span_tests.cpp
@@ -23,6 +23,7 @@
#include <memory>
#include <string>
#include <vector>
+#include <regex>
using namespace std;
using namespace gsl;
@@ -1330,6 +1331,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<char> s = lat;
+ auto f_it = s.begin() + 7;
+
+ std::match_results<span<char>::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(); }