diff options
| author | Howard Hinnant <hhinnant@apple.com> | 2010-07-13 21:48:06 +0000 |
|---|---|---|
| committer | Howard Hinnant <hhinnant@apple.com> | 2010-07-13 21:48:06 +0000 |
| commit | 8ab959c9614533f418cfdda4e52ad0af5722114d (patch) | |
| tree | d8b8c937809c8540f465131b71db5fda11e76df8 /libcxx/test | |
| parent | 549c9f7f9a4b0951c17a837f08e01f5c36512b54 (diff) | |
| download | bcm5719-llvm-8ab959c9614533f418cfdda4e52ad0af5722114d.tar.gz bcm5719-llvm-8ab959c9614533f418cfdda4e52ad0af5722114d.zip | |
Bracket expressions are working (lightly tested).
llvm-svn: 108280
Diffstat (limited to 'libcxx/test')
| -rw-r--r-- | libcxx/test/re/re.alg/re.alg.search/basic.pass.cpp | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/libcxx/test/re/re.alg/re.alg.search/basic.pass.cpp b/libcxx/test/re/re.alg/re.alg.search/basic.pass.cpp index df591ed5c92..10ea4572ee3 100644 --- a/libcxx/test/re/re.alg/re.alg.search/basic.pass.cpp +++ b/libcxx/test/re/re.alg/re.alg.search/basic.pass.cpp @@ -498,4 +498,105 @@ int main() std::regex_constants::basic))); assert(m.size() == 0); } + { + std::cmatch m; + const char s[] = "a"; + assert(std::regex_search(s, m, std::regex("^[a]$", + 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 == m[0].second); + assert(m.length(0) == 1); + assert(m.position(0) == 0); + assert(m.str(0) == "a"); + } + { + std::cmatch m; + const char s[] = "a"; + assert(std::regex_search(s, m, std::regex("^[ab]$", + 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 == m[0].second); + assert(m.length(0) == 1); + assert(m.position(0) == 0); + assert(m.str(0) == "a"); + } + { + std::cmatch m; + const char s[] = "c"; + assert(std::regex_search(s, m, std::regex("^[a-f]$", + 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 == m[0].second); + assert(m.length(0) == 1); + assert(m.position(0) == 0); + assert(m.str(0) == s); + } + { + std::cmatch m; + const char s[] = "g"; + assert(!std::regex_search(s, m, std::regex("^[a-f]$", + std::regex_constants::basic))); + assert(m.size() == 0); + } + { + std::cmatch m; + const char s[] = "Iraqi"; + assert(std::regex_search(s, m, std::regex("q[^u]", + 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 == m[0].second); + assert(m.length(0) == 2); + assert(m.position(0) == 3); + assert(m.str(0) == "qi"); + } + { + std::cmatch m; + const char s[] = "Iraq"; + assert(!std::regex_search(s, m, std::regex("q[^u]", + std::regex_constants::basic))); + assert(m.size() == 0); + } + { + std::cmatch m; + const char s[] = "AmB"; + assert(std::regex_search(s, m, std::regex("A[[:lower:]]B", + 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 == 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[] = "AMB"; + assert(!std::regex_search(s, m, std::regex("A[[:lower:]]B", + std::regex_constants::basic))); + assert(m.size() == 0); + } } |

