mirror of
https://github.com/microsoft/GSL.git
synced 2024-11-03 17:56:43 -05:00
Added basic test for interop with std::regex as per Issue #271.
This commit is contained in:
commit
f3e660a5a5
@ -23,6 +23,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <regex>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace gsl;
|
using namespace gsl;
|
||||||
@ -1330,6 +1331,29 @@ SUITE(span_tests)
|
|||||||
};
|
};
|
||||||
CHECK_THROW(f(), fail_fast);
|
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(); }
|
int main(int, const char* []) { return UnitTest::RunAllTests(); }
|
||||||
|
Loading…
Reference in New Issue
Block a user