summaryrefslogtreecommitdiffstats
path: root/libcxx/test
diff options
context:
space:
mode:
authorHoward Hinnant <hhinnant@apple.com>2010-06-21 21:01:43 +0000
committerHoward Hinnant <hhinnant@apple.com>2010-06-21 21:01:43 +0000
commit24757ff75e5f1af2405ad45280bcadd6d344762c (patch)
tree13019a4e8e39a3a3b4294e8159d83ce5b69d56cc /libcxx/test
parent280e61f148d66ba5a5352e7d9dfa70ce64f1fa29 (diff)
downloadbcm5719-llvm-24757ff75e5f1af2405ad45280bcadd6d344762c.tar.gz
bcm5719-llvm-24757ff75e5f1af2405ad45280bcadd6d344762c.zip
Finished [re.traits]. I'd like to acknowledge the help of Bjorn Reese with <regex>.
llvm-svn: 106478
Diffstat (limited to 'libcxx/test')
-rw-r--r--libcxx/test/re/re.traits/default.pass.cpp16
-rw-r--r--libcxx/test/re/re.traits/getloc.pass.cpp15
-rw-r--r--libcxx/test/re/re.traits/imbue.pass.cpp9
-rw-r--r--libcxx/test/re/re.traits/isctype.pass.cpp260
-rw-r--r--libcxx/test/re/re.traits/lookup_classname.pass.cpp187
-rw-r--r--libcxx/test/re/re.traits/value.pass.cpp108
6 files changed, 588 insertions, 7 deletions
diff --git a/libcxx/test/re/re.traits/default.pass.cpp b/libcxx/test/re/re.traits/default.pass.cpp
index ebc3d80e390..0e071e8d028 100644
--- a/libcxx/test/re/re.traits/default.pass.cpp
+++ b/libcxx/test/re/re.traits/default.pass.cpp
@@ -15,9 +15,21 @@
// regex_traits();
#include <regex>
+#include <cassert>
int main()
{
- std::regex_traits<char> t1();
- std::regex_traits<wchar_t> t2();
+ {
+ std::regex_traits<char> t1;
+ assert(t1.getloc().name() == "C");
+ std::regex_traits<wchar_t> t2;
+ assert(t2.getloc().name() == "C");
+ }
+ {
+ std::locale::global(std::locale("en_US"));
+ std::regex_traits<char> t1;
+ assert(t1.getloc().name() == "en_US");
+ std::regex_traits<wchar_t> t2;
+ assert(t2.getloc().name() == "en_US");
+ }
}
diff --git a/libcxx/test/re/re.traits/getloc.pass.cpp b/libcxx/test/re/re.traits/getloc.pass.cpp
index b5d1b7015c7..3c2618fc13b 100644
--- a/libcxx/test/re/re.traits/getloc.pass.cpp
+++ b/libcxx/test/re/re.traits/getloc.pass.cpp
@@ -14,8 +14,21 @@
// locale_type getloc()const;
#include <regex>
+#include <cassert>
int main()
{
-#error getloc not implemented
+ {
+ std::regex_traits<char> t1;
+ assert(t1.getloc().name() == "C");
+ std::regex_traits<wchar_t> t2;
+ assert(t2.getloc().name() == "C");
+ }
+ {
+ std::locale::global(std::locale("en_US"));
+ std::regex_traits<char> t1;
+ assert(t1.getloc().name() == "en_US");
+ std::regex_traits<wchar_t> t2;
+ assert(t2.getloc().name() == "en_US");
+ }
}
diff --git a/libcxx/test/re/re.traits/imbue.pass.cpp b/libcxx/test/re/re.traits/imbue.pass.cpp
index 687ff64bfd0..3fd86afa79f 100644
--- a/libcxx/test/re/re.traits/imbue.pass.cpp
+++ b/libcxx/test/re/re.traits/imbue.pass.cpp
@@ -14,8 +14,15 @@
// locale_type imbue(locale_type l);
#include <regex>
+#include <locale>
+#include <cassert>
int main()
{
-#error imbue not implemented
+ {
+ std::regex_traits<char> t;
+ std::locale loc = t.imbue(std::locale("en_US"));
+ assert(loc.name() == "C");
+ assert(t.getloc().name() == "en_US");
+ }
}
diff --git a/libcxx/test/re/re.traits/isctype.pass.cpp b/libcxx/test/re/re.traits/isctype.pass.cpp
index 7cb141e2b5a..dddaa562380 100644
--- a/libcxx/test/re/re.traits/isctype.pass.cpp
+++ b/libcxx/test/re/re.traits/isctype.pass.cpp
@@ -14,8 +14,266 @@
// bool isctype(charT c, char_class_type f) const;
#include <regex>
+#include <cassert>
int main()
{
-#error isctype not implemented
+ {
+ std::regex_traits<char> t;
+
+ std::string s("w");
+ assert( t.isctype('_', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('a', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('5', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('-', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('@', t.lookup_classname(s.begin(), s.end())));
+
+ s = "alnum";
+ assert(!t.isctype('_', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('a', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('5', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('-', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('@', t.lookup_classname(s.begin(), s.end())));
+
+ s = "alpha";
+ assert(!t.isctype('_', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('a', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('5', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('-', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('@', t.lookup_classname(s.begin(), s.end())));
+
+ s = "blank";
+ assert(!t.isctype('_', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('a', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('5', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('-', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('@', t.lookup_classname(s.begin(), s.end())));
+
+ s = "cntrl";
+ assert( t.isctype('\n', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('_', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('a', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('5', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('-', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('@', t.lookup_classname(s.begin(), s.end())));
+
+ s = "digit";
+ assert(!t.isctype('\n', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('_', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('a', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('5', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('-', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('@', t.lookup_classname(s.begin(), s.end())));
+
+ s = "graph";
+ assert(!t.isctype('\n', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('_', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('a', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('5', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('-', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('@', t.lookup_classname(s.begin(), s.end())));
+
+ s = "lower";
+ assert(!t.isctype('\n', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('_', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('a', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('5', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('-', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('@', t.lookup_classname(s.begin(), s.end())));
+
+ s = "print";
+ assert(!t.isctype('\n', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('_', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('a', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('5', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('-', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('@', t.lookup_classname(s.begin(), s.end())));
+
+ s = "punct";
+ assert(!t.isctype('\n', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('_', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('a', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('5', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('-', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('@', t.lookup_classname(s.begin(), s.end())));
+
+ s = "space";
+ assert( t.isctype('\n', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('_', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('a', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('5', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('-', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('@', t.lookup_classname(s.begin(), s.end())));
+
+ s = "upper";
+ assert(!t.isctype('\n', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('_', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('a', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('5', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('-', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('@', t.lookup_classname(s.begin(), s.end())));
+
+ s = "xdigit";
+ assert(!t.isctype('\n', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('_', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('a', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('Z', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype('5', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(' ', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('-', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype('@', t.lookup_classname(s.begin(), s.end())));
+ }
+ {
+ std::regex_traits<wchar_t> t;
+
+ std::wstring s(L"w");
+ assert( t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
+
+ s = L"alnum";
+ assert(!t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
+
+ s = L"alpha";
+ assert(!t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
+
+ s = L"blank";
+ assert(!t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
+
+ s = L"cntrl";
+ assert( t.isctype(L'\n', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
+
+ s = L"digit";
+ assert(!t.isctype(L'\n', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
+
+ s = L"graph";
+ assert(!t.isctype(L'\n', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
+
+ s = L"lower";
+ assert(!t.isctype(L'\n', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
+
+ s = L"print";
+ assert(!t.isctype(L'\n', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
+
+ s = L"punct";
+ assert(!t.isctype(L'\n', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
+
+ s = L"space";
+ assert( t.isctype(L'\n', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
+
+ s = L"upper";
+ assert(!t.isctype(L'\n', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
+
+ s = L"xdigit";
+ assert(!t.isctype(L'\n', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'_', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'a', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'Z', t.lookup_classname(s.begin(), s.end())));
+ assert( t.isctype(L'5', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L' ', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'-', t.lookup_classname(s.begin(), s.end())));
+ assert(!t.isctype(L'@', t.lookup_classname(s.begin(), s.end())));
+ }
}
diff --git a/libcxx/test/re/re.traits/lookup_classname.pass.cpp b/libcxx/test/re/re.traits/lookup_classname.pass.cpp
index 80df4ce0434..20baf01acb6 100644
--- a/libcxx/test/re/re.traits/lookup_classname.pass.cpp
+++ b/libcxx/test/re/re.traits/lookup_classname.pass.cpp
@@ -17,8 +17,193 @@
// bool icase = false) const;
#include <regex>
+#include <cassert>
+#include "iterators.h"
+
+template <class char_type>
+void
+test(const char_type* A, std::ctype_base::mask expected, bool icase = false)
+{
+ std::regex_traits<char_type> t;
+ typedef forward_iterator<const char_type*> F;
+ assert(t.lookup_classname(F(A), F(A + t.length(A)), icase) == expected);
+}
int main()
{
-#error lookup_classname not implemented
+ test("d", std::ctype_base::digit);
+ test("D", std::ctype_base::digit);
+ test("d", std::ctype_base::digit, true);
+ test("D", std::ctype_base::digit, true);
+
+ test("w", std::regex_traits<char>::__regex_word | std::ctype_base::alnum
+ | std::ctype_base::upper | std::ctype_base::lower);
+ test("W", std::regex_traits<char>::__regex_word | std::ctype_base::alnum
+ | std::ctype_base::upper | std::ctype_base::lower);
+ test("w", std::regex_traits<char>::__regex_word | std::ctype_base::alnum
+ | std::ctype_base::upper | std::ctype_base::lower, true);
+ test("W", std::regex_traits<char>::__regex_word | std::ctype_base::alnum
+ | std::ctype_base::upper | std::ctype_base::lower, true);
+
+ test("s", std::ctype_base::space);
+ test("S", std::ctype_base::space);
+ test("s", std::ctype_base::space, true);
+ test("S", std::ctype_base::space, true);
+
+ test("alnum", std::ctype_base::alnum);
+ test("AlNum", std::ctype_base::alnum);
+ test("alnum", std::ctype_base::alnum, true);
+ test("AlNum", std::ctype_base::alnum, true);
+
+ test("alpha", std::ctype_base::alpha);
+ test("Alpha", std::ctype_base::alpha);
+ test("alpha", std::ctype_base::alpha, true);
+ test("Alpha", std::ctype_base::alpha, true);
+
+ test("blank", std::ctype_base::blank);
+ test("Blank", std::ctype_base::blank);
+ test("blank", std::ctype_base::blank, true);
+ test("Blank", std::ctype_base::blank, true);
+
+ test("cntrl", std::ctype_base::cntrl);
+ test("Cntrl", std::ctype_base::cntrl);
+ test("cntrl", std::ctype_base::cntrl, true);
+ test("Cntrl", std::ctype_base::cntrl, true);
+
+ test("digit", std::ctype_base::digit);
+ test("Digit", std::ctype_base::digit);
+ test("digit", std::ctype_base::digit, true);
+ test("Digit", std::ctype_base::digit, true);
+
+ test("digit", std::ctype_base::digit);
+ test("DIGIT", std::ctype_base::digit);
+ test("digit", std::ctype_base::digit, true);
+ test("Digit", std::ctype_base::digit, true);
+
+ test("graph", std::ctype_base::graph);
+ test("GRAPH", std::ctype_base::graph);
+ test("graph", std::ctype_base::graph, true);
+ test("Graph", std::ctype_base::graph, true);
+
+ test("lower", std::ctype_base::lower);
+ test("LOWER", std::ctype_base::lower);
+ test("lower", std::ctype_base::lower | std::ctype_base::alpha, true);
+ test("Lower", std::ctype_base::lower | std::ctype_base::alpha, true);
+
+ test("print", std::ctype_base::print);
+ test("PRINT", std::ctype_base::print);
+ test("print", std::ctype_base::print, true);
+ test("Print", std::ctype_base::print, true);
+
+ test("punct", std::ctype_base::punct);
+ test("PUNCT", std::ctype_base::punct);
+ test("punct", std::ctype_base::punct, true);
+ test("Punct", std::ctype_base::punct, true);
+
+ test("space", std::ctype_base::space);
+ test("SPACE", std::ctype_base::space);
+ test("space", std::ctype_base::space, true);
+ test("Space", std::ctype_base::space, true);
+
+ test("upper", std::ctype_base::upper);
+ test("UPPER", std::ctype_base::upper);
+ test("upper", std::ctype_base::upper | std::ctype_base::alpha, true);
+ test("Upper", std::ctype_base::upper | std::ctype_base::alpha, true);
+
+ test("xdigit", std::ctype_base::xdigit);
+ test("XDIGIT", std::ctype_base::xdigit);
+ test("xdigit", std::ctype_base::xdigit, true);
+ test("Xdigit", std::ctype_base::xdigit, true);
+
+ test("dig", 0);
+ test("", 0);
+ test("digits", 0);
+
+ test(L"d", std::ctype_base::digit);
+ test(L"D", std::ctype_base::digit);
+ test(L"d", std::ctype_base::digit, true);
+ test(L"D", std::ctype_base::digit, true);
+
+ test(L"w", std::regex_traits<wchar_t>::__regex_word | std::ctype_base::alnum
+ | std::ctype_base::upper | std::ctype_base::lower);
+ test(L"W", std::regex_traits<wchar_t>::__regex_word | std::ctype_base::alnum
+ | std::ctype_base::upper | std::ctype_base::lower);
+ test(L"w", std::regex_traits<wchar_t>::__regex_word | std::ctype_base::alnum
+ | std::ctype_base::upper | std::ctype_base::lower, true);
+ test(L"W", std::regex_traits<wchar_t>::__regex_word | std::ctype_base::alnum
+ | std::ctype_base::upper | std::ctype_base::lower, true);
+
+ test(L"s", std::ctype_base::space);
+ test(L"S", std::ctype_base::space);
+ test(L"s", std::ctype_base::space, true);
+ test(L"S", std::ctype_base::space, true);
+
+ test(L"alnum", std::ctype_base::alnum);
+ test(L"AlNum", std::ctype_base::alnum);
+ test(L"alnum", std::ctype_base::alnum, true);
+ test(L"AlNum", std::ctype_base::alnum, true);
+
+ test(L"alpha", std::ctype_base::alpha);
+ test(L"Alpha", std::ctype_base::alpha);
+ test(L"alpha", std::ctype_base::alpha, true);
+ test(L"Alpha", std::ctype_base::alpha, true);
+
+ test(L"blank", std::ctype_base::blank);
+ test(L"Blank", std::ctype_base::blank);
+ test(L"blank", std::ctype_base::blank, true);
+ test(L"Blank", std::ctype_base::blank, true);
+
+ test(L"cntrl", std::ctype_base::cntrl);
+ test(L"Cntrl", std::ctype_base::cntrl);
+ test(L"cntrl", std::ctype_base::cntrl, true);
+ test(L"Cntrl", std::ctype_base::cntrl, true);
+
+ test(L"digit", std::ctype_base::digit);
+ test(L"Digit", std::ctype_base::digit);
+ test(L"digit", std::ctype_base::digit, true);
+ test(L"Digit", std::ctype_base::digit, true);
+
+ test(L"digit", std::ctype_base::digit);
+ test(L"DIGIT", std::ctype_base::digit);
+ test(L"digit", std::ctype_base::digit, true);
+ test(L"Digit", std::ctype_base::digit, true);
+
+ test(L"graph", std::ctype_base::graph);
+ test(L"GRAPH", std::ctype_base::graph);
+ test(L"graph", std::ctype_base::graph, true);
+ test(L"Graph", std::ctype_base::graph, true);
+
+ test(L"lower", std::ctype_base::lower);
+ test(L"LOWER", std::ctype_base::lower);
+ test(L"lower", std::ctype_base::lower | std::ctype_base::alpha, true);
+ test(L"Lower", std::ctype_base::lower | std::ctype_base::alpha, true);
+
+ test(L"print", std::ctype_base::print);
+ test(L"PRINT", std::ctype_base::print);
+ test(L"print", std::ctype_base::print, true);
+ test(L"Print", std::ctype_base::print, true);
+
+ test(L"punct", std::ctype_base::punct);
+ test(L"PUNCT", std::ctype_base::punct);
+ test(L"punct", std::ctype_base::punct, true);
+ test(L"Punct", std::ctype_base::punct, true);
+
+ test(L"space", std::ctype_base::space);
+ test(L"SPACE", std::ctype_base::space);
+ test(L"space", std::ctype_base::space, true);
+ test(L"Space", std::ctype_base::space, true);
+
+ test(L"upper", std::ctype_base::upper);
+ test(L"UPPER", std::ctype_base::upper);
+ test(L"upper", std::ctype_base::upper | std::ctype_base::alpha, true);
+ test(L"Upper", std::ctype_base::upper | std::ctype_base::alpha, true);
+
+ test(L"xdigit", std::ctype_base::xdigit);
+ test(L"XDIGIT", std::ctype_base::xdigit);
+ test(L"xdigit", std::ctype_base::xdigit, true);
+ test(L"Xdigit", std::ctype_base::xdigit, true);
+
+ test(L"dig", 0);
+ test(L"", 0);
+ test(L"digits", 0);
}
diff --git a/libcxx/test/re/re.traits/value.pass.cpp b/libcxx/test/re/re.traits/value.pass.cpp
index c2e8b0d6790..4cbf924d833 100644
--- a/libcxx/test/re/re.traits/value.pass.cpp
+++ b/libcxx/test/re/re.traits/value.pass.cpp
@@ -13,9 +13,115 @@
// int value(charT ch, int radix) const;
+#include <iostream>
+
#include <regex>
+#include <cassert>
int main()
{
-#error value not implemented
+ {
+ std::regex_traits<char> t;
+
+ for (char c = 0; c < '0'; ++c)
+ {
+ assert(t.value(c, 8) == -1);
+ assert(t.value(c, 10) == -1);
+ assert(t.value(c, 16) == -1);
+ }
+ for (char c = '0'; c < '8'; ++c)
+ {
+ assert(t.value(c, 8) == c - '0');
+ assert(t.value(c, 10) == c - '0');
+ assert(t.value(c, 16) == c - '0');
+ }
+ for (char c = '8'; c < ':'; ++c)
+ {
+ assert(t.value(c, 8) == -1);
+ assert(t.value(c, 10) == c - '0');
+ assert(t.value(c, 16) == c - '0');
+ }
+ for (char c = ':'; c < 'A'; ++c)
+ {
+ assert(t.value(c, 8) == -1);
+ assert(t.value(c, 10) == -1);
+ assert(t.value(c, 16) == -1);
+ }
+ for (char c = 'A'; c < 'G'; ++c)
+ {
+ assert(t.value(c, 8) == -1);
+ assert(t.value(c, 10) == -1);
+ assert(t.value(c, 16) == c - 'A' +10);
+ }
+ for (char c = 'G'; c < 'a'; ++c)
+ {
+ assert(t.value(c, 8) == -1);
+ assert(t.value(c, 10) == -1);
+ assert(t.value(c, 16) == -1);
+ }
+ for (char c = 'a'; c < 'g'; ++c)
+ {
+ assert(t.value(c, 8) == -1);
+ assert(t.value(c, 10) == -1);
+ assert(t.value(c, 16) == c - 'a' +10);
+ }
+ for (int c = 'g'; c < 256; ++c)
+ {
+ assert(t.value(char(c), 8) == -1);
+ assert(t.value(char(c), 10) == -1);
+ assert(t.value(char(c), 16) == -1);
+ }
+ }
+ {
+ std::regex_traits<wchar_t> t;
+
+ for (wchar_t c = 0; c < '0'; ++c)
+ {
+ assert(t.value(c, 8) == -1);
+ assert(t.value(c, 10) == -1);
+ assert(t.value(c, 16) == -1);
+ }
+ for (wchar_t c = '0'; c < '8'; ++c)
+ {
+ assert(t.value(c, 8) == c - '0');
+ assert(t.value(c, 10) == c - '0');
+ assert(t.value(c, 16) == c - '0');
+ }
+ for (wchar_t c = '8'; c < ':'; ++c)
+ {
+ assert(t.value(c, 8) == -1);
+ assert(t.value(c, 10) == c - '0');
+ assert(t.value(c, 16) == c - '0');
+ }
+ for (wchar_t c = ':'; c < 'A'; ++c)
+ {
+ assert(t.value(c, 8) == -1);
+ assert(t.value(c, 10) == -1);
+ assert(t.value(c, 16) == -1);
+ }
+ for (wchar_t c = 'A'; c < 'G'; ++c)
+ {
+ assert(t.value(c, 8) == -1);
+ assert(t.value(c, 10) == -1);
+ assert(t.value(c, 16) == c - 'A' +10);
+ }
+ for (wchar_t c = 'G'; c < 'a'; ++c)
+ {
+ assert(t.value(c, 8) == -1);
+ assert(t.value(c, 10) == -1);
+ assert(t.value(c, 16) == -1);
+ }
+ for (wchar_t c = 'a'; c < 'g'; ++c)
+ {
+ assert(t.value(c, 8) == -1);
+ assert(t.value(c, 10) == -1);
+ assert(t.value(c, 16) == c - 'a' +10);
+ }
+ for (int c = 'g'; c < 0xFFFF; ++c)
+ {
+ assert(t.value(c, 8) == -1);
+ assert(t.value(c, 10) == -1);
+ assert(t.value(c, 16) == -1);
+ }
+ }
}
OpenPOWER on IntegriCloud