weekly update to by-chapter-summary, plus left and right anchor support in basic posix.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@107938 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Howard Hinnant
2010-07-09 00:15:26 +00:00
parent e77aa5e7f4
commit 37f9f9c587
3 changed files with 123 additions and 36 deletions

View File

@@ -157,4 +157,76 @@ int main()
assert(m.position(2) == 4);
assert(m.str(2) == "e");
}
{
std::cmatch m;
const char s[] = "abc";
assert(std::regex_search(s, m, std::regex("^abc", std::regex_constants::basic)));
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 == s+3);
assert(m.length(0) == 3);
assert(m.position(0) == 0);
assert(m.str(0) == s);
}
{
std::cmatch m;
const char s[] = "abcd";
assert(std::regex_search(s, m, std::regex("^abc", std::regex_constants::basic)));
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 == s+4);
assert(m.length(0) == 3);
assert(m.position(0) == 0);
assert(m.str(0) == "abc");
}
{
std::cmatch m;
const char s[] = "aabc";
assert(!std::regex_search(s, m, std::regex("^abc", std::regex_constants::basic)));
assert(m.size() == 0);
}
{
std::cmatch m;
const char s[] = "abc";
assert(std::regex_search(s, m, std::regex("abc$", std::regex_constants::basic)));
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 == s+3);
assert(m.length(0) == 3);
assert(m.position(0) == 0);
assert(m.str(0) == s);
}
{
std::cmatch m;
const char s[] = "efabc";
assert(std::regex_search(s, m, std::regex("abc$", std::regex_constants::basic)));
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 == s+5);
assert(m.length(0) == 3);
assert(m.position(0) == 2);
assert(m.str(0) == s+2);
}
{
std::cmatch m;
const char s[] = "efabcg";
assert(!std::regex_search(s, m, std::regex("abc$", std::regex_constants::basic)));
assert(m.size() == 0);
}
}