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,63 @@
//===----------------------------------------------------------------------===//
//
// 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_search(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 <string>
#include <list>
#include <cassert>
int main()
{
// This regex_iterator uses regex_search(__wrap_iter<_Iter> __first, ...)
// Test for http://llvm.org/bugs/show_bug.cgi?id=16240 fixed in r185273.
{
std::string s("aaaa a");
std::regex re("\\ba");
std::sregex_iterator it(s.begin(), s.end(), re);
std::sregex_iterator end = std::sregex_iterator();
assert(it->position(0) == 0);
assert(it->length(0) == 1);
++it;
assert(it->position(0) == 5);
assert(it->length(0) == 1);
++it;
assert(it == end);
}
// This regex_iterator uses regex_search(_BidirectionalIterator __first, ...)
{
std::string s("aaaa a");
std::list<char> l(s.begin(), s.end());
std::regex re("\\ba");
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>();
assert(it->position(0) == 0);
assert(it->length(0) == 1);
++it;
assert(it->position(0) == 5);
assert(it->length(0) == 1);
++it;
assert(it == end);
}
}

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_search(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_search(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,90 @@
//===----------------------------------------------------------------------===//
//
// 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_search(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_search(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_search(s, m, std::regex("tour\n\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) == 0);
assert(m.position(0) == 0);
assert(m.str(0) == "");
}
{
std::cmatch m;
const char s[] = "tournament";
assert(std::regex_search(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_search(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,58 @@
//===----------------------------------------------------------------------===//
//
// 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_search(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_search(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_search(s, m, std::regex("tour\n\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) == 0);
assert(m.position(0) == 0);
assert(m.str(0) == "");
}
}

View File

@@ -0,0 +1,28 @@
//===----------------------------------------------------------------------===//
//
// 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_search(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=11118
#include <regex>
#include <cassert>
int main()
{
assert(!std::regex_search("ab", std::regex("(?=^)b")));
assert(!std::regex_search("ab", std::regex("a(?=^)b")));
}

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 BidirectionalIterator, class Allocator, class charT, class traits>
// bool
// regex_search(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>
int main()
{
// Iterating over /^a/ should yield one instance at the beginning
// of the text.
const char *text = "aaa\naa";
std::regex re("^a");
std::cregex_iterator it(text, text+6, re);
std::cregex_iterator end = std::cregex_iterator();
assert(it->str() == "a");
assert(it->position(0) == 0);
assert(it->length(0) == 1);
++it;
assert(it == end);
}