summaryrefslogtreecommitdiffstats
path: root/libcxx/test/re
diff options
context:
space:
mode:
authorHoward Hinnant <hhinnant@apple.com>2010-06-24 21:28:00 +0000
committerHoward Hinnant <hhinnant@apple.com>2010-06-24 21:28:00 +0000
commit24e98486a3b6076bfa1b5fac5c2be0ec264d10c9 (patch)
tree3bab4b034474b5f1b8073e45e22b6a95483c3082 /libcxx/test/re
parent2b87d44c5de111da0389f832e7311101f61e6a55 (diff)
downloadbcm5719-llvm-24e98486a3b6076bfa1b5fac5c2be0ec264d10c9.tar.gz
bcm5719-llvm-24e98486a3b6076bfa1b5fac5c2be0ec264d10c9.zip
Continuing to work through regex, and updated libcxx_by_chapter.pdf with weekly test results
llvm-svn: 106790
Diffstat (limited to 'libcxx/test/re')
-rw-r--r--libcxx/test/re/re.badexp/regex_error.pass.cpp31
-rw-r--r--libcxx/test/re/re.regex/re.regex.const/constants.pass.cpp52
-rw-r--r--libcxx/test/re/re.regex/re.regex.construct/default.pass.cpp32
-rw-r--r--libcxx/test/re/re.regex/types.pass.cpp35
4 files changed, 137 insertions, 13 deletions
diff --git a/libcxx/test/re/re.badexp/regex_error.pass.cpp b/libcxx/test/re/re.badexp/regex_error.pass.cpp
index 6145b8eae65..849e372e499 100644
--- a/libcxx/test/re/re.badexp/regex_error.pass.cpp
+++ b/libcxx/test/re/re.badexp/regex_error.pass.cpp
@@ -26,66 +26,71 @@ int main()
{
std::regex_error e(std::regex_constants::error_collate);
assert(e.code() == std::regex_constants::error_collate);
- assert(e.what() == std::string("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("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("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("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("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("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("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("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("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("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("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("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("error_stack"));
+ assert(e.what() == std::string("There was insufficient memory to determine whether the regular "
+ "expression could match the specified character sequence."));
}
}
diff --git a/libcxx/test/re/re.regex/re.regex.const/constants.pass.cpp b/libcxx/test/re/re.regex/re.regex.const/constants.pass.cpp
new file mode 100644
index 00000000000..634cb2ecc6e
--- /dev/null
+++ b/libcxx/test/re/re.regex/re.regex.const/constants.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+// {
+// 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 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), "");
+}
+
+int main()
+{
+ test<char>();
+ test<wchar_t>();
+}
diff --git a/libcxx/test/re/re.regex/re.regex.construct/default.pass.cpp b/libcxx/test/re/re.regex/re.regex.construct/default.pass.cpp
new file mode 100644
index 00000000000..44930f6d737
--- /dev/null
+++ b/libcxx/test/re/re.regex/re.regex.construct/default.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// 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();
+
+#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>();
+}
diff --git a/libcxx/test/re/re.regex/types.pass.cpp b/libcxx/test/re/re.regex/types.pass.cpp
new file mode 100644
index 00000000000..4d90737eddd
--- /dev/null
+++ b/libcxx/test/re/re.regex/types.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
+// {
+// 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), "");
+}
OpenPOWER on IntegriCloud