[cfe-commits] [libcxx] r109107 - in /libcxx/trunk: include/regex test/re/re.alg/re.alg.search/extended.pass.cpp
Howard Hinnant
hhinnant at apple.com
Thu Jul 22 07:12:20 PDT 2010
Author: hhinnant
Date: Thu Jul 22 09:12:20 2010
New Revision: 109107
URL: http://llvm.org/viewvc/llvm-project?rev=109107&view=rev
Log:
A few more tests for posix extended alternation
Modified:
libcxx/trunk/include/regex
libcxx/trunk/test/re/re.alg/re.alg.search/extended.pass.cpp
Modified: libcxx/trunk/include/regex
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/regex?rev=109107&r1=109106&r2=109107&view=diff
==============================================================================
--- libcxx/trunk/include/regex (original)
+++ libcxx/trunk/include/regex Thu Jul 22 09:12:20 2010
@@ -1596,10 +1596,10 @@
__alternate<_CharT>::__exec_split(bool __second, __state& __s) const
{
__s.__do_ = __state::__accept_but_not_consume;
- if (!__second)
- __s.__node_ = this->first();
- else
+ if (__second)
__s.__node_ = this->second();
+ else
+ __s.__node_ = this->first();
}
// __begin_marked_subexpression
Modified: libcxx/trunk/test/re/re.alg/re.alg.search/extended.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/re/re.alg/re.alg.search/extended.pass.cpp?rev=109107&r1=109106&r2=109107&view=diff
==============================================================================
--- libcxx/trunk/test/re/re.alg/re.alg.search/extended.pass.cpp (original)
+++ libcxx/trunk/test/re/re.alg/re.alg.search/extended.pass.cpp Thu Jul 22 09:12:20 2010
@@ -323,7 +323,7 @@
assert(!m.suffix().matched);
assert(m.suffix().first == m[0].second);
assert(m.suffix().second == m[0].second);
- assert(m.length(0) == sizeof(s)-1);
+ assert(m.length(0) == std::char_traits<char>::length(s));
assert(m.position(0) == 0);
assert(m.str(0) == s);
}
@@ -338,7 +338,7 @@
assert(!m.suffix().matched);
assert(m.suffix().first == m[0].second);
assert(m.suffix().second == m[0].second);
- assert(m.length(0) == sizeof(s)-1);
+ assert(m.length(0) == std::char_traits<char>::length(s));
assert(m.position(0) == 0);
assert(m.str(0) == s);
}
@@ -353,7 +353,7 @@
assert(!m.suffix().matched);
assert(m.suffix().first == m[0].second);
assert(m.suffix().second == m[0].second);
- assert(m.length(0) == sizeof(s)-1);
+ assert(m.length(0) == std::char_traits<char>::length(s));
assert(m.position(0) == 0);
assert(m.str(0) == s);
}
@@ -386,7 +386,7 @@
assert(!m.suffix().matched);
assert(m.suffix().first == m[0].second);
assert(m.suffix().second == m[0].second);
- assert(m.length(0) == sizeof(s)-1);
+ assert(m.length(0) == std::char_traits<char>::length(s));
assert(m.position(0) == 0);
assert(m.str(0) == s);
}
@@ -401,7 +401,7 @@
assert(!m.suffix().matched);
assert(m.suffix().first == m[0].second);
assert(m.suffix().second == m[0].second);
- assert(m.length(0) == sizeof(s)-1);
+ assert(m.length(0) == std::char_traits<char>::length(s));
assert(m.position(0) == 0);
assert(m.str(0) == s);
}
@@ -416,7 +416,7 @@
assert(!m.suffix().matched);
assert(m.suffix().first == m[0].second);
assert(m.suffix().second == m[0].second);
- assert(m.length(0) == sizeof(s)-1);
+ assert(m.length(0) == std::char_traits<char>::length(s));
assert(m.position(0) == 0);
assert(m.str(0) == s);
}
@@ -438,8 +438,43 @@
assert(!m.suffix().matched);
assert(m.suffix().first == m[0].second);
assert(m.suffix().second == m[0].second);
- assert(m.length(0) == sizeof(s)-1);
+ assert(m.length(0) == std::char_traits<char>::length(s));
assert(m.position(0) == 0);
assert(m.str(0) == s);
}
+ {
+ std::cmatch m;
+ const char s[] = "tournamenttotour";
+ assert(std::regex_search(s, m, std::regex("(tour|to|tournament)+",
+ std::regex_constants::extended | std::regex_constants::nosubs)));
+ assert(m.size() == 1);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ }
+ {
+ std::cmatch m;
+ const char s[] = "ttotour";
+ assert(std::regex_search(s, m, std::regex("(tour|to|t)+",
+ std::regex_constants::extended)));
+ assert(m.size() == 2);
+ assert(!m.prefix().matched);
+ assert(m.prefix().first == s);
+ assert(m.prefix().second == m[0].first);
+ assert(!m.suffix().matched);
+ assert(m.suffix().first == m[0].second);
+ assert(m.suffix().second == m[0].second);
+ assert(m.length(0) == std::char_traits<char>::length(s));
+ assert(m.position(0) == 0);
+ assert(m.str(0) == s);
+ assert(m.length(1) == 4);
+ assert(m.position(1) == 3);
+ assert(m.str(1) == "tour");
+ }
}
More information about the cfe-commits
mailing list