Move test into test/std subdirectory.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@224658 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Fiselier
2014-12-20 01:40:03 +00:00
parent 669a8a5a19
commit a90c6dd460
4817 changed files with 13 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,38 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <regex>
// template <class ST, class SA, class Allocator, class charT, class traits>
// bool regex_match(const basic_string<charT, ST, SA>&&,
// match_results<
// typename basic_string<charT, ST, SA>::const_iterator,
// Allocator>&,
// const basic_regex<charT, traits>&,
// regex_constants::match_flag_type =
// regex_constants::match_default) = delete;
#include <__config>
#if _LIBCPP_STD_VER <= 11
#error
#else
#include <regex>
#include <cassert>
int main()
{
{
std::smatch m;
std::regex re{"*"};
std::regex_match(std::string("abcde"), m, re);
}
}
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,81 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <regex>
// template <class BidirectionalIterator, class Allocator, class charT, class traits>
// bool
// regex_match(BidirectionalIterator first, BidirectionalIterator last,
// match_results<BidirectionalIterator, Allocator>& m,
// const basic_regex<charT, traits>& e,
// regex_constants::match_flag_type flags = regex_constants::match_default);
#include <regex>
#include <cassert>
#include "test_iterators.h"
int main()
{
{
std::cmatch m;
const char s[] = "tournament";
assert(std::regex_match(s, m, std::regex("tour\nto\ntournament",
std::regex_constants::egrep)));
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 + std::char_traits<char>::length(s));
assert(m.length(0) == 10);
assert(m.position(0) == 0);
assert(m.str(0) == "tournament");
}
{
std::cmatch m;
const char s[] = "ment";
assert(!std::regex_match(s, m, std::regex("tour\n\ntournament",
std::regex_constants::egrep)));
assert(m.size() == 0);
}
{
std::cmatch m;
const char s[] = "tournament";
assert(std::regex_match(s, m, std::regex("(tour|to|tournament)+\ntourna",
std::regex_constants::egrep)));
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 == s + std::char_traits<char>::length(s));
assert(m.length(0) == 10);
assert(m.position(0) == 0);
assert(m.str(0) == "tournament");
}
{
std::cmatch m;
const char s[] = "tourna";
assert(std::regex_match(s, m, std::regex("(tour|to|tournament)+\ntourna",
std::regex_constants::egrep)));
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 == s + std::char_traits<char>::length(s));
assert(m.length(0) == 6);
assert(m.position(0) == 0);
assert(m.str(0) == "tourna");
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,49 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <regex>
// template <class BidirectionalIterator, class Allocator, class charT, class traits>
// bool
// regex_match(BidirectionalIterator first, BidirectionalIterator last,
// match_results<BidirectionalIterator, Allocator>& m,
// const basic_regex<charT, traits>& e,
// regex_constants::match_flag_type flags = regex_constants::match_default);
#include <regex>
#include <cassert>
#include "test_iterators.h"
int main()
{
{
std::cmatch m;
const char s[] = "tournament";
assert(std::regex_match(s, m, std::regex("tour\nto\ntournament",
std::regex_constants::grep)));
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 + std::char_traits<char>::length(s));
assert(m.length(0) == 10);
assert(m.position(0) == 0);
assert(m.str(0) == "tournament");
}
{
std::cmatch m;
const char s[] = "ment";
assert(!std::regex_match(s, m, std::regex("tour\n\ntournament",
std::regex_constants::grep)));
assert(m.size() == 0);
}
}

View File

@@ -0,0 +1,98 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <regex>
// template <class BidirectionalIterator, class Allocator, class charT, class traits>
// bool
// regex_match(BidirectionalIterator first, BidirectionalIterator last,
// match_results<BidirectionalIterator, Allocator>& m,
// const basic_regex<charT, traits>& e,
// regex_constants::match_flag_type flags = regex_constants::match_default);
// std::regex in ECMAScript mode should not ignore capture groups inside lookahead assertions.
// For example, matching /(?=(a))(a)/ to "a" should yield two captures: \1 = "a", \2 = "a"
#include <regex>
#include <cassert>
#include "test_iterators.h"
int main()
{
{
std::regex re("^(?=(.))a$");
assert(re.mark_count() == 1);
std::string s("a");
std::smatch m;
assert(std::regex_match(s, m, re));
assert(m.size() == 2);
assert(m[0] == "a");
assert(m[1] == "a");
}
{
std::regex re("^(a)(?=(.))(b)$");
assert(re.mark_count() == 3);
std::string s("ab");
std::smatch m;
assert(std::regex_match(s, m, re));
assert(m.size() == 4);
assert(m[0] == "ab");
assert(m[1] == "a");
assert(m[2] == "b");
assert(m[3] == "b");
}
{
std::regex re("^(.)(?=(.)(?=.(.)))(...)$");
assert(re.mark_count() == 4);
std::string s("abcd");
std::smatch m;
assert(std::regex_match(s, m, re));
assert(m.size() == 5);
assert(m[0] == "abcd");
assert(m[1] == "a");
assert(m[2] == "b");
assert(m[3] == "d");
assert(m[4] == "bcd");
}
{
std::regex re("^(a)(?!([^b]))(.c)$");
assert(re.mark_count() == 3);
std::string s("abc");
std::smatch m;
assert(std::regex_match(s, m, re));
assert(m.size() == 4);
assert(m[0] == "abc");
assert(m[1] == "a");
assert(m[2] == "");
assert(m[3] == "bc");
}
{
std::regex re("^(?!((b)))(?=(.))(?!(abc)).b$");
assert(re.mark_count() == 4);
std::string s("ab");
std::smatch m;
assert(std::regex_match(s, m, re));
assert(m.size() == 5);
assert(m[0] == "ab");
assert(m[1] == "");
assert(m[2] == "");
assert(m[3] == "a");
assert(m[4] == "");
}
}

View File

@@ -0,0 +1,72 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <regex>
// template <class BidirectionalIterator, class Allocator, class charT, class traits>
// bool
// regex_match(BidirectionalIterator first, BidirectionalIterator last,
// match_results<BidirectionalIterator, Allocator>& m,
// const basic_regex<charT, traits>& e,
// regex_constants::match_flag_type flags = regex_constants::match_default);
// http://llvm.org/bugs/show_bug.cgi?id=16135
#include <string>
#include <regex>
#include <cassert>
void
test1()
{
std::string re("\\{a\\}");
std::string target("{a}");
std::regex regex(re);
std::smatch smatch;
assert((std::regex_match(target, smatch, regex)));
}
void
test2()
{
std::string re("\\{a\\}");
std::string target("{a}");
std::regex regex(re, std::regex::extended);
std::smatch smatch;
assert((std::regex_match(target, smatch, regex)));
}
void
test3()
{
std::string re("\\{a\\}");
std::string target("{a}");
std::regex regex(re, std::regex::awk);
std::smatch smatch;
assert((std::regex_match(target, smatch, regex)));
}
void
test4()
{
std::string re("\\{a\\}");
std::string target("{a}");
std::regex regex(re, std::regex::egrep);
std::smatch smatch;
assert((std::regex_match(target, smatch, regex)));
}
int
main()
{
test1();
test2();
test3();
test4();
}