[libcxx] Remove use of uniform initialization from regex tests so that they compile in C++03.

Reviewers: danalbert, jroelofs, mclow.lists

Reviewed By: mclow.lists

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D5957

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@220707 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Fiselier
2014-10-27 19:29:32 +00:00
parent b991975439
commit e4e883e6c8
5 changed files with 38 additions and 38 deletions

View File

@@ -27,10 +27,10 @@
int main() int main()
{ {
{ {
std::regex re{"^(?=(.))a$"}; std::regex re("^(?=(.))a$");
assert(re.mark_count() == 1); assert(re.mark_count() == 1);
std::string s{"a"}; std::string s("a");
std::smatch m; std::smatch m;
assert(std::regex_match(s, m, re)); assert(std::regex_match(s, m, re));
assert(m.size() == 2); assert(m.size() == 2);
@@ -39,10 +39,10 @@ int main()
} }
{ {
std::regex re{"^(a)(?=(.))(b)$"}; std::regex re("^(a)(?=(.))(b)$");
assert(re.mark_count() == 3); assert(re.mark_count() == 3);
std::string s{"ab"}; std::string s("ab");
std::smatch m; std::smatch m;
assert(std::regex_match(s, m, re)); assert(std::regex_match(s, m, re));
assert(m.size() == 4); assert(m.size() == 4);
@@ -53,10 +53,10 @@ int main()
} }
{ {
std::regex re{"^(.)(?=(.)(?=.(.)))(...)$"}; std::regex re("^(.)(?=(.)(?=.(.)))(...)$");
assert(re.mark_count() == 4); assert(re.mark_count() == 4);
std::string s{"abcd"}; std::string s("abcd");
std::smatch m; std::smatch m;
assert(std::regex_match(s, m, re)); assert(std::regex_match(s, m, re));
assert(m.size() == 5); assert(m.size() == 5);
@@ -68,10 +68,10 @@ int main()
} }
{ {
std::regex re{"^(a)(?!([^b]))(.c)$"}; std::regex re("^(a)(?!([^b]))(.c)$");
assert(re.mark_count() == 3); assert(re.mark_count() == 3);
std::string s{"abc"}; std::string s("abc");
std::smatch m; std::smatch m;
assert(std::regex_match(s, m, re)); assert(std::regex_match(s, m, re));
assert(m.size() == 4); assert(m.size() == 4);
@@ -82,10 +82,10 @@ int main()
} }
{ {
std::regex re{"^(?!((b)))(?=(.))(?!(abc)).b$"}; std::regex re("^(?!((b)))(?=(.))(?!(abc)).b$");
assert(re.mark_count() == 4); assert(re.mark_count() == 4);
std::string s{"ab"}; std::string s("ab");
std::smatch m; std::smatch m;
assert(std::regex_match(s, m, re)); assert(std::regex_match(s, m, re));
assert(m.size() == 5); assert(m.size() == 5);

View File

@@ -25,9 +25,9 @@
void void
test1() test1()
{ {
std::string re{"\\{a\\}"}; std::string re("\\{a\\}");
std::string target{"{a}"}; std::string target("{a}");
std::regex regex{re}; std::regex regex(re);
std::smatch smatch; std::smatch smatch;
assert((std::regex_match(target, smatch, regex))); assert((std::regex_match(target, smatch, regex)));
} }
@@ -35,9 +35,9 @@ test1()
void void
test2() test2()
{ {
std::string re{"\\{a\\}"}; std::string re("\\{a\\}");
std::string target{"{a}"}; std::string target("{a}");
std::regex regex{re, std::regex::extended}; std::regex regex(re, std::regex::extended);
std::smatch smatch; std::smatch smatch;
assert((std::regex_match(target, smatch, regex))); assert((std::regex_match(target, smatch, regex)));
} }
@@ -45,9 +45,9 @@ test2()
void void
test3() test3()
{ {
std::string re{"\\{a\\}"}; std::string re("\\{a\\}");
std::string target{"{a}"}; std::string target("{a}");
std::regex regex{re, std::regex::awk}; std::regex regex(re, std::regex::awk);
std::smatch smatch; std::smatch smatch;
assert((std::regex_match(target, smatch, regex))); assert((std::regex_match(target, smatch, regex)));
} }
@@ -55,9 +55,9 @@ test3()
void void
test4() test4()
{ {
std::string re{"\\{a\\}"}; std::string re("\\{a\\}");
std::string target{"{a}"}; std::string target("{a}");
std::regex regex{re, std::regex::egrep}; std::regex regex(re, std::regex::egrep);
std::smatch smatch; std::smatch smatch;
assert((std::regex_match(target, smatch, regex))); assert((std::regex_match(target, smatch, regex)));
} }

View File

@@ -26,10 +26,10 @@ int main()
// This regex_iterator uses regex_search(__wrap_iter<_Iter> __first, ...) // This regex_iterator uses regex_search(__wrap_iter<_Iter> __first, ...)
// Test for http://llvm.org/bugs/show_bug.cgi?id=16240 fixed in r185273. // Test for http://llvm.org/bugs/show_bug.cgi?id=16240 fixed in r185273.
{ {
std::string s{"aaaa a"}; std::string s("aaaa a");
std::regex re{"\\ba"}; std::regex re("\\ba");
std::sregex_iterator it{s.begin(), s.end(), re}; std::sregex_iterator it(s.begin(), s.end(), re);
std::sregex_iterator end{}; std::sregex_iterator end = std::sregex_iterator();
assert(it->position(0) == 0); assert(it->position(0) == 0);
assert(it->length(0) == 1); assert(it->length(0) == 1);
@@ -44,11 +44,11 @@ int main()
// This regex_iterator uses regex_search(_BidirectionalIterator __first, ...) // This regex_iterator uses regex_search(_BidirectionalIterator __first, ...)
{ {
std::string s{"aaaa a"}; std::string s("aaaa a");
std::list<char> l{s.begin(), s.end()}; std::list<char> l(s.begin(), s.end());
std::regex re{"\\ba"}; std::regex re("\\ba");
std::regex_iterator<std::list<char>::iterator> it{l.begin(), l.end(), re}; std::regex_iterator<std::list<char>::iterator> it(l.begin(), l.end(), re);
std::regex_iterator<std::list<char>::iterator> end{}; std::regex_iterator<std::list<char>::iterator> end = std::regex_iterator<std::list<char>::iterator>();
assert(it->position(0) == 0); assert(it->position(0) == 0);
assert(it->length(0) == 1); assert(it->length(0) == 1);

View File

@@ -25,9 +25,9 @@ int main()
// of the text. // of the text.
const char *text = "aaa\naa"; const char *text = "aaa\naa";
std::regex re{"^a"}; std::regex re("^a");
std::cregex_iterator it{text, text+6, re}; std::cregex_iterator it(text, text+6, re);
std::cregex_iterator end{}; std::cregex_iterator end = std::cregex_iterator();
assert(it->str() == "a"); assert(it->str() == "a");
assert(it->position(0) == 0); assert(it->position(0) == 0);

View File

@@ -21,8 +21,8 @@ int main()
{ {
using std::regex_constants::awk; using std::regex_constants::awk;
assert(std::regex_match("\4", std::regex{"\\4", awk})); assert(std::regex_match("\4", std::regex("\\4", awk)));
assert(std::regex_match("\41", std::regex{"\\41", awk})); assert(std::regex_match("\41", std::regex("\\41", awk)));
assert(std::regex_match("\141", std::regex{"\\141", awk})); assert(std::regex_match("\141", std::regex("\\141", awk)));
assert(std::regex_match("\1411", std::regex{"\\1411", awk})); assert(std::regex_match("\1411", std::regex("\\1411", awk)));
} }