aboutsummaryrefslogtreecommitdiff
path: root/tests/span_tests.cpp
diff options
context:
space:
mode:
authorNeil MacIntosh <neilmac@microsoft.com>2016-08-10 19:32:00 -0700
committerNeil MacIntosh <neilmac@microsoft.com>2016-08-10 19:32:00 -0700
commitd6ac64027194678bba8f7b518d729075bac27a2d (patch)
tree12d7cd9a4c871b5b6b6f303e8477034e0947b744 /tests/span_tests.cpp
parentcb6996cd97f3cf5c774f8a32abd3aaafc6d96a88 (diff)
downloadMicrosoft-GSL-d6ac64027194678bba8f7b518d729075bac27a2d.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 8479aa1..2243160 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;
@@ -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<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(); }