summaryrefslogtreecommitdiffstats
path: root/libcxx/test/re/re.regex
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/test/re/re.regex')
-rw-r--r--libcxx/test/re/re.regex/re.regex.construct/il_flg.pass.cpp70
-rw-r--r--libcxx/test/re/re.regex/re.regex.construct/iter_iter.pass.cpp43
-rw-r--r--libcxx/test/re/re.regex/re.regex.construct/iter_iter_flg.pass.cpp69
-rw-r--r--libcxx/test/re/re.regex/re.regex.construct/ptr.pass.cpp36
-rw-r--r--libcxx/test/re/re.regex/re.regex.construct/ptr_flg.pass.cpp26
-rw-r--r--libcxx/test/re/re.regex/re.regex.construct/ptr_size_flg.pass.cpp60
-rw-r--r--libcxx/test/re/re.regex/re.regex.construct/string.pass.cpp35
-rw-r--r--libcxx/test/re/re.regex/re.regex.construct/string_flg.pass.cpp63
8 files changed, 401 insertions, 1 deletions
diff --git a/libcxx/test/re/re.regex/re.regex.construct/il_flg.pass.cpp b/libcxx/test/re/re.regex/re.regex.construct/il_flg.pass.cpp
new file mode 100644
index 00000000000..6ced811a051
--- /dev/null
+++ b/libcxx/test/re/re.regex/re.regex.construct/il_flg.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. 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>
+
+#ifdef _LIBCPP_MOVE
+
+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
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+ 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
+}
diff --git a/libcxx/test/re/re.regex/re.regex.construct/iter_iter.pass.cpp b/libcxx/test/re/re.regex/re.regex.construct/iter_iter.pass.cpp
new file mode 100644
index 00000000000..2c387b5764d
--- /dev/null
+++ b/libcxx/test/re/re.regex/re.regex.construct/iter_iter.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. 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 "../../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);
+}
diff --git a/libcxx/test/re/re.regex/re.regex.construct/iter_iter_flg.pass.cpp b/libcxx/test/re/re.regex/re.regex.construct/iter_iter_flg.pass.cpp
new file mode 100644
index 00000000000..e4db52c7c71
--- /dev/null
+++ b/libcxx/test/re/re.regex/re.regex.construct/iter_iter_flg.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. 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 "../../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);
+}
diff --git a/libcxx/test/re/re.regex/re.regex.construct/ptr.pass.cpp b/libcxx/test/re/re.regex/re.regex.construct/ptr.pass.cpp
new file mode 100644
index 00000000000..23b3d17568e
--- /dev/null
+++ b/libcxx/test/re/re.regex/re.regex.construct/ptr.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <regex>
+
+// template <class charT, class traits = regex_traits<charT>> class basic_regex;
+
+// basic_regex(const charT* p);
+
+#include <iostream>
+
+#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);
+}
diff --git a/libcxx/test/re/re.regex/re.regex.construct/ptr_flg.pass.cpp b/libcxx/test/re/re.regex/re.regex.construct/ptr_flg.pass.cpp
index f2d7c814307..31f9da9e4df 100644
--- a/libcxx/test/re/re.regex/re.regex.construct/ptr_flg.pass.cpp
+++ b/libcxx/test/re/re.regex/re.regex.construct/ptr_flg.pass.cpp
@@ -29,9 +29,33 @@ test(const CharT* p, std::regex_constants::syntax_option_type f, unsigned mc)
int main()
{
- test("", std::regex_constants::basic, 0);
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/re/re.regex/re.regex.construct/ptr_size_flg.pass.cpp b/libcxx/test/re/re.regex/re.regex.construct/ptr_size_flg.pass.cpp
new file mode 100644
index 00000000000..532ed3bf05d
--- /dev/null
+++ b/libcxx/test/re/re.regex/re.regex.construct/ptr_size_flg.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. 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);
+}
diff --git a/libcxx/test/re/re.regex/re.regex.construct/string.pass.cpp b/libcxx/test/re/re.regex/re.regex.construct/string.pass.cpp
new file mode 100644
index 00000000000..4145225a346
--- /dev/null
+++ b/libcxx/test/re/re.regex/re.regex.construct/string.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. 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);
+}
diff --git a/libcxx/test/re/re.regex/re.regex.construct/string_flg.pass.cpp b/libcxx/test/re/re.regex/re.regex.construct/string_flg.pass.cpp
new file mode 100644
index 00000000000..56ba2af7c79
--- /dev/null
+++ b/libcxx/test/re/re.regex/re.regex.construct/string_flg.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. 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 <iostream>
+
+#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);
+}
OpenPOWER on IntegriCloud