From 5a83710e371fe68a06e6e3876c6a2c8b820a8976 Mon Sep 17 00:00:00 2001 From: Eric Fiselier Date: Sat, 20 Dec 2014 01:40:03 +0000 Subject: Move test into test/std subdirectory. llvm-svn: 224658 --- .../re.regex/re.regex.construct/awk_oct.pass.cpp | 28 +++++++++ .../re.regex.construct/bad_escape.pass.cpp | 45 ++++++++++++++ .../re/re.regex/re.regex.construct/copy.pass.cpp | 25 ++++++++ .../re.regex/re.regex.construct/default.pass.cpp | 32 ++++++++++ .../re/re.regex/re.regex.construct/il_flg.pass.cpp | 70 ++++++++++++++++++++++ .../re.regex/re.regex.construct/iter_iter.pass.cpp | 43 +++++++++++++ .../re.regex.construct/iter_iter_flg.pass.cpp | 69 +++++++++++++++++++++ .../re/re.regex/re.regex.construct/ptr.pass.cpp | 34 +++++++++++ .../re.regex/re.regex.construct/ptr_flg.pass.cpp | 59 ++++++++++++++++++ .../re.regex.construct/ptr_size_flg.pass.cpp | 60 +++++++++++++++++++ .../re/re.regex/re.regex.construct/string.pass.cpp | 35 +++++++++++ .../re.regex.construct/string_flg.pass.cpp | 61 +++++++++++++++++++ 12 files changed, 561 insertions(+) create mode 100644 libcxx/test/std/re/re.regex/re.regex.construct/awk_oct.pass.cpp create mode 100644 libcxx/test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp create mode 100644 libcxx/test/std/re/re.regex/re.regex.construct/copy.pass.cpp create mode 100644 libcxx/test/std/re/re.regex/re.regex.construct/default.pass.cpp create mode 100644 libcxx/test/std/re/re.regex/re.regex.construct/il_flg.pass.cpp create mode 100644 libcxx/test/std/re/re.regex/re.regex.construct/iter_iter.pass.cpp create mode 100644 libcxx/test/std/re/re.regex/re.regex.construct/iter_iter_flg.pass.cpp create mode 100644 libcxx/test/std/re/re.regex/re.regex.construct/ptr.pass.cpp create mode 100644 libcxx/test/std/re/re.regex/re.regex.construct/ptr_flg.pass.cpp create mode 100644 libcxx/test/std/re/re.regex/re.regex.construct/ptr_size_flg.pass.cpp create mode 100644 libcxx/test/std/re/re.regex/re.regex.construct/string.pass.cpp create mode 100644 libcxx/test/std/re/re.regex/re.regex.construct/string_flg.pass.cpp (limited to 'libcxx/test/std/re/re.regex/re.regex.construct') diff --git a/libcxx/test/std/re/re.regex/re.regex.construct/awk_oct.pass.cpp b/libcxx/test/std/re/re.regex/re.regex.construct/awk_oct.pass.cpp new file mode 100644 index 00000000000..4b7e5e62929 --- /dev/null +++ b/libcxx/test/std/re/re.regex/re.regex.construct/awk_oct.pass.cpp @@ -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. +// +//===----------------------------------------------------------------------===// + +// + +// template > class basic_regex; + +// template +// basic_regex(const basic_string& s); + +#include +#include + +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))); +} diff --git a/libcxx/test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp b/libcxx/test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp new file mode 100644 index 00000000000..9455527412b --- /dev/null +++ b/libcxx/test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp @@ -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. +// +//===----------------------------------------------------------------------===// + +// + +// template > class basic_regex; + +// template +// basic_regex(const basic_string& s); + +#include +#include + +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")); + +} diff --git a/libcxx/test/std/re/re.regex/re.regex.construct/copy.pass.cpp b/libcxx/test/std/re/re.regex/re.regex.construct/copy.pass.cpp new file mode 100644 index 00000000000..c2788f0fa2c --- /dev/null +++ b/libcxx/test/std/re/re.regex/re.regex.construct/copy.pass.cpp @@ -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. +// +//===----------------------------------------------------------------------===// + +// + +// template > class basic_regex; + +// basic_regex(const basic_regex& e); + +#include +#include + +int main() +{ + std::regex r1("(a([bc]))"); + std::regex r2 = r1; + assert(r2.flags() == std::regex::ECMAScript); + assert(r2.mark_count() == 2); +} diff --git a/libcxx/test/std/re/re.regex/re.regex.construct/default.pass.cpp b/libcxx/test/std/re/re.regex/re.regex.construct/default.pass.cpp new file mode 100644 index 00000000000..d959c1ec582 --- /dev/null +++ b/libcxx/test/std/re/re.regex/re.regex.construct/default.pass.cpp @@ -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. +// +//===----------------------------------------------------------------------===// + +// + +// template > class basic_regex; + +// basic_regex(); + +#include +#include + +template +void +test() +{ + std::basic_regex r; + assert(r.flags() == 0); + assert(r.mark_count() == 0); +} + +int main() +{ + test(); + test(); +} diff --git a/libcxx/test/std/re/re.regex/re.regex.construct/il_flg.pass.cpp b/libcxx/test/std/re/re.regex/re.regex.construct/il_flg.pass.cpp new file mode 100644 index 00000000000..70d28df370d --- /dev/null +++ b/libcxx/test/std/re/re.regex/re.regex.construct/il_flg.pass.cpp @@ -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. +// +//===----------------------------------------------------------------------===// + +// + +// template > class basic_regex; + +// basic_regex(initializer_list il, +// flag_type f = regex_constants::ECMAScript); + +#include +#include + +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + +void +test(std::initializer_list il, std::regex_constants::syntax_option_type f, unsigned mc) +{ + std::basic_regex 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 +} diff --git a/libcxx/test/std/re/re.regex/re.regex.construct/iter_iter.pass.cpp b/libcxx/test/std/re/re.regex/re.regex.construct/iter_iter.pass.cpp new file mode 100644 index 00000000000..a38e1623419 --- /dev/null +++ b/libcxx/test/std/re/re.regex/re.regex.construct/iter_iter.pass.cpp @@ -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. +// +//===----------------------------------------------------------------------===// + +// + +// template > class basic_regex; + +// template +// basic_regex(ForwardIterator first, ForwardIterator last); + +#include +#include + +#include "test_iterators.h" + +template +void +test(Iter first, Iter last, unsigned mc) +{ + std::basic_regex::value_type> r(first, last); + assert(r.flags() == std::regex_constants::ECMAScript); + assert(r.mark_count() == mc); +} + +int main() +{ + typedef forward_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); +} diff --git a/libcxx/test/std/re/re.regex/re.regex.construct/iter_iter_flg.pass.cpp b/libcxx/test/std/re/re.regex/re.regex.construct/iter_iter_flg.pass.cpp new file mode 100644 index 00000000000..c4c440e6d24 --- /dev/null +++ b/libcxx/test/std/re/re.regex/re.regex.construct/iter_iter_flg.pass.cpp @@ -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. +// +//===----------------------------------------------------------------------===// + +// + +// template > class basic_regex; + +// template +// basic_regex(ForwardIterator first, ForwardIterator last, +// flag_type f = regex_constants::ECMAScript); + +#include +#include + +#include "test_iterators.h" + +template +void +test(Iter first, Iter last, std::regex_constants::syntax_option_type f, unsigned mc) +{ + std::basic_regex::value_type> r(first, last, f); + assert(r.flags() == f); + assert(r.mark_count() == mc); +} + +int main() +{ + typedef forward_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); +} diff --git a/libcxx/test/std/re/re.regex/re.regex.construct/ptr.pass.cpp b/libcxx/test/std/re/re.regex/re.regex.construct/ptr.pass.cpp new file mode 100644 index 00000000000..b99b58b469c --- /dev/null +++ b/libcxx/test/std/re/re.regex/re.regex.construct/ptr.pass.cpp @@ -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. +// +//===----------------------------------------------------------------------===// + +// + +// template > class basic_regex; + +// basic_regex(const charT* p); + +#include +#include + +template +void +test(const CharT* p, unsigned mc) +{ + std::basic_regex 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); +} diff --git a/libcxx/test/std/re/re.regex/re.regex.construct/ptr_flg.pass.cpp b/libcxx/test/std/re/re.regex/re.regex.construct/ptr_flg.pass.cpp new file mode 100644 index 00000000000..138e20efbf6 --- /dev/null +++ b/libcxx/test/std/re/re.regex/re.regex.construct/ptr_flg.pass.cpp @@ -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. +// +//===----------------------------------------------------------------------===// + +// + +// template > class basic_regex; + +// basic_regex(const charT* p, flag_type f = regex_constants::ECMAScript); + +#include +#include + +template +void +test(const CharT* p, std::regex_constants::syntax_option_type f, unsigned mc) +{ + std::basic_regex 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); +} diff --git a/libcxx/test/std/re/re.regex/re.regex.construct/ptr_size_flg.pass.cpp b/libcxx/test/std/re/re.regex/re.regex.construct/ptr_size_flg.pass.cpp new file mode 100644 index 00000000000..d623a15936f --- /dev/null +++ b/libcxx/test/std/re/re.regex/re.regex.construct/ptr_size_flg.pass.cpp @@ -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. +// +//===----------------------------------------------------------------------===// + +// + +// template > class basic_regex; + +// basic_regex(const charT* p, size_t len, flag_type f); + +#include +#include + +template +void +test(const CharT* p, std::size_t len, std::regex_constants::syntax_option_type f, + unsigned mc) +{ + std::basic_regex 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); +} diff --git a/libcxx/test/std/re/re.regex/re.regex.construct/string.pass.cpp b/libcxx/test/std/re/re.regex/re.regex.construct/string.pass.cpp new file mode 100644 index 00000000000..b58b8e03cd2 --- /dev/null +++ b/libcxx/test/std/re/re.regex/re.regex.construct/string.pass.cpp @@ -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. +// +//===----------------------------------------------------------------------===// + +// + +// template > class basic_regex; + +// template +// basic_regex(const basic_string& s); + +#include +#include + +template +void +test(const String& p, unsigned mc) +{ + std::basic_regex 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); +} diff --git a/libcxx/test/std/re/re.regex/re.regex.construct/string_flg.pass.cpp b/libcxx/test/std/re/re.regex/re.regex.construct/string_flg.pass.cpp new file mode 100644 index 00000000000..768de568e22 --- /dev/null +++ b/libcxx/test/std/re/re.regex/re.regex.construct/string_flg.pass.cpp @@ -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. +// +//===----------------------------------------------------------------------===// + +// + +// template > class basic_regex; + +// template +// basic_regex(const basic_string& s, +// flag_type f = regex_constants::ECMAScript); + +#include +#include + +template +void +test(const String& p, std::regex_constants::syntax_option_type f, unsigned mc) +{ + std::basic_regex 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); +} -- cgit v1.2.3