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:
12
test/std/re/nothing_to_do.pass.cpp
Normal file
12
test/std/re/nothing_to_do.pass.cpp
Normal file
@@ -0,0 +1,12 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
12
test/std/re/re.alg/nothing_to_do.pass.cpp
Normal file
12
test/std/re/re.alg/nothing_to_do.pass.cpp
Normal file
@@ -0,0 +1,12 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
1389
test/std/re/re.alg/re.alg.match/awk.pass.cpp
Normal file
1389
test/std/re/re.alg/re.alg.match/awk.pass.cpp
Normal file
File diff suppressed because it is too large
Load Diff
38
test/std/re/re.alg/re.alg.match/basic.fail.cpp
Normal file
38
test/std/re/re.alg/re.alg.match/basic.fail.cpp
Normal 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
|
1366
test/std/re/re.alg/re.alg.match/basic.pass.cpp
Normal file
1366
test/std/re/re.alg/re.alg.match/basic.pass.cpp
Normal file
File diff suppressed because it is too large
Load Diff
1348
test/std/re/re.alg/re.alg.match/ecma.pass.cpp
Normal file
1348
test/std/re/re.alg/re.alg.match/ecma.pass.cpp
Normal file
File diff suppressed because it is too large
Load Diff
81
test/std/re/re.alg/re.alg.match/egrep.pass.cpp
Normal file
81
test/std/re/re.alg/re.alg.match/egrep.pass.cpp
Normal 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");
|
||||
}
|
||||
}
|
1362
test/std/re/re.alg/re.alg.match/extended.pass.cpp
Normal file
1362
test/std/re/re.alg/re.alg.match/extended.pass.cpp
Normal file
File diff suppressed because it is too large
Load Diff
49
test/std/re/re.alg/re.alg.match/grep.pass.cpp
Normal file
49
test/std/re/re.alg/re.alg.match/grep.pass.cpp
Normal 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);
|
||||
}
|
||||
}
|
98
test/std/re/re.alg/re.alg.match/lookahead_capture.pass.cpp
Normal file
98
test/std/re/re.alg/re.alg.match/lookahead_capture.pass.cpp
Normal 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] == "");
|
||||
}
|
||||
}
|
@@ -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();
|
||||
}
|
107
test/std/re/re.alg/re.alg.replace/test1.pass.cpp
Normal file
107
test/std/re/re.alg/re.alg.replace/test1.pass.cpp
Normal file
@@ -0,0 +1,107 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 OutputIterator, class BidirectionalIterator,
|
||||
// class traits, class charT, class ST, class SA>
|
||||
// OutputIterator
|
||||
// regex_replace(OutputIterator out,
|
||||
// BidirectionalIterator first, BidirectionalIterator last,
|
||||
// const basic_regex<charT, traits>& e,
|
||||
// const basic_string<charT, ST, SA>& fmt,
|
||||
// regex_constants::match_flag_type flags =
|
||||
// regex_constants::match_default);
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::regex phone_numbers("\\d{3}-\\d{4}");
|
||||
const char phone_book[] = "555-1234, 555-2345, 555-3456";
|
||||
typedef output_iterator<char*> Out;
|
||||
typedef bidirectional_iterator<const char*> Bi;
|
||||
char buf[100] = {0};
|
||||
Out r = std::regex_replace(Out(buf), Bi(std::begin(phone_book)),
|
||||
Bi(std::end(phone_book)-1), phone_numbers,
|
||||
std::string("123-$&"));
|
||||
assert(r.base() == buf+40);
|
||||
assert(buf == std::string("123-555-1234, 123-555-2345, 123-555-3456"));
|
||||
}
|
||||
{
|
||||
std::regex phone_numbers("\\d{3}-\\d{4}");
|
||||
const char phone_book[] = "555-1234, 555-2345, 555-3456";
|
||||
typedef output_iterator<char*> Out;
|
||||
typedef bidirectional_iterator<const char*> Bi;
|
||||
char buf[100] = {0};
|
||||
Out r = std::regex_replace(Out(buf), Bi(std::begin(phone_book)),
|
||||
Bi(std::end(phone_book)-1), phone_numbers,
|
||||
std::string("123-$&"),
|
||||
std::regex_constants::format_sed);
|
||||
assert(r.base() == buf+43);
|
||||
assert(buf == std::string("123-$555-1234, 123-$555-2345, 123-$555-3456"));
|
||||
}
|
||||
{
|
||||
std::regex phone_numbers("\\d{3}-\\d{4}");
|
||||
const char phone_book[] = "555-1234, 555-2345, 555-3456";
|
||||
typedef output_iterator<char*> Out;
|
||||
typedef bidirectional_iterator<const char*> Bi;
|
||||
char buf[100] = {0};
|
||||
Out r = std::regex_replace(Out(buf), Bi(std::begin(phone_book)),
|
||||
Bi(std::end(phone_book)-1), phone_numbers,
|
||||
std::string("123-&"),
|
||||
std::regex_constants::format_sed);
|
||||
assert(r.base() == buf+40);
|
||||
assert(buf == std::string("123-555-1234, 123-555-2345, 123-555-3456"));
|
||||
}
|
||||
{
|
||||
std::regex phone_numbers("\\d{3}-\\d{4}");
|
||||
const char phone_book[] = "555-1234, 555-2345, 555-3456";
|
||||
typedef output_iterator<char*> Out;
|
||||
typedef bidirectional_iterator<const char*> Bi;
|
||||
char buf[100] = {0};
|
||||
Out r = std::regex_replace(Out(buf), Bi(std::begin(phone_book)),
|
||||
Bi(std::end(phone_book)-1), phone_numbers,
|
||||
std::string("123-$&"),
|
||||
std::regex_constants::format_no_copy);
|
||||
assert(r.base() == buf+36);
|
||||
assert(buf == std::string("123-555-1234123-555-2345123-555-3456"));
|
||||
}
|
||||
{
|
||||
std::regex phone_numbers("\\d{3}-\\d{4}");
|
||||
const char phone_book[] = "555-1234, 555-2345, 555-3456";
|
||||
typedef output_iterator<char*> Out;
|
||||
typedef bidirectional_iterator<const char*> Bi;
|
||||
char buf[100] = {0};
|
||||
Out r = std::regex_replace(Out(buf), Bi(std::begin(phone_book)),
|
||||
Bi(std::end(phone_book)-1), phone_numbers,
|
||||
std::string("123-$&"),
|
||||
std::regex_constants::format_first_only);
|
||||
assert(r.base() == buf+32);
|
||||
assert(buf == std::string("123-555-1234, 555-2345, 555-3456"));
|
||||
}
|
||||
{
|
||||
std::regex phone_numbers("\\d{3}-\\d{4}");
|
||||
const char phone_book[] = "555-1234, 555-2345, 555-3456";
|
||||
typedef output_iterator<char*> Out;
|
||||
typedef bidirectional_iterator<const char*> Bi;
|
||||
char buf[100] = {0};
|
||||
Out r = std::regex_replace(Out(buf), Bi(std::begin(phone_book)),
|
||||
Bi(std::end(phone_book)-1), phone_numbers,
|
||||
std::string("123-$&"),
|
||||
std::regex_constants::format_first_only |
|
||||
std::regex_constants::format_no_copy);
|
||||
assert(r.base() == buf+12);
|
||||
assert(buf == std::string("123-555-1234"));
|
||||
}
|
||||
}
|
107
test/std/re/re.alg/re.alg.replace/test2.pass.cpp
Normal file
107
test/std/re/re.alg/re.alg.replace/test2.pass.cpp
Normal file
@@ -0,0 +1,107 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 OutputIterator, class BidirectionalIterator,
|
||||
// class traits, class charT, class ST, class SA>
|
||||
// OutputIterator
|
||||
// regex_replace(OutputIterator out,
|
||||
// BidirectionalIterator first, BidirectionalIterator last,
|
||||
// const basic_regex<charT, traits>& e,
|
||||
// const charT* fmt,
|
||||
// regex_constants::match_flag_type flags =
|
||||
// regex_constants::match_default);
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::regex phone_numbers("\\d{3}-\\d{4}");
|
||||
const char phone_book[] = "555-1234, 555-2345, 555-3456";
|
||||
typedef output_iterator<char*> Out;
|
||||
typedef bidirectional_iterator<const char*> Bi;
|
||||
char buf[100] = {0};
|
||||
Out r = std::regex_replace(Out(buf), Bi(std::begin(phone_book)),
|
||||
Bi(std::end(phone_book)-1), phone_numbers,
|
||||
"123-$&");
|
||||
assert(r.base() == buf+40);
|
||||
assert(buf == std::string("123-555-1234, 123-555-2345, 123-555-3456"));
|
||||
}
|
||||
{
|
||||
std::regex phone_numbers("\\d{3}-\\d{4}");
|
||||
const char phone_book[] = "555-1234, 555-2345, 555-3456";
|
||||
typedef output_iterator<char*> Out;
|
||||
typedef bidirectional_iterator<const char*> Bi;
|
||||
char buf[100] = {0};
|
||||
Out r = std::regex_replace(Out(buf), Bi(std::begin(phone_book)),
|
||||
Bi(std::end(phone_book)-1), phone_numbers,
|
||||
"123-$&",
|
||||
std::regex_constants::format_sed);
|
||||
assert(r.base() == buf+43);
|
||||
assert(buf == std::string("123-$555-1234, 123-$555-2345, 123-$555-3456"));
|
||||
}
|
||||
{
|
||||
std::regex phone_numbers("\\d{3}-\\d{4}");
|
||||
const char phone_book[] = "555-1234, 555-2345, 555-3456";
|
||||
typedef output_iterator<char*> Out;
|
||||
typedef bidirectional_iterator<const char*> Bi;
|
||||
char buf[100] = {0};
|
||||
Out r = std::regex_replace(Out(buf), Bi(std::begin(phone_book)),
|
||||
Bi(std::end(phone_book)-1), phone_numbers,
|
||||
"123-&",
|
||||
std::regex_constants::format_sed);
|
||||
assert(r.base() == buf+40);
|
||||
assert(buf == std::string("123-555-1234, 123-555-2345, 123-555-3456"));
|
||||
}
|
||||
{
|
||||
std::regex phone_numbers("\\d{3}-\\d{4}");
|
||||
const char phone_book[] = "555-1234, 555-2345, 555-3456";
|
||||
typedef output_iterator<char*> Out;
|
||||
typedef bidirectional_iterator<const char*> Bi;
|
||||
char buf[100] = {0};
|
||||
Out r = std::regex_replace(Out(buf), Bi(std::begin(phone_book)),
|
||||
Bi(std::end(phone_book)-1), phone_numbers,
|
||||
"123-$&",
|
||||
std::regex_constants::format_no_copy);
|
||||
assert(r.base() == buf+36);
|
||||
assert(buf == std::string("123-555-1234123-555-2345123-555-3456"));
|
||||
}
|
||||
{
|
||||
std::regex phone_numbers("\\d{3}-\\d{4}");
|
||||
const char phone_book[] = "555-1234, 555-2345, 555-3456";
|
||||
typedef output_iterator<char*> Out;
|
||||
typedef bidirectional_iterator<const char*> Bi;
|
||||
char buf[100] = {0};
|
||||
Out r = std::regex_replace(Out(buf), Bi(std::begin(phone_book)),
|
||||
Bi(std::end(phone_book)-1), phone_numbers,
|
||||
"123-$&",
|
||||
std::regex_constants::format_first_only);
|
||||
assert(r.base() == buf+32);
|
||||
assert(buf == std::string("123-555-1234, 555-2345, 555-3456"));
|
||||
}
|
||||
{
|
||||
std::regex phone_numbers("\\d{3}-\\d{4}");
|
||||
const char phone_book[] = "555-1234, 555-2345, 555-3456";
|
||||
typedef output_iterator<char*> Out;
|
||||
typedef bidirectional_iterator<const char*> Bi;
|
||||
char buf[100] = {0};
|
||||
Out r = std::regex_replace(Out(buf), Bi(std::begin(phone_book)),
|
||||
Bi(std::end(phone_book)-1), phone_numbers,
|
||||
"123-$&",
|
||||
std::regex_constants::format_first_only |
|
||||
std::regex_constants::format_no_copy);
|
||||
assert(r.base() == buf+12);
|
||||
assert(buf == std::string("123-555-1234"));
|
||||
}
|
||||
}
|
73
test/std/re/re.alg/re.alg.replace/test3.pass.cpp
Normal file
73
test/std/re/re.alg/re.alg.replace/test3.pass.cpp
Normal file
@@ -0,0 +1,73 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 traits, class charT, class ST, class SA, class FST, class FSA>>
|
||||
// basic_string<charT, ST, SA>
|
||||
// regex_replace(const basic_string<charT, ST, SA>& s,
|
||||
// const basic_regex<charT, traits>& e,
|
||||
// const basic_string<charT, FST, FSA>& fmt,
|
||||
// regex_constants::match_flag_type flags =
|
||||
// regex_constants::match_default);
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::regex phone_numbers("\\d{3}-\\d{4}");
|
||||
std::string phone_book("555-1234, 555-2345, 555-3456");
|
||||
std::string r = std::regex_replace(phone_book, phone_numbers,
|
||||
std::string("123-$&"));
|
||||
assert(r == "123-555-1234, 123-555-2345, 123-555-3456");
|
||||
}
|
||||
{
|
||||
std::regex phone_numbers("\\d{3}-\\d{4}");
|
||||
std::string phone_book("555-1234, 555-2345, 555-3456");
|
||||
std::string r = std::regex_replace(phone_book, phone_numbers,
|
||||
std::string("123-$&"),
|
||||
std::regex_constants::format_sed);
|
||||
assert(r == "123-$555-1234, 123-$555-2345, 123-$555-3456");
|
||||
}
|
||||
{
|
||||
std::regex phone_numbers("\\d{3}-\\d{4}");
|
||||
std::string phone_book("555-1234, 555-2345, 555-3456");
|
||||
std::string r = std::regex_replace(phone_book, phone_numbers,
|
||||
std::string("123-&"),
|
||||
std::regex_constants::format_sed);
|
||||
assert(r == "123-555-1234, 123-555-2345, 123-555-3456");
|
||||
}
|
||||
{
|
||||
std::regex phone_numbers("\\d{3}-\\d{4}");
|
||||
std::string phone_book("555-1234, 555-2345, 555-3456");
|
||||
std::string r = std::regex_replace(phone_book, phone_numbers,
|
||||
std::string("123-$&"),
|
||||
std::regex_constants::format_no_copy);
|
||||
assert(r == "123-555-1234123-555-2345123-555-3456");
|
||||
}
|
||||
{
|
||||
std::regex phone_numbers("\\d{3}-\\d{4}");
|
||||
std::string phone_book("555-1234, 555-2345, 555-3456");
|
||||
std::string r = std::regex_replace(phone_book, phone_numbers,
|
||||
std::string("123-$&"),
|
||||
std::regex_constants::format_first_only);
|
||||
assert(r == "123-555-1234, 555-2345, 555-3456");
|
||||
}
|
||||
{
|
||||
std::regex phone_numbers("\\d{3}-\\d{4}");
|
||||
std::string phone_book("555-1234, 555-2345, 555-3456");
|
||||
std::string r = std::regex_replace(phone_book, phone_numbers,
|
||||
std::string("123-$&"),
|
||||
std::regex_constants::format_first_only |
|
||||
std::regex_constants::format_no_copy);
|
||||
assert(r == "123-555-1234");
|
||||
}
|
||||
}
|
72
test/std/re/re.alg/re.alg.replace/test4.pass.cpp
Normal file
72
test/std/re/re.alg/re.alg.replace/test4.pass.cpp
Normal 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 traits, class charT, class ST, class SA>
|
||||
// basic_string<charT, ST, SA>
|
||||
// regex_replace(const basic_string<charT, ST, SA>& s,
|
||||
// const basic_regex<charT, traits>& e, const charT* fmt,
|
||||
// regex_constants::match_flag_type flags =
|
||||
// regex_constants::match_default);
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::regex phone_numbers("\\d{3}-\\d{4}");
|
||||
std::string phone_book("555-1234, 555-2345, 555-3456");
|
||||
std::string r = std::regex_replace(phone_book, phone_numbers,
|
||||
"123-$&");
|
||||
assert(r == "123-555-1234, 123-555-2345, 123-555-3456");
|
||||
}
|
||||
{
|
||||
std::regex phone_numbers("\\d{3}-\\d{4}");
|
||||
std::string phone_book("555-1234, 555-2345, 555-3456");
|
||||
std::string r = std::regex_replace(phone_book, phone_numbers,
|
||||
"123-$&",
|
||||
std::regex_constants::format_sed);
|
||||
assert(r == "123-$555-1234, 123-$555-2345, 123-$555-3456");
|
||||
}
|
||||
{
|
||||
std::regex phone_numbers("\\d{3}-\\d{4}");
|
||||
std::string phone_book("555-1234, 555-2345, 555-3456");
|
||||
std::string r = std::regex_replace(phone_book, phone_numbers,
|
||||
"123-&",
|
||||
std::regex_constants::format_sed);
|
||||
assert(r == "123-555-1234, 123-555-2345, 123-555-3456");
|
||||
}
|
||||
{
|
||||
std::regex phone_numbers("\\d{3}-\\d{4}");
|
||||
std::string phone_book("555-1234, 555-2345, 555-3456");
|
||||
std::string r = std::regex_replace(phone_book, phone_numbers,
|
||||
"123-$&",
|
||||
std::regex_constants::format_no_copy);
|
||||
assert(r == "123-555-1234123-555-2345123-555-3456");
|
||||
}
|
||||
{
|
||||
std::regex phone_numbers("\\d{3}-\\d{4}");
|
||||
std::string phone_book("555-1234, 555-2345, 555-3456");
|
||||
std::string r = std::regex_replace(phone_book, phone_numbers,
|
||||
"123-$&",
|
||||
std::regex_constants::format_first_only);
|
||||
assert(r == "123-555-1234, 555-2345, 555-3456");
|
||||
}
|
||||
{
|
||||
std::regex phone_numbers("\\d{3}-\\d{4}");
|
||||
std::string phone_book("555-1234, 555-2345, 555-3456");
|
||||
std::string r = std::regex_replace(phone_book, phone_numbers,
|
||||
"123-$&",
|
||||
std::regex_constants::format_first_only |
|
||||
std::regex_constants::format_no_copy);
|
||||
assert(r == "123-555-1234");
|
||||
}
|
||||
}
|
73
test/std/re/re.alg/re.alg.replace/test5.pass.cpp
Normal file
73
test/std/re/re.alg/re.alg.replace/test5.pass.cpp
Normal file
@@ -0,0 +1,73 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 traits, class charT, class ST, class SA>
|
||||
// basic_string<charT>
|
||||
// regex_replace(const charT* s,
|
||||
// const basic_regex<charT, traits>& e,
|
||||
// const basic_string<charT, ST, SA>& fmt,
|
||||
// regex_constants::match_flag_type flags =
|
||||
// regex_constants::match_default);
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::regex phone_numbers("\\d{3}-\\d{4}");
|
||||
const char phone_book[] = "555-1234, 555-2345, 555-3456";
|
||||
std::string r = std::regex_replace(phone_book, phone_numbers,
|
||||
std::string("123-$&"));
|
||||
assert(r == "123-555-1234, 123-555-2345, 123-555-3456");
|
||||
}
|
||||
{
|
||||
std::regex phone_numbers("\\d{3}-\\d{4}");
|
||||
const char phone_book[] = "555-1234, 555-2345, 555-3456";
|
||||
std::string r = std::regex_replace(phone_book, phone_numbers,
|
||||
std::string("123-$&"),
|
||||
std::regex_constants::format_sed);
|
||||
assert(r == "123-$555-1234, 123-$555-2345, 123-$555-3456");
|
||||
}
|
||||
{
|
||||
std::regex phone_numbers("\\d{3}-\\d{4}");
|
||||
const char phone_book[] = "555-1234, 555-2345, 555-3456";
|
||||
std::string r = std::regex_replace(phone_book, phone_numbers,
|
||||
std::string("123-&"),
|
||||
std::regex_constants::format_sed);
|
||||
assert(r == "123-555-1234, 123-555-2345, 123-555-3456");
|
||||
}
|
||||
{
|
||||
std::regex phone_numbers("\\d{3}-\\d{4}");
|
||||
const char phone_book[] = "555-1234, 555-2345, 555-3456";
|
||||
std::string r = std::regex_replace(phone_book, phone_numbers,
|
||||
std::string("123-$&"),
|
||||
std::regex_constants::format_no_copy);
|
||||
assert(r == "123-555-1234123-555-2345123-555-3456");
|
||||
}
|
||||
{
|
||||
std::regex phone_numbers("\\d{3}-\\d{4}");
|
||||
const char phone_book[] = "555-1234, 555-2345, 555-3456";
|
||||
std::string r = std::regex_replace(phone_book, phone_numbers,
|
||||
std::string("123-$&"),
|
||||
std::regex_constants::format_first_only);
|
||||
assert(r == "123-555-1234, 555-2345, 555-3456");
|
||||
}
|
||||
{
|
||||
std::regex phone_numbers("\\d{3}-\\d{4}");
|
||||
const char phone_book[] = "555-1234, 555-2345, 555-3456";
|
||||
std::string r = std::regex_replace(phone_book, phone_numbers,
|
||||
std::string("123-$&"),
|
||||
std::regex_constants::format_first_only |
|
||||
std::regex_constants::format_no_copy);
|
||||
assert(r == "123-555-1234");
|
||||
}
|
||||
}
|
73
test/std/re/re.alg/re.alg.replace/test6.pass.cpp
Normal file
73
test/std/re/re.alg/re.alg.replace/test6.pass.cpp
Normal file
@@ -0,0 +1,73 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 traits, class charT>
|
||||
// basic_string<charT>
|
||||
// regex_replace(const charT* s,
|
||||
// const basic_regex<charT, traits>& e,
|
||||
// const charT* fmt,
|
||||
// regex_constants::match_flag_type flags =
|
||||
// regex_constants::match_default);
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::regex phone_numbers("\\d{3}-\\d{4}");
|
||||
const char phone_book[] = "555-1234, 555-2345, 555-3456";
|
||||
std::string r = std::regex_replace(phone_book, phone_numbers,
|
||||
"123-$&");
|
||||
assert(r == "123-555-1234, 123-555-2345, 123-555-3456");
|
||||
}
|
||||
{
|
||||
std::regex phone_numbers("\\d{3}-\\d{4}");
|
||||
const char phone_book[] = "555-1234, 555-2345, 555-3456";
|
||||
std::string r = std::regex_replace(phone_book, phone_numbers,
|
||||
"123-$&",
|
||||
std::regex_constants::format_sed);
|
||||
assert(r == "123-$555-1234, 123-$555-2345, 123-$555-3456");
|
||||
}
|
||||
{
|
||||
std::regex phone_numbers("\\d{3}-\\d{4}");
|
||||
const char phone_book[] = "555-1234, 555-2345, 555-3456";
|
||||
std::string r = std::regex_replace(phone_book, phone_numbers,
|
||||
"123-&",
|
||||
std::regex_constants::format_sed);
|
||||
assert(r == "123-555-1234, 123-555-2345, 123-555-3456");
|
||||
}
|
||||
{
|
||||
std::regex phone_numbers("\\d{3}-\\d{4}");
|
||||
const char phone_book[] = "555-1234, 555-2345, 555-3456";
|
||||
std::string r = std::regex_replace(phone_book, phone_numbers,
|
||||
"123-$&",
|
||||
std::regex_constants::format_no_copy);
|
||||
assert(r == "123-555-1234123-555-2345123-555-3456");
|
||||
}
|
||||
{
|
||||
std::regex phone_numbers("\\d{3}-\\d{4}");
|
||||
const char phone_book[] = "555-1234, 555-2345, 555-3456";
|
||||
std::string r = std::regex_replace(phone_book, phone_numbers,
|
||||
"123-$&",
|
||||
std::regex_constants::format_first_only);
|
||||
assert(r == "123-555-1234, 555-2345, 555-3456");
|
||||
}
|
||||
{
|
||||
std::regex phone_numbers("\\d{3}-\\d{4}");
|
||||
const char phone_book[] = "555-1234, 555-2345, 555-3456";
|
||||
std::string r = std::regex_replace(phone_book, phone_numbers,
|
||||
"123-$&",
|
||||
std::regex_constants::format_first_only |
|
||||
std::regex_constants::format_no_copy);
|
||||
assert(r == "123-555-1234");
|
||||
}
|
||||
}
|
1573
test/std/re/re.alg/re.alg.search/awk.pass.cpp
Normal file
1573
test/std/re/re.alg/re.alg.search/awk.pass.cpp
Normal file
File diff suppressed because it is too large
Load Diff
63
test/std/re/re.alg/re.alg.search/backup.pass.cpp
Normal file
63
test/std/re/re.alg/re.alg.search/backup.pass.cpp
Normal 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);
|
||||
}
|
||||
}
|
38
test/std/re/re.alg/re.alg.search/basic.fail.cpp
Normal file
38
test/std/re/re.alg/re.alg.search/basic.fail.cpp
Normal 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
|
1546
test/std/re/re.alg/re.alg.search/basic.pass.cpp
Normal file
1546
test/std/re/re.alg/re.alg.search/basic.pass.cpp
Normal file
File diff suppressed because it is too large
Load Diff
1588
test/std/re/re.alg/re.alg.search/ecma.pass.cpp
Normal file
1588
test/std/re/re.alg/re.alg.search/ecma.pass.cpp
Normal file
File diff suppressed because it is too large
Load Diff
90
test/std/re/re.alg/re.alg.search/egrep.pass.cpp
Normal file
90
test/std/re/re.alg/re.alg.search/egrep.pass.cpp
Normal 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");
|
||||
}
|
||||
}
|
1542
test/std/re/re.alg/re.alg.search/extended.pass.cpp
Normal file
1542
test/std/re/re.alg/re.alg.search/extended.pass.cpp
Normal file
File diff suppressed because it is too large
Load Diff
58
test/std/re/re.alg/re.alg.search/grep.pass.cpp
Normal file
58
test/std/re/re.alg/re.alg.search/grep.pass.cpp
Normal 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) == "");
|
||||
}
|
||||
}
|
28
test/std/re/re.alg/re.alg.search/lookahead.pass.cpp
Normal file
28
test/std/re/re.alg/re.alg.search/lookahead.pass.cpp
Normal 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")));
|
||||
}
|
38
test/std/re/re.alg/re.alg.search/no_update_pos.pass.cpp
Normal file
38
test/std/re/re.alg/re.alg.search/no_update_pos.pass.cpp
Normal 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);
|
||||
}
|
12
test/std/re/re.alg/re.except/nothing_to_do.pass.cpp
Normal file
12
test/std/re/re.alg/re.except/nothing_to_do.pass.cpp
Normal file
@@ -0,0 +1,12 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
96
test/std/re/re.badexp/regex_error.pass.cpp
Normal file
96
test/std/re/re.badexp/regex_error.pass.cpp
Normal file
@@ -0,0 +1,96 @@
|
||||
// -*- C++ -*-
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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>
|
||||
|
||||
// class regex_error
|
||||
// : public runtime_error
|
||||
// {
|
||||
// public:
|
||||
// explicit regex_error(regex_constants::error_type ecode);
|
||||
// regex_constants::error_type code() const;
|
||||
// };
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::regex_error e(std::regex_constants::error_collate);
|
||||
assert(e.code() == std::regex_constants::error_collate);
|
||||
assert(e.what() == std::string("The expression contained an invalid collating element name."));
|
||||
}
|
||||
{
|
||||
std::regex_error e(std::regex_constants::error_ctype);
|
||||
assert(e.code() == std::regex_constants::error_ctype);
|
||||
assert(e.what() == std::string("The expression contained an invalid character class name."));
|
||||
}
|
||||
{
|
||||
std::regex_error e(std::regex_constants::error_escape);
|
||||
assert(e.code() == std::regex_constants::error_escape);
|
||||
assert(e.what() == std::string("The expression contained an invalid escaped character, or a "
|
||||
"trailing escape."));
|
||||
}
|
||||
{
|
||||
std::regex_error e(std::regex_constants::error_backref);
|
||||
assert(e.code() == std::regex_constants::error_backref);
|
||||
assert(e.what() == std::string("The expression contained an invalid back reference."));
|
||||
}
|
||||
{
|
||||
std::regex_error e(std::regex_constants::error_brack);
|
||||
assert(e.code() == std::regex_constants::error_brack);
|
||||
assert(e.what() == std::string("The expression contained mismatched [ and ]."));
|
||||
}
|
||||
{
|
||||
std::regex_error e(std::regex_constants::error_paren);
|
||||
assert(e.code() == std::regex_constants::error_paren);
|
||||
assert(e.what() == std::string("The expression contained mismatched ( and )."));
|
||||
}
|
||||
{
|
||||
std::regex_error e(std::regex_constants::error_brace);
|
||||
assert(e.code() == std::regex_constants::error_brace);
|
||||
assert(e.what() == std::string("The expression contained mismatched { and }."));
|
||||
}
|
||||
{
|
||||
std::regex_error e(std::regex_constants::error_badbrace);
|
||||
assert(e.code() == std::regex_constants::error_badbrace);
|
||||
assert(e.what() == std::string("The expression contained an invalid range in a {} expression."));
|
||||
}
|
||||
{
|
||||
std::regex_error e(std::regex_constants::error_range);
|
||||
assert(e.code() == std::regex_constants::error_range);
|
||||
assert(e.what() == std::string("The expression contained an invalid character range, "
|
||||
"such as [b-a] in most encodings."));
|
||||
}
|
||||
{
|
||||
std::regex_error e(std::regex_constants::error_space);
|
||||
assert(e.code() == std::regex_constants::error_space);
|
||||
assert(e.what() == std::string("There was insufficient memory to convert the expression into "
|
||||
"a finite state machine."));
|
||||
}
|
||||
{
|
||||
std::regex_error e(std::regex_constants::error_badrepeat);
|
||||
assert(e.code() == std::regex_constants::error_badrepeat);
|
||||
assert(e.what() == std::string("One of *?+{ was not preceded by a valid regular expression."));
|
||||
}
|
||||
{
|
||||
std::regex_error e(std::regex_constants::error_complexity);
|
||||
assert(e.code() == std::regex_constants::error_complexity);
|
||||
assert(e.what() == std::string("The complexity of an attempted match against a regular "
|
||||
"expression exceeded a pre-set level."));
|
||||
}
|
||||
{
|
||||
std::regex_error e(std::regex_constants::error_stack);
|
||||
assert(e.code() == std::regex_constants::error_stack);
|
||||
assert(e.what() == std::string("There was insufficient memory to determine whether the regular "
|
||||
"expression could match the specified character sequence."));
|
||||
}
|
||||
}
|
13
test/std/re/re.const/nothing_to_do.pass.cpp
Normal file
13
test/std/re/re.const/nothing_to_do.pass.cpp
Normal file
@@ -0,0 +1,13 @@
|
||||
// -*- C++ -*-
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
143
test/std/re/re.const/re.err/error_type.pass.cpp
Normal file
143
test/std/re/re.const/re.err/error_type.pass.cpp
Normal file
@@ -0,0 +1,143 @@
|
||||
// -*- C++ -*-
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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>
|
||||
|
||||
// namespace regex_constants
|
||||
// {
|
||||
//
|
||||
// enum error_type
|
||||
// {
|
||||
// error_collate = unspecified,
|
||||
// error_ctype = unspecified,
|
||||
// error_escape = unspecified,
|
||||
// error_backref = unspecified,
|
||||
// error_brack = unspecified,
|
||||
// error_paren = unspecified,
|
||||
// error_brace = unspecified,
|
||||
// error_badbrace = unspecified,
|
||||
// error_range = unspecified,
|
||||
// error_space = unspecified,
|
||||
// error_badrepeat = unspecified,
|
||||
// error_complexity = unspecified,
|
||||
// error_stack = unspecified
|
||||
// };
|
||||
//
|
||||
// }
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
assert(std::regex_constants::error_collate != 0);
|
||||
assert(std::regex_constants::error_ctype != 0);
|
||||
assert(std::regex_constants::error_escape != 0);
|
||||
assert(std::regex_constants::error_backref != 0);
|
||||
assert(std::regex_constants::error_brack != 0);
|
||||
assert(std::regex_constants::error_paren != 0);
|
||||
assert(std::regex_constants::error_brace != 0);
|
||||
assert(std::regex_constants::error_badbrace != 0);
|
||||
assert(std::regex_constants::error_range != 0);
|
||||
assert(std::regex_constants::error_space != 0);
|
||||
assert(std::regex_constants::error_badrepeat != 0);
|
||||
assert(std::regex_constants::error_complexity != 0);
|
||||
assert(std::regex_constants::error_stack != 0);
|
||||
|
||||
assert(std::regex_constants::error_collate != std::regex_constants::error_ctype);
|
||||
assert(std::regex_constants::error_collate != std::regex_constants::error_escape);
|
||||
assert(std::regex_constants::error_collate != std::regex_constants::error_backref);
|
||||
assert(std::regex_constants::error_collate != std::regex_constants::error_brack);
|
||||
assert(std::regex_constants::error_collate != std::regex_constants::error_paren);
|
||||
assert(std::regex_constants::error_collate != std::regex_constants::error_brace);
|
||||
assert(std::regex_constants::error_collate != std::regex_constants::error_badbrace);
|
||||
assert(std::regex_constants::error_collate != std::regex_constants::error_range);
|
||||
assert(std::regex_constants::error_collate != std::regex_constants::error_space);
|
||||
assert(std::regex_constants::error_collate != std::regex_constants::error_badrepeat);
|
||||
assert(std::regex_constants::error_collate != std::regex_constants::error_complexity);
|
||||
assert(std::regex_constants::error_collate != std::regex_constants::error_stack);
|
||||
|
||||
assert(std::regex_constants::error_ctype != std::regex_constants::error_escape);
|
||||
assert(std::regex_constants::error_ctype != std::regex_constants::error_backref);
|
||||
assert(std::regex_constants::error_ctype != std::regex_constants::error_brack);
|
||||
assert(std::regex_constants::error_ctype != std::regex_constants::error_paren);
|
||||
assert(std::regex_constants::error_ctype != std::regex_constants::error_brace);
|
||||
assert(std::regex_constants::error_ctype != std::regex_constants::error_badbrace);
|
||||
assert(std::regex_constants::error_ctype != std::regex_constants::error_range);
|
||||
assert(std::regex_constants::error_ctype != std::regex_constants::error_space);
|
||||
assert(std::regex_constants::error_ctype != std::regex_constants::error_badrepeat);
|
||||
assert(std::regex_constants::error_ctype != std::regex_constants::error_complexity);
|
||||
assert(std::regex_constants::error_ctype != std::regex_constants::error_stack);
|
||||
|
||||
assert(std::regex_constants::error_escape != std::regex_constants::error_backref);
|
||||
assert(std::regex_constants::error_escape != std::regex_constants::error_brack);
|
||||
assert(std::regex_constants::error_escape != std::regex_constants::error_paren);
|
||||
assert(std::regex_constants::error_escape != std::regex_constants::error_brace);
|
||||
assert(std::regex_constants::error_escape != std::regex_constants::error_badbrace);
|
||||
assert(std::regex_constants::error_escape != std::regex_constants::error_range);
|
||||
assert(std::regex_constants::error_escape != std::regex_constants::error_space);
|
||||
assert(std::regex_constants::error_escape != std::regex_constants::error_badrepeat);
|
||||
assert(std::regex_constants::error_escape != std::regex_constants::error_complexity);
|
||||
assert(std::regex_constants::error_escape != std::regex_constants::error_stack);
|
||||
|
||||
assert(std::regex_constants::error_backref != std::regex_constants::error_brack);
|
||||
assert(std::regex_constants::error_backref != std::regex_constants::error_paren);
|
||||
assert(std::regex_constants::error_backref != std::regex_constants::error_brace);
|
||||
assert(std::regex_constants::error_backref != std::regex_constants::error_badbrace);
|
||||
assert(std::regex_constants::error_backref != std::regex_constants::error_range);
|
||||
assert(std::regex_constants::error_backref != std::regex_constants::error_space);
|
||||
assert(std::regex_constants::error_backref != std::regex_constants::error_badrepeat);
|
||||
assert(std::regex_constants::error_backref != std::regex_constants::error_complexity);
|
||||
assert(std::regex_constants::error_backref != std::regex_constants::error_stack);
|
||||
|
||||
assert(std::regex_constants::error_brack != std::regex_constants::error_paren);
|
||||
assert(std::regex_constants::error_brack != std::regex_constants::error_brace);
|
||||
assert(std::regex_constants::error_brack != std::regex_constants::error_badbrace);
|
||||
assert(std::regex_constants::error_brack != std::regex_constants::error_range);
|
||||
assert(std::regex_constants::error_brack != std::regex_constants::error_space);
|
||||
assert(std::regex_constants::error_brack != std::regex_constants::error_badrepeat);
|
||||
assert(std::regex_constants::error_brack != std::regex_constants::error_complexity);
|
||||
assert(std::regex_constants::error_brack != std::regex_constants::error_stack);
|
||||
|
||||
assert(std::regex_constants::error_paren != std::regex_constants::error_brace);
|
||||
assert(std::regex_constants::error_paren != std::regex_constants::error_badbrace);
|
||||
assert(std::regex_constants::error_paren != std::regex_constants::error_range);
|
||||
assert(std::regex_constants::error_paren != std::regex_constants::error_space);
|
||||
assert(std::regex_constants::error_paren != std::regex_constants::error_badrepeat);
|
||||
assert(std::regex_constants::error_paren != std::regex_constants::error_complexity);
|
||||
assert(std::regex_constants::error_paren != std::regex_constants::error_stack);
|
||||
|
||||
assert(std::regex_constants::error_brace != std::regex_constants::error_badbrace);
|
||||
assert(std::regex_constants::error_brace != std::regex_constants::error_range);
|
||||
assert(std::regex_constants::error_brace != std::regex_constants::error_space);
|
||||
assert(std::regex_constants::error_brace != std::regex_constants::error_badrepeat);
|
||||
assert(std::regex_constants::error_brace != std::regex_constants::error_complexity);
|
||||
assert(std::regex_constants::error_brace != std::regex_constants::error_stack);
|
||||
|
||||
assert(std::regex_constants::error_badbrace != std::regex_constants::error_range);
|
||||
assert(std::regex_constants::error_badbrace != std::regex_constants::error_space);
|
||||
assert(std::regex_constants::error_badbrace != std::regex_constants::error_badrepeat);
|
||||
assert(std::regex_constants::error_badbrace != std::regex_constants::error_complexity);
|
||||
assert(std::regex_constants::error_badbrace != std::regex_constants::error_stack);
|
||||
|
||||
assert(std::regex_constants::error_range != std::regex_constants::error_space);
|
||||
assert(std::regex_constants::error_range != std::regex_constants::error_badrepeat);
|
||||
assert(std::regex_constants::error_range != std::regex_constants::error_complexity);
|
||||
assert(std::regex_constants::error_range != std::regex_constants::error_stack);
|
||||
|
||||
assert(std::regex_constants::error_space != std::regex_constants::error_badrepeat);
|
||||
assert(std::regex_constants::error_space != std::regex_constants::error_complexity);
|
||||
assert(std::regex_constants::error_space != std::regex_constants::error_stack);
|
||||
|
||||
assert(std::regex_constants::error_badrepeat != std::regex_constants::error_complexity);
|
||||
assert(std::regex_constants::error_badrepeat != std::regex_constants::error_stack);
|
||||
|
||||
assert(std::regex_constants::error_complexity != std::regex_constants::error_stack);
|
||||
}
|
128
test/std/re/re.const/re.matchflag/match_flag_type.pass.cpp
Normal file
128
test/std/re/re.const/re.matchflag/match_flag_type.pass.cpp
Normal file
@@ -0,0 +1,128 @@
|
||||
// -*- C++ -*-
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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>
|
||||
|
||||
// namespace regex_constants
|
||||
// {
|
||||
//
|
||||
// emum match_flag_type // bitmask type
|
||||
// {
|
||||
// match_default = 0,
|
||||
// match_not_bol = unspecified,
|
||||
// match_not_eol = unspecified,
|
||||
// match_not_bow = unspecified,
|
||||
// match_not_eow = unspecified,
|
||||
// match_any = unspecified,
|
||||
// match_not_null = unspecified,
|
||||
// match_continuous = unspecified,
|
||||
// match_prev_avail = unspecified,
|
||||
// format_default = 0,
|
||||
// format_sed = unspecified,
|
||||
// format_no_copy = unspecified,
|
||||
// format_first_only = unspecified
|
||||
// };
|
||||
//
|
||||
// }
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
assert(std::regex_constants::match_default == 0);
|
||||
assert(std::regex_constants::match_not_bol != 0);
|
||||
assert(std::regex_constants::match_not_eol != 0);
|
||||
assert(std::regex_constants::match_not_bow != 0);
|
||||
assert(std::regex_constants::match_not_eow != 0);
|
||||
assert(std::regex_constants::match_any != 0);
|
||||
assert(std::regex_constants::match_not_null != 0);
|
||||
assert(std::regex_constants::match_continuous != 0);
|
||||
assert(std::regex_constants::match_prev_avail != 0);
|
||||
assert(std::regex_constants::format_default == 0);
|
||||
assert(std::regex_constants::format_sed != 0);
|
||||
assert(std::regex_constants::format_no_copy != 0);
|
||||
assert(std::regex_constants::format_first_only != 0);
|
||||
|
||||
assert((std::regex_constants::match_not_bol & std::regex_constants::match_not_eol) == 0);
|
||||
assert((std::regex_constants::match_not_bol & std::regex_constants::match_not_bow) == 0);
|
||||
assert((std::regex_constants::match_not_bol & std::regex_constants::match_not_eow) == 0);
|
||||
assert((std::regex_constants::match_not_bol & std::regex_constants::match_any) == 0);
|
||||
assert((std::regex_constants::match_not_bol & std::regex_constants::match_not_null) == 0);
|
||||
assert((std::regex_constants::match_not_bol & std::regex_constants::match_continuous) == 0);
|
||||
assert((std::regex_constants::match_not_bol & std::regex_constants::match_prev_avail) == 0);
|
||||
assert((std::regex_constants::match_not_bol & std::regex_constants::format_sed) == 0);
|
||||
assert((std::regex_constants::match_not_bol & std::regex_constants::format_no_copy) == 0);
|
||||
assert((std::regex_constants::match_not_bol & std::regex_constants::format_first_only) == 0);
|
||||
|
||||
assert((std::regex_constants::match_not_eol & std::regex_constants::match_not_bow) == 0);
|
||||
assert((std::regex_constants::match_not_eol & std::regex_constants::match_not_eow) == 0);
|
||||
assert((std::regex_constants::match_not_eol & std::regex_constants::match_any) == 0);
|
||||
assert((std::regex_constants::match_not_eol & std::regex_constants::match_not_null) == 0);
|
||||
assert((std::regex_constants::match_not_eol & std::regex_constants::match_continuous) == 0);
|
||||
assert((std::regex_constants::match_not_eol & std::regex_constants::match_prev_avail) == 0);
|
||||
assert((std::regex_constants::match_not_eol & std::regex_constants::format_sed) == 0);
|
||||
assert((std::regex_constants::match_not_eol & std::regex_constants::format_no_copy) == 0);
|
||||
assert((std::regex_constants::match_not_eol & std::regex_constants::format_first_only) == 0);
|
||||
|
||||
assert((std::regex_constants::match_not_bow & std::regex_constants::match_not_eow) == 0);
|
||||
assert((std::regex_constants::match_not_bow & std::regex_constants::match_any) == 0);
|
||||
assert((std::regex_constants::match_not_bow & std::regex_constants::match_not_null) == 0);
|
||||
assert((std::regex_constants::match_not_bow & std::regex_constants::match_continuous) == 0);
|
||||
assert((std::regex_constants::match_not_bow & std::regex_constants::match_prev_avail) == 0);
|
||||
assert((std::regex_constants::match_not_bow & std::regex_constants::format_sed) == 0);
|
||||
assert((std::regex_constants::match_not_bow & std::regex_constants::format_no_copy) == 0);
|
||||
assert((std::regex_constants::match_not_bow & std::regex_constants::format_first_only) == 0);
|
||||
|
||||
assert((std::regex_constants::match_not_eow & std::regex_constants::match_any) == 0);
|
||||
assert((std::regex_constants::match_not_eow & std::regex_constants::match_not_null) == 0);
|
||||
assert((std::regex_constants::match_not_eow & std::regex_constants::match_continuous) == 0);
|
||||
assert((std::regex_constants::match_not_eow & std::regex_constants::match_prev_avail) == 0);
|
||||
assert((std::regex_constants::match_not_eow & std::regex_constants::format_sed) == 0);
|
||||
assert((std::regex_constants::match_not_eow & std::regex_constants::format_no_copy) == 0);
|
||||
assert((std::regex_constants::match_not_eow & std::regex_constants::format_first_only) == 0);
|
||||
|
||||
assert((std::regex_constants::match_any & std::regex_constants::match_not_null) == 0);
|
||||
assert((std::regex_constants::match_any & std::regex_constants::match_continuous) == 0);
|
||||
assert((std::regex_constants::match_any & std::regex_constants::match_prev_avail) == 0);
|
||||
assert((std::regex_constants::match_any & std::regex_constants::format_sed) == 0);
|
||||
assert((std::regex_constants::match_any & std::regex_constants::format_no_copy) == 0);
|
||||
assert((std::regex_constants::match_any & std::regex_constants::format_first_only) == 0);
|
||||
|
||||
assert((std::regex_constants::match_not_null & std::regex_constants::match_continuous) == 0);
|
||||
assert((std::regex_constants::match_not_null & std::regex_constants::match_prev_avail) == 0);
|
||||
assert((std::regex_constants::match_not_null & std::regex_constants::format_sed) == 0);
|
||||
assert((std::regex_constants::match_not_null & std::regex_constants::format_no_copy) == 0);
|
||||
assert((std::regex_constants::match_not_null & std::regex_constants::format_first_only) == 0);
|
||||
|
||||
assert((std::regex_constants::match_continuous & std::regex_constants::match_prev_avail) == 0);
|
||||
assert((std::regex_constants::match_continuous & std::regex_constants::format_sed) == 0);
|
||||
assert((std::regex_constants::match_continuous & std::regex_constants::format_no_copy) == 0);
|
||||
assert((std::regex_constants::match_continuous & std::regex_constants::format_first_only) == 0);
|
||||
|
||||
assert((std::regex_constants::match_prev_avail & std::regex_constants::format_sed) == 0);
|
||||
assert((std::regex_constants::match_prev_avail & std::regex_constants::format_no_copy) == 0);
|
||||
assert((std::regex_constants::match_prev_avail & std::regex_constants::format_first_only) == 0);
|
||||
|
||||
assert((std::regex_constants::format_sed & std::regex_constants::format_no_copy) == 0);
|
||||
assert((std::regex_constants::format_sed & std::regex_constants::format_first_only) == 0);
|
||||
|
||||
assert((std::regex_constants::format_no_copy & std::regex_constants::format_first_only) == 0);
|
||||
|
||||
std::regex_constants::match_flag_type e1 = std::regex_constants::match_not_bol;
|
||||
std::regex_constants::match_flag_type e2 = std::regex_constants::match_not_eol;
|
||||
e1 = ~e1;
|
||||
e1 = e1 & e2;
|
||||
e1 = e1 | e2;
|
||||
e1 = e1 ^ e2;
|
||||
e1 &= e2;
|
||||
e1 |= e2;
|
||||
e1 ^= e2;
|
||||
}
|
114
test/std/re/re.const/re.synopt/syntax_option_type.pass.cpp
Normal file
114
test/std/re/re.const/re.synopt/syntax_option_type.pass.cpp
Normal file
@@ -0,0 +1,114 @@
|
||||
// -*- C++ -*-
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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>
|
||||
|
||||
// namespace regex_constants
|
||||
// {
|
||||
//
|
||||
// emum syntax_option_type // bitmask type
|
||||
// {
|
||||
// icase = unspecified,
|
||||
// nosubs = unspecified,
|
||||
// optimize = unspecified,
|
||||
// collate = unspecified,
|
||||
// ECMAScript = unspecified,
|
||||
// basic = unspecified,
|
||||
// extended = unspecified,
|
||||
// awk = unspecified,
|
||||
// grep = unspecified,
|
||||
// egrep = unspecified
|
||||
// };
|
||||
//
|
||||
// }
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
assert(std::regex_constants::icase != 0);
|
||||
assert(std::regex_constants::nosubs != 0);
|
||||
assert(std::regex_constants::optimize != 0);
|
||||
assert(std::regex_constants::collate != 0);
|
||||
assert(std::regex_constants::ECMAScript == 0);
|
||||
assert(std::regex_constants::basic != 0);
|
||||
assert(std::regex_constants::extended != 0);
|
||||
assert(std::regex_constants::awk != 0);
|
||||
assert(std::regex_constants::grep != 0);
|
||||
assert(std::regex_constants::egrep != 0);
|
||||
|
||||
assert((std::regex_constants::icase & std::regex_constants::nosubs) == 0);
|
||||
assert((std::regex_constants::icase & std::regex_constants::optimize) == 0);
|
||||
assert((std::regex_constants::icase & std::regex_constants::collate) == 0);
|
||||
assert((std::regex_constants::icase & std::regex_constants::ECMAScript) == 0);
|
||||
assert((std::regex_constants::icase & std::regex_constants::basic) == 0);
|
||||
assert((std::regex_constants::icase & std::regex_constants::extended) == 0);
|
||||
assert((std::regex_constants::icase & std::regex_constants::awk) == 0);
|
||||
assert((std::regex_constants::icase & std::regex_constants::grep) == 0);
|
||||
assert((std::regex_constants::icase & std::regex_constants::egrep) == 0);
|
||||
|
||||
assert((std::regex_constants::nosubs & std::regex_constants::optimize) == 0);
|
||||
assert((std::regex_constants::nosubs & std::regex_constants::collate) == 0);
|
||||
assert((std::regex_constants::nosubs & std::regex_constants::ECMAScript) == 0);
|
||||
assert((std::regex_constants::nosubs & std::regex_constants::basic) == 0);
|
||||
assert((std::regex_constants::nosubs & std::regex_constants::extended) == 0);
|
||||
assert((std::regex_constants::nosubs & std::regex_constants::awk) == 0);
|
||||
assert((std::regex_constants::nosubs & std::regex_constants::grep) == 0);
|
||||
assert((std::regex_constants::nosubs & std::regex_constants::egrep) == 0);
|
||||
|
||||
assert((std::regex_constants::optimize & std::regex_constants::collate) == 0);
|
||||
assert((std::regex_constants::optimize & std::regex_constants::ECMAScript) == 0);
|
||||
assert((std::regex_constants::optimize & std::regex_constants::basic) == 0);
|
||||
assert((std::regex_constants::optimize & std::regex_constants::extended) == 0);
|
||||
assert((std::regex_constants::optimize & std::regex_constants::awk) == 0);
|
||||
assert((std::regex_constants::optimize & std::regex_constants::grep) == 0);
|
||||
assert((std::regex_constants::optimize & std::regex_constants::egrep) == 0);
|
||||
|
||||
assert((std::regex_constants::collate & std::regex_constants::ECMAScript) == 0);
|
||||
assert((std::regex_constants::collate & std::regex_constants::basic) == 0);
|
||||
assert((std::regex_constants::collate & std::regex_constants::extended) == 0);
|
||||
assert((std::regex_constants::collate & std::regex_constants::awk) == 0);
|
||||
assert((std::regex_constants::collate & std::regex_constants::grep) == 0);
|
||||
assert((std::regex_constants::collate & std::regex_constants::egrep) == 0);
|
||||
|
||||
assert((std::regex_constants::ECMAScript & std::regex_constants::basic) == 0);
|
||||
assert((std::regex_constants::ECMAScript & std::regex_constants::extended) == 0);
|
||||
assert((std::regex_constants::ECMAScript & std::regex_constants::awk) == 0);
|
||||
assert((std::regex_constants::ECMAScript & std::regex_constants::grep) == 0);
|
||||
assert((std::regex_constants::ECMAScript & std::regex_constants::egrep) == 0);
|
||||
|
||||
assert((std::regex_constants::basic & std::regex_constants::extended) == 0);
|
||||
assert((std::regex_constants::basic & std::regex_constants::awk) == 0);
|
||||
assert((std::regex_constants::basic & std::regex_constants::grep) == 0);
|
||||
assert((std::regex_constants::basic & std::regex_constants::egrep) == 0);
|
||||
|
||||
assert((std::regex_constants::extended & std::regex_constants::awk) == 0);
|
||||
assert((std::regex_constants::extended & std::regex_constants::grep) == 0);
|
||||
assert((std::regex_constants::extended & std::regex_constants::egrep) == 0);
|
||||
|
||||
assert((std::regex_constants::awk & std::regex_constants::grep) == 0);
|
||||
assert((std::regex_constants::awk & std::regex_constants::egrep) == 0);
|
||||
|
||||
assert((std::regex_constants::grep & std::regex_constants::egrep) == 0);
|
||||
|
||||
assert((std::regex_constants::icase | std::regex_constants::nosubs) != 0);
|
||||
assert((std::regex_constants::icase ^ std::regex_constants::nosubs) != 0);
|
||||
|
||||
std::regex_constants::syntax_option_type e1 = std::regex_constants::icase;
|
||||
std::regex_constants::syntax_option_type e2 = std::regex_constants::nosubs;
|
||||
e1 = ~e1;
|
||||
e1 = e1 & e2;
|
||||
e1 = e1 | e2;
|
||||
e1 = e1 ^ e2;
|
||||
e1 &= e2;
|
||||
e1 |= e2;
|
||||
e1 ^= e2;
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
// -*- C++ -*-
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
// -*- C++ -*-
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
// -*- C++ -*-
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
// -*- C++ -*-
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
// -*- C++ -*-
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
// -*- C++ -*-
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
// -*- C++ -*-
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
13
test/std/re/re.def/nothing_to_do.pass.cpp
Normal file
13
test/std/re/re.def/nothing_to_do.pass.cpp
Normal file
@@ -0,0 +1,13 @@
|
||||
// -*- C++ -*-
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
13
test/std/re/re.general/nothing_to_do.pass.cpp
Normal file
13
test/std/re/re.general/nothing_to_do.pass.cpp
Normal file
@@ -0,0 +1,13 @@
|
||||
// -*- C++ -*-
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
12
test/std/re/re.grammar/nothing_to_do.pass.cpp
Normal file
12
test/std/re/re.grammar/nothing_to_do.pass.cpp
Normal file
@@ -0,0 +1,12 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
12
test/std/re/re.iter/nothing_to_do.pass.cpp
Normal file
12
test/std/re/re.iter/nothing_to_do.pass.cpp
Normal file
@@ -0,0 +1,12 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
@@ -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>
|
||||
|
||||
// class regex_iterator<BidirectionalIterator, charT, traits>
|
||||
|
||||
// regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
|
||||
// const regex_type&& re,
|
||||
// int submatch = 0,
|
||||
// regex_constants::match_flag_type m =
|
||||
// regex_constants::match_default) = delete;
|
||||
|
||||
#include <__config>
|
||||
|
||||
#if _LIBCPP_STD_VER <= 11
|
||||
#error
|
||||
#else
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
const char phone_book[] = "555-1234, 555-2345, 555-3456";
|
||||
std::cregex_iterator i(
|
||||
std::begin(phone_book), std::end(phone_book),
|
||||
std::regex("\\d{3}-\\d{4}"));
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -0,0 +1,44 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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>
|
||||
|
||||
// class regex_iterator<BidirectionalIterator, charT, traits>
|
||||
|
||||
// regex_iterator(BidirectionalIterator a, BidirectionalIterator b,
|
||||
// const regex_type& re,
|
||||
// regex_constants::match_flag_type m = regex_constants::match_default);
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::regex phone_numbers("\\d{3}-\\d{4}");
|
||||
const char phone_book[] = "555-1234, 555-2345, 555-3456";
|
||||
std::cregex_iterator i(std::begin(phone_book), std::end(phone_book), phone_numbers);
|
||||
assert(i != std::cregex_iterator());
|
||||
assert(i->size() == 1);
|
||||
assert(i->position() == 0);
|
||||
assert(i->str() == "555-1234");
|
||||
++i;
|
||||
assert(i != std::cregex_iterator());
|
||||
assert(i->size() == 1);
|
||||
assert(i->position() == 10);
|
||||
assert(i->str() == "555-2345");
|
||||
++i;
|
||||
assert(i != std::cregex_iterator());
|
||||
assert(i->size() == 1);
|
||||
assert(i->position() == 20);
|
||||
assert(i->str() == "555-3456");
|
||||
++i;
|
||||
assert(i == std::cregex_iterator());
|
||||
}
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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>
|
||||
|
||||
// class regex_iterator<BidirectionalIterator, charT, traits>
|
||||
|
||||
// regex_iterator();
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
template <class CharT>
|
||||
void
|
||||
test()
|
||||
{
|
||||
typedef std::regex_iterator<const CharT*> I;
|
||||
I i1;
|
||||
assert(i1 == I());
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test<char>();
|
||||
test<wchar_t>();
|
||||
}
|
@@ -0,0 +1,19 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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>
|
||||
|
||||
// class regex_iterator<BidirectionalIterator, charT, traits>
|
||||
|
||||
// bool operator==(const regex_iterator& right) const;
|
||||
// bool operator!=(const regex_iterator& right) const;
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
@@ -0,0 +1,42 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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>
|
||||
|
||||
// class regex_iterator<BidirectionalIterator, charT, traits>
|
||||
|
||||
// const value_type& operator*() const;
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::regex phone_numbers("\\d{3}-\\d{4}");
|
||||
const char phone_book[] = "555-1234, 555-2345, 555-3456";
|
||||
std::cregex_iterator i(std::begin(phone_book), std::end(phone_book), phone_numbers);
|
||||
assert(i != std::cregex_iterator());
|
||||
assert((*i).size() == 1);
|
||||
assert((*i).position() == 0);
|
||||
assert((*i).str() == "555-1234");
|
||||
++i;
|
||||
assert(i != std::cregex_iterator());
|
||||
assert((*i).size() == 1);
|
||||
assert((*i).position() == 10);
|
||||
assert((*i).str() == "555-2345");
|
||||
++i;
|
||||
assert(i != std::cregex_iterator());
|
||||
assert((*i).size() == 1);
|
||||
assert((*i).position() == 20);
|
||||
assert((*i).str() == "555-3456");
|
||||
++i;
|
||||
assert(i == std::cregex_iterator());
|
||||
}
|
||||
}
|
97
test/std/re/re.iter/re.regiter/re.regiter.incr/post.pass.cpp
Normal file
97
test/std/re/re.iter/re.regiter/re.regiter.incr/post.pass.cpp
Normal file
@@ -0,0 +1,97 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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>
|
||||
|
||||
// class regex_iterator<BidirectionalIterator, charT, traits>
|
||||
|
||||
// regex_iterator operator++(int);
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::regex phone_numbers("\\d{3}-\\d{4}");
|
||||
const char phone_book[] = "555-1234, 555-2345, 555-3456";
|
||||
std::cregex_iterator i(std::begin(phone_book), std::end(phone_book), phone_numbers);
|
||||
std::cregex_iterator i2 = i;
|
||||
assert(i != std::cregex_iterator());
|
||||
assert(i2!= std::cregex_iterator());
|
||||
assert((*i).size() == 1);
|
||||
assert((*i).position() == 0);
|
||||
assert((*i).str() == "555-1234");
|
||||
assert((*i2).size() == 1);
|
||||
assert((*i2).position() == 0);
|
||||
assert((*i2).str() == "555-1234");
|
||||
i++;
|
||||
assert(i != std::cregex_iterator());
|
||||
assert(i2!= std::cregex_iterator());
|
||||
assert((*i).size() == 1);
|
||||
assert((*i).position() == 10);
|
||||
assert((*i).str() == "555-2345");
|
||||
assert((*i2).size() == 1);
|
||||
assert((*i2).position() == 0);
|
||||
assert((*i2).str() == "555-1234");
|
||||
i++;
|
||||
assert(i != std::cregex_iterator());
|
||||
assert(i2!= std::cregex_iterator());
|
||||
assert((*i).size() == 1);
|
||||
assert((*i).position() == 20);
|
||||
assert((*i).str() == "555-3456");
|
||||
assert((*i2).size() == 1);
|
||||
assert((*i2).position() == 0);
|
||||
assert((*i2).str() == "555-1234");
|
||||
i++;
|
||||
assert(i == std::cregex_iterator());
|
||||
assert(i2!= std::cregex_iterator());
|
||||
assert((*i2).size() == 1);
|
||||
assert((*i2).position() == 0);
|
||||
assert((*i2).str() == "555-1234");
|
||||
}
|
||||
{
|
||||
std::regex phone_numbers("\\d{3}-\\d{4}");
|
||||
const char phone_book[] = "555-1234, 555-2345, 555-3456";
|
||||
std::cregex_iterator i(std::begin(phone_book), std::end(phone_book), phone_numbers);
|
||||
std::cregex_iterator i2 = i;
|
||||
assert(i != std::cregex_iterator());
|
||||
assert(i2!= std::cregex_iterator());
|
||||
assert((*i).size() == 1);
|
||||
assert((*i).position() == 0);
|
||||
assert((*i).str() == "555-1234");
|
||||
assert((*i2).size() == 1);
|
||||
assert((*i2).position() == 0);
|
||||
assert((*i2).str() == "555-1234");
|
||||
++i;
|
||||
assert(i != std::cregex_iterator());
|
||||
assert(i2!= std::cregex_iterator());
|
||||
assert((*i).size() == 1);
|
||||
assert((*i).position() == 10);
|
||||
assert((*i).str() == "555-2345");
|
||||
assert((*i2).size() == 1);
|
||||
assert((*i2).position() == 0);
|
||||
assert((*i2).str() == "555-1234");
|
||||
++i;
|
||||
assert(i != std::cregex_iterator());
|
||||
assert(i2!= std::cregex_iterator());
|
||||
assert((*i).size() == 1);
|
||||
assert((*i).position() == 20);
|
||||
assert((*i).str() == "555-3456");
|
||||
assert((*i2).size() == 1);
|
||||
assert((*i2).position() == 0);
|
||||
assert((*i2).str() == "555-1234");
|
||||
++i;
|
||||
assert(i == std::cregex_iterator());
|
||||
assert(i2!= std::cregex_iterator());
|
||||
assert((*i2).size() == 1);
|
||||
assert((*i2).position() == 0);
|
||||
assert((*i2).str() == "555-1234");
|
||||
}
|
||||
}
|
45
test/std/re/re.iter/re.regiter/types.pass.cpp
Normal file
45
test/std/re/re.iter/re.regiter/types.pass.cpp
Normal file
@@ -0,0 +1,45 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 charT = typename iterator_traits< BidirectionalIterator>::value_type,
|
||||
// class traits = regex_traits<charT>>
|
||||
// class regex_iterator
|
||||
// {
|
||||
// public:
|
||||
// typedef basic_regex<charT, traits> regex_type;
|
||||
// typedef match_results<BidirectionalIterator> value_type;
|
||||
// typedef ptrdiff_t difference_type;
|
||||
// typedef const value_type* pointer;
|
||||
// typedef const value_type& reference;
|
||||
// typedef forward_iterator_tag iterator_category;
|
||||
|
||||
#include <regex>
|
||||
#include <type_traits>
|
||||
|
||||
template <class CharT>
|
||||
void
|
||||
test()
|
||||
{
|
||||
typedef std::regex_iterator<const CharT*> I;
|
||||
static_assert((std::is_same<typename I::regex_type, std::basic_regex<CharT> >::value), "");
|
||||
static_assert((std::is_same<typename I::value_type, std::match_results<const CharT*> >::value), "");
|
||||
static_assert((std::is_same<typename I::difference_type, std::ptrdiff_t>::value), "");
|
||||
static_assert((std::is_same<typename I::pointer, const std::match_results<const CharT*>*>::value), "");
|
||||
static_assert((std::is_same<typename I::reference, const std::match_results<const CharT*>&>::value), "");
|
||||
static_assert((std::is_same<typename I::iterator_category, std::forward_iterator_tag>::value), "");
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test<char>();
|
||||
test<wchar_t>();
|
||||
}
|
@@ -0,0 +1,41 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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>
|
||||
|
||||
// class regex_iterator<BidirectionalIterator, charT, traits>
|
||||
|
||||
// template <size_t N>
|
||||
// regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
|
||||
// const regex_type&& re,
|
||||
// const int (&submatches)[N],
|
||||
// regex_constants::match_flag_type m =
|
||||
// regex_constants::match_default);
|
||||
|
||||
#include <__config>
|
||||
|
||||
#if _LIBCPP_STD_VER <= 11
|
||||
#error
|
||||
#else
|
||||
|
||||
#include <regex>
|
||||
#include <vector>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::regex phone_numbers("\\d{3}-(\\d{4})");
|
||||
const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
|
||||
const int indices[] = {-1, 0, 1};
|
||||
std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
|
||||
std::regex("\\d{3}-\\d{4}"), indices);
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -0,0 +1,64 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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>
|
||||
|
||||
// class regex_token_iterator<BidirectionalIterator, charT, traits>
|
||||
|
||||
// template <size_t N>
|
||||
// regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
|
||||
// const regex_type& re,
|
||||
// const int (&submatches)[N],
|
||||
// regex_constants::match_flag_type m =
|
||||
// regex_constants::match_default);
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::regex phone_numbers("\\d{3}-(\\d{4})");
|
||||
const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
|
||||
const int indices[] = {-1, 0, 1};
|
||||
std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
|
||||
phone_numbers, indices);
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i->str() == "start ");
|
||||
++i;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i->str() == "555-1234");
|
||||
++i;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i->str() == "1234");
|
||||
++i;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i->str() == ", ");
|
||||
++i;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i->str() == "555-2345");
|
||||
++i;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i->str() == "2345");
|
||||
++i;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i->str() == ", ");
|
||||
++i;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i->str() == "555-3456");
|
||||
++i;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i->str() == "3456");
|
||||
++i;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i->str() == " end");
|
||||
++i;
|
||||
assert(i == std::cregex_token_iterator());
|
||||
}
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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>
|
||||
|
||||
// class regex_token_iterator<BidirectionalIterator, charT, traits>
|
||||
|
||||
// regex_token_iterator();
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
template <class CharT>
|
||||
void
|
||||
test()
|
||||
{
|
||||
typedef std::regex_token_iterator<const CharT*> I;
|
||||
I i1;
|
||||
assert(i1 == I());
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test<char>();
|
||||
test<wchar_t>();
|
||||
}
|
@@ -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>
|
||||
|
||||
// class regex_iterator<BidirectionalIterator, charT, traits>
|
||||
|
||||
// regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
|
||||
// const regex_type&& re,
|
||||
// initializer_list<int> submatches,
|
||||
// regex_constants::match_flag_type m =
|
||||
// regex_constants::match_default);
|
||||
|
||||
#include <__config>
|
||||
|
||||
#if _LIBCPP_STD_VER <= 11
|
||||
#error
|
||||
#else
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::regex phone_numbers("\\d{3}-(\\d{4})");
|
||||
const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
|
||||
std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
|
||||
std::regex("\\d{3}-\\d{4}"), {-1, 0, 1});
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -0,0 +1,64 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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>
|
||||
|
||||
// class regex_token_iterator<BidirectionalIterator, charT, traits>
|
||||
|
||||
// regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
|
||||
// const regex_type& re,
|
||||
// initializer_list<int> submatches,
|
||||
// regex_constants::match_flag_type m =
|
||||
// regex_constants::match_default);
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
{
|
||||
std::regex phone_numbers("\\d{3}-(\\d{4})");
|
||||
const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
|
||||
std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
|
||||
phone_numbers, {-1, 0, 1});
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i->str() == "start ");
|
||||
++i;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i->str() == "555-1234");
|
||||
++i;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i->str() == "1234");
|
||||
++i;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i->str() == ", ");
|
||||
++i;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i->str() == "555-2345");
|
||||
++i;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i->str() == "2345");
|
||||
++i;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i->str() == ", ");
|
||||
++i;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i->str() == "555-3456");
|
||||
++i;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i->str() == "3456");
|
||||
++i;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i->str() == " end");
|
||||
++i;
|
||||
assert(i == std::cregex_token_iterator());
|
||||
}
|
||||
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
}
|
37
test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/int.fail.cpp
Normal file
37
test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/int.fail.cpp
Normal file
@@ -0,0 +1,37 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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>
|
||||
|
||||
// class regex_iterator<BidirectionalIterator, charT, traits>
|
||||
|
||||
// regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
|
||||
// const regex_type&& re, int submatch = 0,
|
||||
// regex_constants::match_flag_type m =
|
||||
// regex_constants::match_default);
|
||||
|
||||
#include <__config>
|
||||
|
||||
#if _LIBCPP_STD_VER <= 11
|
||||
#error
|
||||
#else
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::regex phone_numbers("\\d{3}-\\d{4}");
|
||||
const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
|
||||
std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
|
||||
std::regex("\\d{3}-\\d{4}"), -1);
|
||||
}
|
||||
}
|
||||
#endif
|
75
test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/int.pass.cpp
Normal file
75
test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/int.pass.cpp
Normal file
@@ -0,0 +1,75 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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>
|
||||
|
||||
// class regex_token_iterator<BidirectionalIterator, charT, traits>
|
||||
|
||||
// regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
|
||||
// const regex_type& re, int submatch = 0,
|
||||
// regex_constants::match_flag_type m =
|
||||
// regex_constants::match_default);
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::regex phone_numbers("\\d{3}-\\d{4}");
|
||||
const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
|
||||
std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
|
||||
phone_numbers, -1);
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i->str() == "start ");
|
||||
++i;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i->str() == ", ");
|
||||
++i;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i->str() == ", ");
|
||||
++i;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i->str() == " end");
|
||||
++i;
|
||||
assert(i == std::cregex_token_iterator());
|
||||
}
|
||||
{
|
||||
std::regex phone_numbers("\\d{3}-\\d{4}");
|
||||
const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
|
||||
std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
|
||||
phone_numbers);
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i->str() == "555-1234");
|
||||
++i;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i->str() == "555-2345");
|
||||
++i;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i->str() == "555-3456");
|
||||
++i;
|
||||
assert(i == std::cregex_token_iterator());
|
||||
}
|
||||
{
|
||||
std::regex phone_numbers("\\d{3}-(\\d{4})");
|
||||
const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
|
||||
std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
|
||||
phone_numbers, 1);
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i->str() == "1234");
|
||||
++i;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i->str() == "2345");
|
||||
++i;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i->str() == "3456");
|
||||
++i;
|
||||
assert(i == std::cregex_token_iterator());
|
||||
}
|
||||
}
|
@@ -0,0 +1,42 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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>
|
||||
|
||||
// class regex_iterator<BidirectionalIterator, charT, traits>
|
||||
|
||||
// template <std::size_t N>
|
||||
// regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
|
||||
// const regex_type&& re,
|
||||
// const std::vector<int>& submatches,
|
||||
// regex_constants::match_flag_type m =
|
||||
// regex_constants::match_default);
|
||||
|
||||
#include <__config>
|
||||
|
||||
#if _LIBCPP_STD_VER <= 11
|
||||
#error
|
||||
#else
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::regex phone_numbers("\\d{3}-(\\d{4})");
|
||||
const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
|
||||
std::vector<int> v;
|
||||
v.push_back(-1);
|
||||
v.push_back(-1);
|
||||
std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
|
||||
std::regex("\\d{3}-\\d{4}"), v);
|
||||
}
|
||||
}
|
||||
#endif
|
128
test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/vector.pass.cpp
Normal file
128
test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/vector.pass.cpp
Normal file
@@ -0,0 +1,128 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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>
|
||||
|
||||
// class regex_token_iterator<BidirectionalIterator, charT, traits>
|
||||
|
||||
// regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
|
||||
// const regex_type& re,
|
||||
// const std::vector<int>& submatches,
|
||||
// regex_constants::match_flag_type m =
|
||||
// regex_constants::match_default);
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::regex phone_numbers("\\d{3}-(\\d{4})");
|
||||
const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
|
||||
std::vector<int> v;
|
||||
v.push_back(-1);
|
||||
v.push_back(-1);
|
||||
std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
|
||||
phone_numbers, v);
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i->str() == "start ");
|
||||
++i;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i->str() == "start ");
|
||||
++i;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i->str() == ", ");
|
||||
++i;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i->str() == ", ");
|
||||
++i;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i->str() == ", ");
|
||||
++i;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i->str() == ", ");
|
||||
++i;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i->str() == " end");
|
||||
++i;
|
||||
assert(i == std::cregex_token_iterator());
|
||||
}
|
||||
{
|
||||
std::regex phone_numbers("\\d{3}-(\\d{4})");
|
||||
const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
|
||||
std::vector<int> v;
|
||||
v.push_back(-1);
|
||||
v.push_back(0);
|
||||
std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
|
||||
phone_numbers, v);
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i->str() == "start ");
|
||||
++i;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i->str() == "555-1234");
|
||||
++i;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i->str() == ", ");
|
||||
++i;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i->str() == "555-2345");
|
||||
++i;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i->str() == ", ");
|
||||
++i;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i->str() == "555-3456");
|
||||
++i;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i->str() == " end");
|
||||
++i;
|
||||
assert(i == std::cregex_token_iterator());
|
||||
}
|
||||
{
|
||||
std::regex phone_numbers("\\d{3}-(\\d{4})");
|
||||
const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
|
||||
std::vector<int> v;
|
||||
v.push_back(-1);
|
||||
v.push_back(0);
|
||||
v.push_back(1);
|
||||
std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
|
||||
phone_numbers, v);
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i->str() == "start ");
|
||||
++i;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i->str() == "555-1234");
|
||||
++i;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i->str() == "1234");
|
||||
++i;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i->str() == ", ");
|
||||
++i;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i->str() == "555-2345");
|
||||
++i;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i->str() == "2345");
|
||||
++i;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i->str() == ", ");
|
||||
++i;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i->str() == "555-3456");
|
||||
++i;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i->str() == "3456");
|
||||
++i;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i->str() == " end");
|
||||
++i;
|
||||
assert(i == std::cregex_token_iterator());
|
||||
}
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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>
|
||||
|
||||
// class regex_token_iterator<BidirectionalIterator, charT, traits>
|
||||
|
||||
// bool operator==(const regex_token_iterator& right) const;
|
||||
// bool operator!=(const regex_token_iterator& right) const;
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::regex phone_numbers("\\d{3}-\\d{4}");
|
||||
const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
|
||||
std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
|
||||
phone_numbers, -1);
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(!(i == std::cregex_token_iterator()));
|
||||
std::cregex_token_iterator i2 = i;
|
||||
assert(i2 == i);
|
||||
assert(!(i2 != i));
|
||||
++i;
|
||||
assert(!(i2 == i));
|
||||
assert(i2 != i);
|
||||
}
|
||||
}
|
@@ -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>
|
||||
|
||||
// class regex_token_iterator<BidirectionalIterator, charT, traits>
|
||||
|
||||
// const value_type& operator*() const;
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::regex phone_numbers("\\d{3}-\\d{4}");
|
||||
const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
|
||||
std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
|
||||
phone_numbers, -1);
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert((*i).str() == "start ");
|
||||
++i;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert((*i).str() == ", ");
|
||||
++i;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert((*i).str() == ", ");
|
||||
++i;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert((*i).str() == " end");
|
||||
++i;
|
||||
assert(i == std::cregex_token_iterator());
|
||||
}
|
||||
{
|
||||
std::regex phone_numbers("\\d{3}-\\d{4}");
|
||||
const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
|
||||
std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
|
||||
phone_numbers);
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert((*i).str() == "555-1234");
|
||||
++i;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert((*i).str() == "555-2345");
|
||||
++i;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert((*i).str() == "555-3456");
|
||||
++i;
|
||||
assert(i == std::cregex_token_iterator());
|
||||
}
|
||||
{
|
||||
std::regex phone_numbers("\\d{3}-(\\d{4})");
|
||||
const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
|
||||
std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
|
||||
phone_numbers, 1);
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert((*i).str() == "1234");
|
||||
++i;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert((*i).str() == "2345");
|
||||
++i;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert((*i).str() == "3456");
|
||||
++i;
|
||||
assert(i == std::cregex_token_iterator());
|
||||
}
|
||||
}
|
135
test/std/re/re.iter/re.tokiter/re.tokiter.incr/post.pass.cpp
Normal file
135
test/std/re/re.iter/re.tokiter/re.tokiter.incr/post.pass.cpp
Normal file
@@ -0,0 +1,135 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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>
|
||||
|
||||
// class regex_token_iterator<BidirectionalIterator, charT, traits>
|
||||
|
||||
// regex_token_iterator& operator++(int);
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::regex phone_numbers("\\d{3}-\\d{4}");
|
||||
const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
|
||||
std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
|
||||
phone_numbers, -1);
|
||||
std::cregex_token_iterator i2 = i;
|
||||
std::cregex_token_iterator i3;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i2 != std::cregex_token_iterator());
|
||||
assert(i->str() == "start ");
|
||||
assert(i2->str() == "start ");
|
||||
i3 = i++;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i2 != std::cregex_token_iterator());
|
||||
assert(i3 != std::cregex_token_iterator());
|
||||
assert(i->str() == ", ");
|
||||
assert(i2->str() == "start ");
|
||||
assert(i3->str() == "start ");
|
||||
i3 = i++;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i2 != std::cregex_token_iterator());
|
||||
assert(i3 != std::cregex_token_iterator());
|
||||
assert(i->str() == ", ");
|
||||
assert(i2->str() == "start ");
|
||||
assert(i3->str() == ", ");
|
||||
i3 = i++;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i2 != std::cregex_token_iterator());
|
||||
assert(i3 != std::cregex_token_iterator());
|
||||
assert(i->str() == " end");
|
||||
assert(i2->str() == "start ");
|
||||
assert(i3->str() == ", ");
|
||||
i3 = i++;
|
||||
assert(i == std::cregex_token_iterator());
|
||||
assert(i2 != std::cregex_token_iterator());
|
||||
assert(i3 != std::cregex_token_iterator());
|
||||
assert(i2->str() == "start ");
|
||||
assert(i3->str() == " end");
|
||||
}
|
||||
{
|
||||
std::regex phone_numbers("\\d{3}-\\d{4}");
|
||||
const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
|
||||
std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
|
||||
phone_numbers, -1);
|
||||
std::cregex_token_iterator i2 = i;
|
||||
std::cregex_token_iterator i3;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i2 != std::cregex_token_iterator());
|
||||
assert(i->str() == "start ");
|
||||
assert(i2->str() == "start ");
|
||||
i3 = i;
|
||||
++i;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i2 != std::cregex_token_iterator());
|
||||
assert(i3 != std::cregex_token_iterator());
|
||||
assert(i->str() == ", ");
|
||||
assert(i2->str() == "start ");
|
||||
assert(i3->str() == "start ");
|
||||
i3 = i;
|
||||
++i;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i2 != std::cregex_token_iterator());
|
||||
assert(i3 != std::cregex_token_iterator());
|
||||
assert(i->str() == ", ");
|
||||
assert(i2->str() == "start ");
|
||||
assert(i3->str() == ", ");
|
||||
i3 = i;
|
||||
++i;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i2 != std::cregex_token_iterator());
|
||||
assert(i3 != std::cregex_token_iterator());
|
||||
assert(i->str() == " end");
|
||||
assert(i2->str() == "start ");
|
||||
assert(i3->str() == ", ");
|
||||
i3 = i;
|
||||
++i;
|
||||
assert(i == std::cregex_token_iterator());
|
||||
assert(i2 != std::cregex_token_iterator());
|
||||
assert(i3 != std::cregex_token_iterator());
|
||||
assert(i2->str() == "start ");
|
||||
assert(i3->str() == " end");
|
||||
}
|
||||
{
|
||||
std::regex phone_numbers("\\d{3}-\\d{4}");
|
||||
const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
|
||||
std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
|
||||
phone_numbers);
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i->str() == "555-1234");
|
||||
i++;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i->str() == "555-2345");
|
||||
i++;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i->str() == "555-3456");
|
||||
i++;
|
||||
assert(i == std::cregex_token_iterator());
|
||||
}
|
||||
{
|
||||
std::regex phone_numbers("\\d{3}-(\\d{4})");
|
||||
const char phone_book[] = "start 555-1234, 555-2345, 555-3456 end";
|
||||
std::cregex_token_iterator i(std::begin(phone_book), std::end(phone_book)-1,
|
||||
phone_numbers, 1);
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i->str() == "1234");
|
||||
i++;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i->str() == "2345");
|
||||
i++;
|
||||
assert(i != std::cregex_token_iterator());
|
||||
assert(i->str() == "3456");
|
||||
i++;
|
||||
assert(i == std::cregex_token_iterator());
|
||||
}
|
||||
}
|
45
test/std/re/re.iter/re.tokiter/types.pass.cpp
Normal file
45
test/std/re/re.iter/re.tokiter/types.pass.cpp
Normal file
@@ -0,0 +1,45 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 charT = typename iterator_traits< BidirectionalIterator>::value_type,
|
||||
// class traits = regex_traits<charT>>
|
||||
// class regex_token_iterator
|
||||
// {
|
||||
// public:
|
||||
// typedef basic_regex<charT, traits> regex_type;
|
||||
// typedef sub_match<BidirectionalIterator> value_type;
|
||||
// typedef ptrdiff_t difference_type;
|
||||
// typedef const value_type* pointer;
|
||||
// typedef const value_type& reference;
|
||||
// typedef forward_iterator_tag iterator_category;
|
||||
|
||||
#include <regex>
|
||||
#include <type_traits>
|
||||
|
||||
template <class CharT>
|
||||
void
|
||||
test()
|
||||
{
|
||||
typedef std::regex_token_iterator<const CharT*> I;
|
||||
static_assert((std::is_same<typename I::regex_type, std::basic_regex<CharT> >::value), "");
|
||||
static_assert((std::is_same<typename I::value_type, std::sub_match<const CharT*> >::value), "");
|
||||
static_assert((std::is_same<typename I::difference_type, std::ptrdiff_t>::value), "");
|
||||
static_assert((std::is_same<typename I::pointer, const std::sub_match<const CharT*>*>::value), "");
|
||||
static_assert((std::is_same<typename I::reference, const std::sub_match<const CharT*>&>::value), "");
|
||||
static_assert((std::is_same<typename I::iterator_category, std::forward_iterator_tag>::value), "");
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test<char>();
|
||||
test<wchar_t>();
|
||||
}
|
33
test/std/re/re.regex/re.regex.assign/assign.il.pass.cpp
Normal file
33
test/std/re/re.regex/re.regex.assign/assign.il.pass.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 charT, class traits = regex_traits<charT>> class basic_regex;
|
||||
|
||||
// basic_regex&
|
||||
// assign(initializer_list<charT> il,
|
||||
// flag_type f = regex_constants::ECMAScript);
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
std::regex r2;
|
||||
r2.assign({'(', 'a', '(', '[', 'b', 'c', ']', ')', ')'});
|
||||
assert(r2.flags() == std::regex::ECMAScript);
|
||||
assert(r2.mark_count() == 2);
|
||||
|
||||
r2.assign({'(', 'a', '(', '[', 'b', 'c', ']', ')', ')'}, std::regex::extended);
|
||||
assert(r2.flags() == std::regex::extended);
|
||||
assert(r2.mark_count() == 2);
|
||||
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
}
|
26
test/std/re/re.regex/re.regex.assign/assign.pass.cpp
Normal file
26
test/std/re/re.regex/re.regex.assign/assign.pass.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 charT, class traits = regex_traits<charT>> class basic_regex;
|
||||
|
||||
// basic_regex& assign(const basic_regex& that);
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::regex r1("(a([bc]))");
|
||||
std::regex r2;
|
||||
r2.assign(r1);
|
||||
assert(r2.flags() == std::regex::ECMAScript);
|
||||
assert(r2.mark_count() == 2);
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 charT, class traits = regex_traits<charT>> class basic_regex;
|
||||
|
||||
// template <class InputIterator>
|
||||
// basic_regex&
|
||||
// assign(InputIterator first, InputIterator last,
|
||||
// flag_type f = regex_constants::ECMAScript);
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef input_iterator<std::string::const_iterator> I;
|
||||
typedef forward_iterator<std::string::const_iterator> F;
|
||||
std::string s4("(a([bc]))");
|
||||
std::regex r2;
|
||||
|
||||
r2.assign(I(s4.begin()), I(s4.end()));
|
||||
assert(r2.flags() == std::regex::ECMAScript);
|
||||
assert(r2.mark_count() == 2);
|
||||
|
||||
r2.assign(I(s4.begin()), I(s4.end()), std::regex::extended);
|
||||
assert(r2.flags() == std::regex::extended);
|
||||
assert(r2.mark_count() == 2);
|
||||
|
||||
r2.assign(F(s4.begin()), F(s4.end()));
|
||||
assert(r2.flags() == std::regex::ECMAScript);
|
||||
assert(r2.mark_count() == 2);
|
||||
|
||||
r2.assign(F(s4.begin()), F(s4.end()), std::regex::extended);
|
||||
assert(r2.flags() == std::regex::extended);
|
||||
assert(r2.mark_count() == 2);
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 charT, class traits = regex_traits<charT>> class basic_regex;
|
||||
|
||||
// basic_regex& assign(const charT* ptr, flag_type f = regex_constants::ECMAScript);
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::regex r2;
|
||||
r2.assign("(a([bc]))");
|
||||
assert(r2.flags() == std::regex::ECMAScript);
|
||||
assert(r2.mark_count() == 2);
|
||||
|
||||
r2.assign("(a([bc]))", std::regex::extended);
|
||||
assert(r2.flags() == std::regex::extended);
|
||||
assert(r2.mark_count() == 2);
|
||||
}
|
@@ -0,0 +1,25 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 charT, class traits = regex_traits<charT>> class basic_regex;
|
||||
|
||||
// basic_regex& assign(const charT* ptr, size_t len, flag_type f);
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::regex r2;
|
||||
r2.assign("(a([bc]))", 9, std::regex::extended);
|
||||
assert(r2.flags() == std::regex::extended);
|
||||
assert(r2.mark_count() == 2);
|
||||
}
|
@@ -0,0 +1,31 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 charT, class traits = regex_traits<charT>> class basic_regex;
|
||||
|
||||
// template <class string_traits, class A>
|
||||
// basic_regex& assign(const basic_string<charT, string_traits, A>& s,
|
||||
// flag_type f = regex_constants::ECMAScript);
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::regex r2;
|
||||
r2.assign(std::string("(a([bc]))"));
|
||||
assert(r2.flags() == std::regex::ECMAScript);
|
||||
assert(r2.mark_count() == 2);
|
||||
|
||||
r2.assign(std::string("(a([bc]))"), std::regex::extended);
|
||||
assert(r2.flags() == std::regex::extended);
|
||||
assert(r2.mark_count() == 2);
|
||||
}
|
26
test/std/re/re.regex/re.regex.assign/copy.pass.cpp
Normal file
26
test/std/re/re.regex/re.regex.assign/copy.pass.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 charT, class traits = regex_traits<charT>> class basic_regex;
|
||||
|
||||
// basic_regex& operator=(const basic_regex& e);
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::regex r1("(a([bc]))");
|
||||
std::regex r2;
|
||||
r2 = r1;
|
||||
assert(r2.flags() == std::regex::ECMAScript);
|
||||
assert(r2.mark_count() == 2);
|
||||
}
|
27
test/std/re/re.regex/re.regex.assign/il.pass.cpp
Normal file
27
test/std/re/re.regex/re.regex.assign/il.pass.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 charT, class traits = regex_traits<charT>> class basic_regex;
|
||||
|
||||
// basic_regex& operator=(initializer_list<charT> il);
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
std::regex r2;
|
||||
r2 = {'(', 'a', '(', '[', 'b', 'c', ']', ')', ')'};
|
||||
assert(r2.flags() == std::regex::ECMAScript);
|
||||
assert(r2.mark_count() == 2);
|
||||
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
}
|
25
test/std/re/re.regex/re.regex.assign/ptr.pass.cpp
Normal file
25
test/std/re/re.regex/re.regex.assign/ptr.pass.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 charT, class traits = regex_traits<charT>> class basic_regex;
|
||||
|
||||
// basic_regex& operator=(const charT* ptr);
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::regex r2;
|
||||
r2 = "(a([bc]))";
|
||||
assert(r2.flags() == std::regex::ECMAScript);
|
||||
assert(r2.mark_count() == 2);
|
||||
}
|
26
test/std/re/re.regex/re.regex.assign/string.pass.cpp
Normal file
26
test/std/re/re.regex/re.regex.assign/string.pass.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 charT, class traits = regex_traits<charT>> class basic_regex;
|
||||
|
||||
// template <class ST, class SA>
|
||||
// basic_regex& operator=(const basic_string<charT, ST, SA>& p);
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::regex r2;
|
||||
r2 = std::string("(a([bc]))");
|
||||
assert(r2.flags() == std::regex::ECMAScript);
|
||||
assert(r2.mark_count() == 2);
|
||||
}
|
65
test/std/re/re.regex/re.regex.const/constants.pass.cpp
Normal file
65
test/std/re/re.regex/re.regex.const/constants.pass.cpp
Normal file
@@ -0,0 +1,65 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 charT, class traits = regex_traits<charT>>
|
||||
// class basic_regex
|
||||
// {
|
||||
// public:
|
||||
// // constants:
|
||||
// static constexpr regex_constants::syntax_option_type icase = regex_constants::icase;
|
||||
// static constexpr regex_constants::syntax_option_type nosubs = regex_constants::nosubs;
|
||||
// static constexpr regex_constants::syntax_option_type optimize = regex_constants::optimize;
|
||||
// static constexpr regex_constants::syntax_option_type collate = regex_constants::collate;
|
||||
// static constexpr regex_constants::syntax_option_type ECMAScript = regex_constants::ECMAScript;
|
||||
// static constexpr regex_constants::syntax_option_type basic = regex_constants::basic;
|
||||
// static constexpr regex_constants::syntax_option_type extended = regex_constants::extended;
|
||||
// static constexpr regex_constants::syntax_option_type awk = regex_constants::awk;
|
||||
// static constexpr regex_constants::syntax_option_type grep = regex_constants::grep;
|
||||
// static constexpr regex_constants::syntax_option_type egrep = regex_constants::egrep;
|
||||
|
||||
#include <regex>
|
||||
#include <type_traits>
|
||||
|
||||
template <class _Tp>
|
||||
void where(const _Tp &) {}
|
||||
|
||||
template <class CharT>
|
||||
void
|
||||
test()
|
||||
{
|
||||
typedef std::basic_regex<CharT> BR;
|
||||
static_assert((BR::icase == std::regex_constants::icase), "");
|
||||
static_assert((BR::nosubs == std::regex_constants::nosubs), "");
|
||||
static_assert((BR::optimize == std::regex_constants::optimize), "");
|
||||
static_assert((BR::collate == std::regex_constants::collate), "");
|
||||
static_assert((BR::ECMAScript == std::regex_constants::ECMAScript), "");
|
||||
static_assert((BR::basic == std::regex_constants::basic), "");
|
||||
static_assert((BR::extended == std::regex_constants::extended), "");
|
||||
static_assert((BR::awk == std::regex_constants::awk), "");
|
||||
static_assert((BR::grep == std::regex_constants::grep), "");
|
||||
static_assert((BR::egrep == std::regex_constants::egrep), "");
|
||||
where(BR::icase);
|
||||
where(BR::nosubs);
|
||||
where(BR::optimize);
|
||||
where(BR::collate);
|
||||
where(BR::ECMAScript);
|
||||
where(BR::basic);
|
||||
where(BR::extended);
|
||||
where(BR::awk);
|
||||
where(BR::grep);
|
||||
where(BR::egrep);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test<char>();
|
||||
test<wchar_t>();
|
||||
}
|
28
test/std/re/re.regex/re.regex.construct/awk_oct.pass.cpp
Normal file
28
test/std/re/re.regex/re.regex.construct/awk_oct.pass.cpp
Normal 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 charT, class traits = regex_traits<charT>> class basic_regex;
|
||||
|
||||
// template <class ST, class SA>
|
||||
// basic_regex(const basic_string<charT, ST, SA>& s);
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
using std::regex_constants::awk;
|
||||
|
||||
assert(std::regex_match("\4", std::regex("\\4", awk)));
|
||||
assert(std::regex_match("\41", std::regex("\\41", awk)));
|
||||
assert(std::regex_match("\141", std::regex("\\141", awk)));
|
||||
assert(std::regex_match("\1411", std::regex("\\1411", awk)));
|
||||
}
|
45
test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp
Normal file
45
test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp
Normal file
@@ -0,0 +1,45 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 charT, class traits = regex_traits<charT>> class basic_regex;
|
||||
|
||||
// template <class ST, class SA>
|
||||
// basic_regex(const basic_string<charT, ST, SA>& s);
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
static bool error_escape_thrown(const char *pat)
|
||||
{
|
||||
bool result = false;
|
||||
try {
|
||||
std::regex re(pat);
|
||||
} catch (std::regex_error &ex) {
|
||||
result = (ex.code() == std::regex_constants::error_escape);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
assert(error_escape_thrown("[\\a]"));
|
||||
assert(error_escape_thrown("\\a"));
|
||||
|
||||
assert(error_escape_thrown("[\\e]"));
|
||||
assert(error_escape_thrown("\\e"));
|
||||
|
||||
assert(error_escape_thrown("[\\c:]"));
|
||||
assert(error_escape_thrown("\\c:"));
|
||||
assert(error_escape_thrown("\\c"));
|
||||
assert(!error_escape_thrown("[\\cA]"));
|
||||
assert(!error_escape_thrown("\\cA"));
|
||||
|
||||
}
|
25
test/std/re/re.regex/re.regex.construct/copy.pass.cpp
Normal file
25
test/std/re/re.regex/re.regex.construct/copy.pass.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 charT, class traits = regex_traits<charT>> class basic_regex;
|
||||
|
||||
// basic_regex(const basic_regex& e);
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::regex r1("(a([bc]))");
|
||||
std::regex r2 = r1;
|
||||
assert(r2.flags() == std::regex::ECMAScript);
|
||||
assert(r2.mark_count() == 2);
|
||||
}
|
32
test/std/re/re.regex/re.regex.construct/default.pass.cpp
Normal file
32
test/std/re/re.regex/re.regex.construct/default.pass.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 charT, class traits = regex_traits<charT>> class basic_regex;
|
||||
|
||||
// basic_regex();
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
template <class CharT>
|
||||
void
|
||||
test()
|
||||
{
|
||||
std::basic_regex<CharT> r;
|
||||
assert(r.flags() == 0);
|
||||
assert(r.mark_count() == 0);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test<char>();
|
||||
test<wchar_t>();
|
||||
}
|
70
test/std/re/re.regex/re.regex.construct/il_flg.pass.cpp
Normal file
70
test/std/re/re.regex/re.regex.construct/il_flg.pass.cpp
Normal file
@@ -0,0 +1,70 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 charT, class traits = regex_traits<charT>> class basic_regex;
|
||||
|
||||
// basic_regex(initializer_list<charT> il,
|
||||
// flag_type f = regex_constants::ECMAScript);
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
|
||||
void
|
||||
test(std::initializer_list<char> il, std::regex_constants::syntax_option_type f, unsigned mc)
|
||||
{
|
||||
std::basic_regex<char> r(il, f);
|
||||
assert(r.flags() == f);
|
||||
assert(r.mark_count() == mc);
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
std::string s1("\\(a\\)");
|
||||
std::string s2("\\(a[bc]\\)");
|
||||
std::string s3("\\(a\\([bc]\\)\\)");
|
||||
std::string s4("(a([bc]))");
|
||||
|
||||
test({'\\', '(', 'a', '\\', ')'}, std::regex_constants::basic, 1);
|
||||
test({'\\', '(', 'a', '[', 'b', 'c', ']', '\\', ')'}, std::regex_constants::basic, 1);
|
||||
test({'\\', '(', 'a', '\\', '(', '[', 'b', 'c', ']', '\\', ')', '\\', ')'}, std::regex_constants::basic, 2);
|
||||
test({'(', 'a', '(', '[', 'b', 'c', ']', ')', ')'}, std::regex_constants::basic, 0);
|
||||
|
||||
test({'\\', '(', 'a', '\\', ')'}, std::regex_constants::extended, 0);
|
||||
test({'\\', '(', 'a', '[', 'b', 'c', ']', '\\', ')'}, std::regex_constants::extended, 0);
|
||||
test({'\\', '(', 'a', '\\', '(', '[', 'b', 'c', ']', '\\', ')', '\\', ')'}, std::regex_constants::extended, 0);
|
||||
test({'(', 'a', '(', '[', 'b', 'c', ']', ')', ')'}, std::regex_constants::extended, 2);
|
||||
|
||||
test({'\\', '(', 'a', '\\', ')'}, std::regex_constants::ECMAScript, 0);
|
||||
test({'\\', '(', 'a', '[', 'b', 'c', ']', '\\', ')'}, std::regex_constants::ECMAScript, 0);
|
||||
test({'\\', '(', 'a', '\\', '(', '[', 'b', 'c', ']', '\\', ')', '\\', ')'}, std::regex_constants::ECMAScript, 0);
|
||||
test({'(', 'a', '(', '[', 'b', 'c', ']', ')', ')'}, std::regex_constants::ECMAScript, 2);
|
||||
|
||||
test({'\\', '(', 'a', '\\', ')'}, std::regex_constants::awk, 0);
|
||||
test({'\\', '(', 'a', '[', 'b', 'c', ']', '\\', ')'}, std::regex_constants::awk, 0);
|
||||
test({'\\', '(', 'a', '\\', '(', '[', 'b', 'c', ']', '\\', ')', '\\', ')'}, std::regex_constants::awk, 0);
|
||||
test({'(', 'a', '(', '[', 'b', 'c', ']', ')', ')'}, std::regex_constants::awk, 2);
|
||||
|
||||
test({'\\', '(', 'a', '\\', ')'}, std::regex_constants::grep, 1);
|
||||
test({'\\', '(', 'a', '[', 'b', 'c', ']', '\\', ')'}, std::regex_constants::grep, 1);
|
||||
test({'\\', '(', 'a', '\\', '(', '[', 'b', 'c', ']', '\\', ')', '\\', ')'}, std::regex_constants::grep, 2);
|
||||
test({'(', 'a', '(', '[', 'b', 'c', ']', ')', ')'}, std::regex_constants::grep, 0);
|
||||
|
||||
test({'\\', '(', 'a', '\\', ')'}, std::regex_constants::egrep, 0);
|
||||
test({'\\', '(', 'a', '[', 'b', 'c', ']', '\\', ')'}, std::regex_constants::egrep, 0);
|
||||
test({'\\', '(', 'a', '\\', '(', '[', 'b', 'c', ']', '\\', ')', '\\', ')'}, std::regex_constants::egrep, 0);
|
||||
test({'(', 'a', '(', '[', 'b', 'c', ']', ')', ')'}, std::regex_constants::egrep, 2);
|
||||
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
|
||||
}
|
43
test/std/re/re.regex/re.regex.construct/iter_iter.pass.cpp
Normal file
43
test/std/re/re.regex/re.regex.construct/iter_iter.pass.cpp
Normal file
@@ -0,0 +1,43 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 charT, class traits = regex_traits<charT>> class basic_regex;
|
||||
|
||||
// template <class ForwardIterator>
|
||||
// basic_regex(ForwardIterator first, ForwardIterator last);
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class Iter>
|
||||
void
|
||||
test(Iter first, Iter last, unsigned mc)
|
||||
{
|
||||
std::basic_regex<typename std::iterator_traits<Iter>::value_type> r(first, last);
|
||||
assert(r.flags() == std::regex_constants::ECMAScript);
|
||||
assert(r.mark_count() == mc);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef forward_iterator<std::string::const_iterator> F;
|
||||
std::string s1("\\(a\\)");
|
||||
std::string s2("\\(a[bc]\\)");
|
||||
std::string s3("\\(a\\([bc]\\)\\)");
|
||||
std::string s4("(a([bc]))");
|
||||
|
||||
test(F(s1.begin()), F(s1.end()), 0);
|
||||
test(F(s2.begin()), F(s2.end()), 0);
|
||||
test(F(s3.begin()), F(s3.end()), 0);
|
||||
test(F(s4.begin()), F(s4.end()), 2);
|
||||
}
|
@@ -0,0 +1,69 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 charT, class traits = regex_traits<charT>> class basic_regex;
|
||||
|
||||
// template <class ForwardIterator>
|
||||
// basic_regex(ForwardIterator first, ForwardIterator last,
|
||||
// flag_type f = regex_constants::ECMAScript);
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
#include "test_iterators.h"
|
||||
|
||||
template <class Iter>
|
||||
void
|
||||
test(Iter first, Iter last, std::regex_constants::syntax_option_type f, unsigned mc)
|
||||
{
|
||||
std::basic_regex<typename std::iterator_traits<Iter>::value_type> r(first, last, f);
|
||||
assert(r.flags() == f);
|
||||
assert(r.mark_count() == mc);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef forward_iterator<std::string::const_iterator> F;
|
||||
std::string s1("\\(a\\)");
|
||||
std::string s2("\\(a[bc]\\)");
|
||||
std::string s3("\\(a\\([bc]\\)\\)");
|
||||
std::string s4("(a([bc]))");
|
||||
|
||||
test(F(s1.begin()), F(s1.end()), std::regex_constants::basic, 1);
|
||||
test(F(s2.begin()), F(s2.end()), std::regex_constants::basic, 1);
|
||||
test(F(s3.begin()), F(s3.end()), std::regex_constants::basic, 2);
|
||||
test(F(s4.begin()), F(s4.end()), std::regex_constants::basic, 0);
|
||||
|
||||
test(F(s1.begin()), F(s1.end()), std::regex_constants::extended, 0);
|
||||
test(F(s2.begin()), F(s2.end()), std::regex_constants::extended, 0);
|
||||
test(F(s3.begin()), F(s3.end()), std::regex_constants::extended, 0);
|
||||
test(F(s4.begin()), F(s4.end()), std::regex_constants::extended, 2);
|
||||
|
||||
test(F(s1.begin()), F(s1.end()), std::regex_constants::ECMAScript, 0);
|
||||
test(F(s2.begin()), F(s2.end()), std::regex_constants::ECMAScript, 0);
|
||||
test(F(s3.begin()), F(s3.end()), std::regex_constants::ECMAScript, 0);
|
||||
test(F(s4.begin()), F(s4.end()), std::regex_constants::ECMAScript, 2);
|
||||
|
||||
test(F(s1.begin()), F(s1.end()), std::regex_constants::awk, 0);
|
||||
test(F(s2.begin()), F(s2.end()), std::regex_constants::awk, 0);
|
||||
test(F(s3.begin()), F(s3.end()), std::regex_constants::awk, 0);
|
||||
test(F(s4.begin()), F(s4.end()), std::regex_constants::awk, 2);
|
||||
|
||||
test(F(s1.begin()), F(s1.end()), std::regex_constants::grep, 1);
|
||||
test(F(s2.begin()), F(s2.end()), std::regex_constants::grep, 1);
|
||||
test(F(s3.begin()), F(s3.end()), std::regex_constants::grep, 2);
|
||||
test(F(s4.begin()), F(s4.end()), std::regex_constants::grep, 0);
|
||||
|
||||
test(F(s1.begin()), F(s1.end()), std::regex_constants::egrep, 0);
|
||||
test(F(s2.begin()), F(s2.end()), std::regex_constants::egrep, 0);
|
||||
test(F(s3.begin()), F(s3.end()), std::regex_constants::egrep, 0);
|
||||
test(F(s4.begin()), F(s4.end()), std::regex_constants::egrep, 2);
|
||||
}
|
34
test/std/re/re.regex/re.regex.construct/ptr.pass.cpp
Normal file
34
test/std/re/re.regex/re.regex.construct/ptr.pass.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 charT, class traits = regex_traits<charT>> class basic_regex;
|
||||
|
||||
// basic_regex(const charT* p);
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
template <class CharT>
|
||||
void
|
||||
test(const CharT* p, unsigned mc)
|
||||
{
|
||||
std::basic_regex<CharT> r(p);
|
||||
assert(r.flags() == std::regex_constants::ECMAScript);
|
||||
assert(r.mark_count() == mc);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test("\\(a\\)", 0);
|
||||
test("\\(a[bc]\\)", 0);
|
||||
test("\\(a\\([bc]\\)\\)", 0);
|
||||
test("(a([bc]))", 2);
|
||||
}
|
59
test/std/re/re.regex/re.regex.construct/ptr_flg.pass.cpp
Normal file
59
test/std/re/re.regex/re.regex.construct/ptr_flg.pass.cpp
Normal file
@@ -0,0 +1,59 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 charT, class traits = regex_traits<charT>> class basic_regex;
|
||||
|
||||
// basic_regex(const charT* p, flag_type f = regex_constants::ECMAScript);
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
template <class CharT>
|
||||
void
|
||||
test(const CharT* p, std::regex_constants::syntax_option_type f, unsigned mc)
|
||||
{
|
||||
std::basic_regex<CharT> r(p, f);
|
||||
assert(r.flags() == f);
|
||||
assert(r.mark_count() == mc);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test("\\(a\\)", std::regex_constants::basic, 1);
|
||||
test("\\(a[bc]\\)", std::regex_constants::basic, 1);
|
||||
test("\\(a\\([bc]\\)\\)", std::regex_constants::basic, 2);
|
||||
test("(a([bc]))", std::regex_constants::basic, 0);
|
||||
|
||||
test("\\(a\\)", std::regex_constants::extended, 0);
|
||||
test("\\(a[bc]\\)", std::regex_constants::extended, 0);
|
||||
test("\\(a\\([bc]\\)\\)", std::regex_constants::extended, 0);
|
||||
test("(a([bc]))", std::regex_constants::extended, 2);
|
||||
|
||||
test("\\(a\\)", std::regex_constants::ECMAScript, 0);
|
||||
test("\\(a[bc]\\)", std::regex_constants::ECMAScript, 0);
|
||||
test("\\(a\\([bc]\\)\\)", std::regex_constants::ECMAScript, 0);
|
||||
test("(a([bc]))", std::regex_constants::ECMAScript, 2);
|
||||
|
||||
test("\\(a\\)", std::regex_constants::awk, 0);
|
||||
test("\\(a[bc]\\)", std::regex_constants::awk, 0);
|
||||
test("\\(a\\([bc]\\)\\)", std::regex_constants::awk, 0);
|
||||
test("(a([bc]))", std::regex_constants::awk, 2);
|
||||
|
||||
test("\\(a\\)", std::regex_constants::grep, 1);
|
||||
test("\\(a[bc]\\)", std::regex_constants::grep, 1);
|
||||
test("\\(a\\([bc]\\)\\)", std::regex_constants::grep, 2);
|
||||
test("(a([bc]))", std::regex_constants::grep, 0);
|
||||
|
||||
test("\\(a\\)", std::regex_constants::egrep, 0);
|
||||
test("\\(a[bc]\\)", std::regex_constants::egrep, 0);
|
||||
test("\\(a\\([bc]\\)\\)", std::regex_constants::egrep, 0);
|
||||
test("(a([bc]))", std::regex_constants::egrep, 2);
|
||||
}
|
@@ -0,0 +1,60 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 charT, class traits = regex_traits<charT>> class basic_regex;
|
||||
|
||||
// basic_regex(const charT* p, size_t len, flag_type f);
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
template <class CharT>
|
||||
void
|
||||
test(const CharT* p, std::size_t len, std::regex_constants::syntax_option_type f,
|
||||
unsigned mc)
|
||||
{
|
||||
std::basic_regex<CharT> r(p, len, f);
|
||||
assert(r.flags() == f);
|
||||
assert(r.mark_count() == mc);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test("\\(a\\)", 5, std::regex_constants::basic, 1);
|
||||
test("\\(a[bc]\\)", 9, std::regex_constants::basic, 1);
|
||||
test("\\(a\\([bc]\\)\\)", 13, std::regex_constants::basic, 2);
|
||||
test("(a([bc]))", 9, std::regex_constants::basic, 0);
|
||||
|
||||
test("\\(a\\)", 5, std::regex_constants::extended, 0);
|
||||
test("\\(a[bc]\\)", 9, std::regex_constants::extended, 0);
|
||||
test("\\(a\\([bc]\\)\\)", 13, std::regex_constants::extended, 0);
|
||||
test("(a([bc]))", 9, std::regex_constants::extended, 2);
|
||||
|
||||
test("\\(a\\)", 5, std::regex_constants::ECMAScript, 0);
|
||||
test("\\(a[bc]\\)", 9, std::regex_constants::ECMAScript, 0);
|
||||
test("\\(a\\([bc]\\)\\)", 13, std::regex_constants::ECMAScript, 0);
|
||||
test("(a([bc]))", 9, std::regex_constants::ECMAScript, 2);
|
||||
|
||||
test("\\(a\\)", 5, std::regex_constants::awk, 0);
|
||||
test("\\(a[bc]\\)", 9, std::regex_constants::awk, 0);
|
||||
test("\\(a\\([bc]\\)\\)", 13, std::regex_constants::awk, 0);
|
||||
test("(a([bc]))", 9, std::regex_constants::awk, 2);
|
||||
|
||||
test("\\(a\\)", 5, std::regex_constants::grep, 1);
|
||||
test("\\(a[bc]\\)", 9, std::regex_constants::grep, 1);
|
||||
test("\\(a\\([bc]\\)\\)", 13, std::regex_constants::grep, 2);
|
||||
test("(a([bc]))", 9, std::regex_constants::grep, 0);
|
||||
|
||||
test("\\(a\\)", 5, std::regex_constants::egrep, 0);
|
||||
test("\\(a[bc]\\)", 9, std::regex_constants::egrep, 0);
|
||||
test("\\(a\\([bc]\\)\\)", 13, std::regex_constants::egrep, 0);
|
||||
test("(a([bc]))", 9, std::regex_constants::egrep, 2);
|
||||
}
|
35
test/std/re/re.regex/re.regex.construct/string.pass.cpp
Normal file
35
test/std/re/re.regex/re.regex.construct/string.pass.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 charT, class traits = regex_traits<charT>> class basic_regex;
|
||||
|
||||
// template <class ST, class SA>
|
||||
// basic_regex(const basic_string<charT, ST, SA>& s);
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
template <class String>
|
||||
void
|
||||
test(const String& p, unsigned mc)
|
||||
{
|
||||
std::basic_regex<typename String::value_type> r(p);
|
||||
assert(r.flags() == std::regex_constants::ECMAScript);
|
||||
assert(r.mark_count() == mc);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test(std::string("\\(a\\)"), 0);
|
||||
test(std::string("\\(a[bc]\\)"), 0);
|
||||
test(std::string("\\(a\\([bc]\\)\\)"), 0);
|
||||
test(std::string("(a([bc]))"), 2);
|
||||
}
|
61
test/std/re/re.regex/re.regex.construct/string_flg.pass.cpp
Normal file
61
test/std/re/re.regex/re.regex.construct/string_flg.pass.cpp
Normal file
@@ -0,0 +1,61 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 charT, class traits = regex_traits<charT>> class basic_regex;
|
||||
|
||||
// template <class ST, class SA>
|
||||
// basic_regex(const basic_string<charT, ST, SA>& s,
|
||||
// flag_type f = regex_constants::ECMAScript);
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
template <class String>
|
||||
void
|
||||
test(const String& p, std::regex_constants::syntax_option_type f, unsigned mc)
|
||||
{
|
||||
std::basic_regex<typename String::value_type> r(p, f);
|
||||
assert(r.flags() == f);
|
||||
assert(r.mark_count() == mc);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test(std::string("\\(a\\)"), std::regex_constants::basic, 1);
|
||||
test(std::string("\\(a[bc]\\)"), std::regex_constants::basic, 1);
|
||||
test(std::string("\\(a\\([bc]\\)\\)"), std::regex_constants::basic, 2);
|
||||
test(std::string("(a([bc]))"), std::regex_constants::basic, 0);
|
||||
|
||||
test(std::string("\\(a\\)"), std::regex_constants::extended, 0);
|
||||
test(std::string("\\(a[bc]\\)"), std::regex_constants::extended, 0);
|
||||
test(std::string("\\(a\\([bc]\\)\\)"), std::regex_constants::extended, 0);
|
||||
test(std::string("(a([bc]))"), std::regex_constants::extended, 2);
|
||||
|
||||
test(std::string("\\(a\\)"), std::regex_constants::ECMAScript, 0);
|
||||
test(std::string("\\(a[bc]\\)"), std::regex_constants::ECMAScript, 0);
|
||||
test(std::string("\\(a\\([bc]\\)\\)"), std::regex_constants::ECMAScript, 0);
|
||||
test(std::string("(a([bc]))"), std::regex_constants::ECMAScript, 2);
|
||||
|
||||
test(std::string("\\(a\\)"), std::regex_constants::awk, 0);
|
||||
test(std::string("\\(a[bc]\\)"), std::regex_constants::awk, 0);
|
||||
test(std::string("\\(a\\([bc]\\)\\)"), std::regex_constants::awk, 0);
|
||||
test(std::string("(a([bc]))"), std::regex_constants::awk, 2);
|
||||
|
||||
test(std::string("\\(a\\)"), std::regex_constants::grep, 1);
|
||||
test(std::string("\\(a[bc]\\)"), std::regex_constants::grep, 1);
|
||||
test(std::string("\\(a\\([bc]\\)\\)"), std::regex_constants::grep, 2);
|
||||
test(std::string("(a([bc]))"), std::regex_constants::grep, 0);
|
||||
|
||||
test(std::string("\\(a\\)"), std::regex_constants::egrep, 0);
|
||||
test(std::string("\\(a[bc]\\)"), std::regex_constants::egrep, 0);
|
||||
test(std::string("\\(a\\([bc]\\)\\)"), std::regex_constants::egrep, 0);
|
||||
test(std::string("(a([bc]))"), std::regex_constants::egrep, 2);
|
||||
}
|
31
test/std/re/re.regex/re.regex.locale/imbue.pass.cpp
Normal file
31
test/std/re/re.regex/re.regex.locale/imbue.pass.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 charT, class traits = regex_traits<charT>> class basic_regex;
|
||||
|
||||
// locale_type imbue(locale_type loc);
|
||||
|
||||
#include <regex>
|
||||
#include <locale>
|
||||
#include <cassert>
|
||||
|
||||
#include "platform_support.h" // locale name macros
|
||||
|
||||
int main()
|
||||
{
|
||||
std::regex r;
|
||||
std::locale loc = r.imbue(std::locale(LOCALE_en_US_UTF_8));
|
||||
assert(loc.name() == "C");
|
||||
assert(r.getloc().name() == LOCALE_en_US_UTF_8);
|
||||
loc = r.imbue(std::locale("C"));
|
||||
assert(loc.name() == LOCALE_en_US_UTF_8);
|
||||
assert(r.getloc().name() == "C");
|
||||
}
|
12
test/std/re/re.regex/re.regex.nonmemb/nothing_to_do.pass.cpp
Normal file
12
test/std/re/re.regex/re.regex.nonmemb/nothing_to_do.pass.cpp
Normal file
@@ -0,0 +1,12 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 charT, class traits = regex_traits<charT>> class basic_regex;
|
||||
|
||||
// template <class charT, class traits>
|
||||
// void swap(basic_regex<charT, traits>& lhs, basic_regex<charT, traits>& rhs);
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::regex r1("(a([bc]))");
|
||||
std::regex r2;
|
||||
swap(r2, r1);
|
||||
assert(r1.flags() == std::regex::ECMAScript);
|
||||
assert(r1.mark_count() == 0);
|
||||
assert(r2.flags() == std::regex::ECMAScript);
|
||||
assert(r2.mark_count() == 2);
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
28
test/std/re/re.regex/re.regex.swap/swap.pass.cpp
Normal file
28
test/std/re/re.regex/re.regex.swap/swap.pass.cpp
Normal 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 charT, class traits = regex_traits<charT>> class basic_regex;
|
||||
|
||||
// void swap(basic_regex& e);
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::regex r1("(a([bc]))");
|
||||
std::regex r2;
|
||||
r2.swap(r1);
|
||||
assert(r1.flags() == std::regex::ECMAScript);
|
||||
assert(r1.mark_count() == 0);
|
||||
assert(r2.flags() == std::regex::ECMAScript);
|
||||
assert(r2.mark_count() == 2);
|
||||
}
|
35
test/std/re/re.regex/types.pass.cpp
Normal file
35
test/std/re/re.regex/types.pass.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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 charT, class traits = regex_traits<charT>>
|
||||
// class basic_regex
|
||||
// {
|
||||
// public:
|
||||
// // types:
|
||||
// typedef charT value_type;
|
||||
// typedef regex_constants::syntax_option_type flag_type;
|
||||
// typedef typename traits::locale_type locale_type;
|
||||
|
||||
#include <regex>
|
||||
#include <type_traits>
|
||||
|
||||
int main()
|
||||
{
|
||||
static_assert((std::is_same<std::basic_regex<char>::value_type, char>::value), "");
|
||||
static_assert((std::is_same<std::basic_regex<char>::flag_type,
|
||||
std::regex_constants::syntax_option_type>::value), "");
|
||||
static_assert((std::is_same<std::basic_regex<char>::locale_type, std::locale>::value), "");
|
||||
|
||||
static_assert((std::is_same<std::basic_regex<wchar_t>::value_type, wchar_t>::value), "");
|
||||
static_assert((std::is_same<std::basic_regex<wchar_t>::flag_type,
|
||||
std::regex_constants::syntax_option_type>::value), "");
|
||||
static_assert((std::is_same<std::basic_regex<wchar_t>::locale_type, std::locale>::value), "");
|
||||
}
|
13
test/std/re/re.req/nothing_to_do.pass.cpp
Normal file
13
test/std/re/re.req/nothing_to_do.pass.cpp
Normal file
@@ -0,0 +1,13 @@
|
||||
// -*- C++ -*-
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
38
test/std/re/re.results/re.results.acc/begin_end.pass.cpp
Normal file
38
test/std/re/re.results/re.results.acc/begin_end.pass.cpp
Normal 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>
|
||||
|
||||
// class match_results<BidirectionalIterator, Allocator>
|
||||
|
||||
// const_iterator begin() const;
|
||||
// const_iterator end() const;
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
void
|
||||
test()
|
||||
{
|
||||
std::match_results<const char*> m;
|
||||
const char s[] = "abcdefghijk";
|
||||
assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
|
||||
|
||||
std::match_results<const char*>::const_iterator i = m.begin();
|
||||
std::match_results<const char*>::const_iterator e = m.end();
|
||||
|
||||
assert(e - i == m.size());
|
||||
for (int j = 0; i != e; ++i, ++j)
|
||||
assert(*i == m[j]);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test();
|
||||
}
|
38
test/std/re/re.results/re.results.acc/cbegin_cend.pass.cpp
Normal file
38
test/std/re/re.results/re.results.acc/cbegin_cend.pass.cpp
Normal 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>
|
||||
|
||||
// class match_results<BidirectionalIterator, Allocator>
|
||||
|
||||
// const_iterator cbegin() const;
|
||||
// const_iterator cend() const;
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
void
|
||||
test()
|
||||
{
|
||||
std::match_results<const char*> m;
|
||||
const char s[] = "abcdefghijk";
|
||||
assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
|
||||
|
||||
std::match_results<const char*>::const_iterator i = m.cbegin();
|
||||
std::match_results<const char*>::const_iterator e = m.cend();
|
||||
|
||||
assert(e - i == m.size());
|
||||
for (int j = 0; i != e; ++i, ++j)
|
||||
assert(*i == m[j]);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test();
|
||||
}
|
50
test/std/re/re.results/re.results.acc/index.pass.cpp
Normal file
50
test/std/re/re.results/re.results.acc/index.pass.cpp
Normal file
@@ -0,0 +1,50 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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>
|
||||
|
||||
// class match_results<BidirectionalIterator, Allocator>
|
||||
|
||||
// const_reference operator[](size_type n) const;
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
void
|
||||
test()
|
||||
{
|
||||
std::match_results<const char*> m;
|
||||
const char s[] = "abcdefghijk";
|
||||
assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
|
||||
|
||||
assert(m[0].first == s+2);
|
||||
assert(m[0].second == s+9);
|
||||
assert(m[0].matched == true);
|
||||
|
||||
assert(m[1].first == s+4);
|
||||
assert(m[1].second == s+7);
|
||||
assert(m[1].matched == true);
|
||||
|
||||
assert(m[2].first == s+4);
|
||||
assert(m[2].second == s+5);
|
||||
assert(m[2].matched == true);
|
||||
|
||||
assert(m[3].first == s+11);
|
||||
assert(m[3].second == s+11);
|
||||
assert(m[3].matched == false);
|
||||
|
||||
assert(m[4].first == s+11);
|
||||
assert(m[4].second == s+11);
|
||||
assert(m[4].matched == false);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test();
|
||||
}
|
36
test/std/re/re.results/re.results.acc/length.pass.cpp
Normal file
36
test/std/re/re.results/re.results.acc/length.pass.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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>
|
||||
|
||||
// class match_results<BidirectionalIterator, Allocator>
|
||||
|
||||
// difference_type length(size_type sub = 0) const;
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
void
|
||||
test()
|
||||
{
|
||||
std::match_results<const char*> m;
|
||||
const char s[] = "abcdefghijk";
|
||||
assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
|
||||
assert(m.length() == m[0].length());
|
||||
assert(m.length(0) == m[0].length());
|
||||
assert(m.length(1) == m[1].length());
|
||||
assert(m.length(2) == m[2].length());
|
||||
assert(m.length(3) == m[3].length());
|
||||
assert(m.length(4) == m[4].length());
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test();
|
||||
}
|
36
test/std/re/re.results/re.results.acc/position.pass.cpp
Normal file
36
test/std/re/re.results/re.results.acc/position.pass.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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>
|
||||
|
||||
// class match_results<BidirectionalIterator, Allocator>
|
||||
|
||||
// difference_type position(size_type sub = 0) const;
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
void
|
||||
test()
|
||||
{
|
||||
std::match_results<const char*> m;
|
||||
const char s[] = "abcdefghijk";
|
||||
assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
|
||||
assert(m.position() == std::distance(s, m[0].first));
|
||||
assert(m.position(0) == std::distance(s, m[0].first));
|
||||
assert(m.position(1) == std::distance(s, m[1].first));
|
||||
assert(m.position(2) == std::distance(s, m[2].first));
|
||||
assert(m.position(3) == std::distance(s, m[3].first));
|
||||
assert(m.position(4) == std::distance(s, m[4].first));
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test();
|
||||
}
|
34
test/std/re/re.results/re.results.acc/prefix.pass.cpp
Normal file
34
test/std/re/re.results/re.results.acc/prefix.pass.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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>
|
||||
|
||||
// class match_results<BidirectionalIterator, Allocator>
|
||||
|
||||
// const_reference prefix() const;
|
||||
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
void
|
||||
test()
|
||||
{
|
||||
std::match_results<const char*> m;
|
||||
const char s[] = "abcdefghijk";
|
||||
assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
|
||||
|
||||
assert(m.prefix().first == s);
|
||||
assert(m.prefix().second == s+2);
|
||||
assert(m.prefix().matched == true);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test();
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user