aboutsummaryrefslogtreecommitdiff
path: root/test/std/re/re.results/re.results.form/form1.pass.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2016-02-21 13:53:59 +0000
committerDimitry Andric <dim@FreeBSD.org>2016-02-21 13:53:59 +0000
commitbb5e33f003797b67974a8893f7f2930fc51b8210 (patch)
tree2ef96e4c81fca716906b41bbaef5978394533a07 /test/std/re/re.results/re.results.form/form1.pass.cpp
parent09a81ed06676bfa727cafe139f24ab2c076ecd04 (diff)
downloadsrc-bb5e33f003797b67974a8893f7f2930fc51b8210.tar.gz
src-bb5e33f003797b67974a8893f7f2930fc51b8210.zip
Notes
Notes: svn path=/vendor/libc++/dist/; revision=295852 svn path=/vendor/libc++/libc++-release_380-r262564/; revision=296363; tag=vendor/libc++/libc++-release_380-r262564
Diffstat (limited to 'test/std/re/re.results/re.results.form/form1.pass.cpp')
-rw-r--r--test/std/re/re.results/re.results.form/form1.pass.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/test/std/re/re.results/re.results.form/form1.pass.cpp b/test/std/re/re.results/re.results.form/form1.pass.cpp
index 9701c60ba77c..5b04c684fef1 100644
--- a/test/std/re/re.results/re.results.form/form1.pass.cpp
+++ b/test/std/re/re.results/re.results.form/form1.pass.cpp
@@ -38,6 +38,31 @@ int main()
{
std::match_results<const char*> m;
const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m, std::regex("cd((e)fg)hi",
+ std::regex_constants::nosubs)));
+
+ char out[100] = {0};
+ const char fmt[] = "prefix: $`, match: $&, suffix: $', m[1]: $1, m[2]: $2";
+ char* r = m.format(output_iterator<char*>(out),
+ fmt, fmt + std::char_traits<char>::length(fmt)).base();
+ assert(r == out + 54);
+ assert(std::string(out) == "prefix: ab, match: cdefghi, suffix: jk, m[1]: , m[2]: ");
+ }
+ {
+ std::match_results<const char*> m;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m, std::regex("cdefghi")));
+
+ char out[100] = {0};
+ const char fmt[] = "prefix: $`, match: $&, suffix: $', m[1]: $1, m[2]: $2";
+ char* r = m.format(output_iterator<char*>(out),
+ fmt, fmt + std::char_traits<char>::length(fmt)).base();
+ assert(r == out + 54);
+ assert(std::string(out) == "prefix: ab, match: cdefghi, suffix: jk, m[1]: , m[2]: ");
+ }
+ {
+ std::match_results<const char*> m;
+ const char s[] = "abcdefghijk";
assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
char out[100] = {0};
@@ -61,6 +86,33 @@ int main()
assert(r == out + 34);
assert(std::string(out) == "match: cdefghi, m[1]: efg, m[2]: e");
}
+ {
+ std::match_results<const char*> m;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m, std::regex("cd((e)fg)hi",
+ std::regex_constants::nosubs)));
+
+ char out[100] = {0};
+ const char fmt[] = "match: &, m[1]: \\1, m[2]: \\2";
+ char* r = m.format(output_iterator<char*>(out),
+ fmt, fmt + std::char_traits<char>::length(fmt),
+ std::regex_constants::format_sed).base();
+ assert(r == out + 30);
+ assert(std::string(out) == "match: cdefghi, m[1]: , m[2]: ");
+ }
+ {
+ std::match_results<const char*> m;
+ const char s[] = "abcdefghijk";
+ assert(std::regex_search(s, m, std::regex("cdefghi")));
+
+ char out[100] = {0};
+ const char fmt[] = "match: &, m[1]: \\1, m[2]: \\2";
+ char* r = m.format(output_iterator<char*>(out),
+ fmt, fmt + std::char_traits<char>::length(fmt),
+ std::regex_constants::format_sed).base();
+ assert(r == out + 30);
+ assert(std::string(out) == "match: cdefghi, m[1]: , m[2]: ");
+ }
{
std::match_results<const wchar_t*> m;