diff options
Diffstat (limited to 'libcxx/test/std/re/re.traits')
-rw-r--r-- | libcxx/test/std/re/re.traits/default.pass.cpp | 37 | ||||
-rw-r--r-- | libcxx/test/std/re/re.traits/getloc.pass.cpp | 36 | ||||
-rw-r--r-- | libcxx/test/std/re/re.traits/imbue.pass.cpp | 30 | ||||
-rw-r--r-- | libcxx/test/std/re/re.traits/isctype.pass.cpp | 279 | ||||
-rw-r--r-- | libcxx/test/std/re/re.traits/length.pass.cpp | 31 | ||||
-rw-r--r-- | libcxx/test/std/re/re.traits/lookup_classname.pass.cpp | 211 | ||||
-rw-r--r-- | libcxx/test/std/re/re.traits/lookup_collatename.pass.cpp | 190 | ||||
-rw-r--r-- | libcxx/test/std/re/re.traits/transform.pass.cpp | 44 | ||||
-rw-r--r-- | libcxx/test/std/re/re.traits/transform_primary.pass.cpp | 49 | ||||
-rw-r--r-- | libcxx/test/std/re/re.traits/translate.pass.cpp | 34 | ||||
-rw-r--r-- | libcxx/test/std/re/re.traits/translate_nocase.pass.cpp | 72 | ||||
-rw-r--r-- | libcxx/test/std/re/re.traits/types.pass.cpp | 32 | ||||
-rw-r--r-- | libcxx/test/std/re/re.traits/value.pass.cpp | 125 |
13 files changed, 1170 insertions, 0 deletions
diff --git a/libcxx/test/std/re/re.traits/default.pass.cpp b/libcxx/test/std/re/re.traits/default.pass.cpp new file mode 100644 index 00000000000..c9a97e025ac --- /dev/null +++ b/libcxx/test/std/re/re.traits/default.pass.cpp @@ -0,0 +1,37 @@ +// -*- 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> + +// template <class charT> struct regex_traits; + +// regex_traits(); + +#include <regex> +#include <cassert> + +#include "platform_support.h" // locale name macros + +int main() +{ + { + 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(LOCALE_en_US_UTF_8)); + std::regex_traits<char> t1; + assert(t1.getloc().name() == LOCALE_en_US_UTF_8); + std::regex_traits<wchar_t> t2; + assert(t2.getloc().name() == LOCALE_en_US_UTF_8); + } +} diff --git a/libcxx/test/std/re/re.traits/getloc.pass.cpp b/libcxx/test/std/re/re.traits/getloc.pass.cpp new file mode 100644 index 00000000000..27ab6cd8654 --- /dev/null +++ b/libcxx/test/std/re/re.traits/getloc.pass.cpp @@ -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> + +// template <class charT> struct regex_traits; + +// locale_type getloc()const; + +#include <regex> +#include <cassert> + +#include "platform_support.h" // locale name macros + +int main() +{ + { + 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(LOCALE_en_US_UTF_8)); + std::regex_traits<char> t1; + assert(t1.getloc().name() == LOCALE_en_US_UTF_8); + std::regex_traits<wchar_t> t2; + assert(t2.getloc().name() == LOCALE_en_US_UTF_8); + } +} diff --git a/libcxx/test/std/re/re.traits/imbue.pass.cpp b/libcxx/test/std/re/re.traits/imbue.pass.cpp new file mode 100644 index 00000000000..11eca41de37 --- /dev/null +++ b/libcxx/test/std/re/re.traits/imbue.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// 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> struct regex_traits; + +// locale_type imbue(locale_type l); + +#include <regex> +#include <locale> +#include <cassert> + +#include "platform_support.h" // locale name macros + +int main() +{ + { + std::regex_traits<char> t; + std::locale loc = t.imbue(std::locale(LOCALE_en_US_UTF_8)); + assert(loc.name() == "C"); + assert(t.getloc().name() == LOCALE_en_US_UTF_8); + } +} diff --git a/libcxx/test/std/re/re.traits/isctype.pass.cpp b/libcxx/test/std/re/re.traits/isctype.pass.cpp new file mode 100644 index 00000000000..ad69f05ae75 --- /dev/null +++ b/libcxx/test/std/re/re.traits/isctype.pass.cpp @@ -0,0 +1,279 @@ +//===----------------------------------------------------------------------===// +// +// 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> struct regex_traits; + +// bool isctype(charT c, char_class_type f) const; + +#include <regex> +#include <cassert> + +int main() +{ + { + 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/std/re/re.traits/length.pass.cpp b/libcxx/test/std/re/re.traits/length.pass.cpp new file mode 100644 index 00000000000..473c233c531 --- /dev/null +++ b/libcxx/test/std/re/re.traits/length.pass.cpp @@ -0,0 +1,31 @@ +// -*- 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> + +// template <class charT> struct regex_traits; + +// static std::size_t length(const char_type* p); + +#include <regex> +#include <cassert> + +int main() +{ + assert(std::regex_traits<char>::length("") == 0); + assert(std::regex_traits<char>::length("1") == 1); + assert(std::regex_traits<char>::length("12") == 2); + assert(std::regex_traits<char>::length("123") == 3); + + assert(std::regex_traits<wchar_t>::length(L"") == 0); + assert(std::regex_traits<wchar_t>::length(L"1") == 1); + assert(std::regex_traits<wchar_t>::length(L"12") == 2); + assert(std::regex_traits<wchar_t>::length(L"123") == 3); +} diff --git a/libcxx/test/std/re/re.traits/lookup_classname.pass.cpp b/libcxx/test/std/re/re.traits/lookup_classname.pass.cpp new file mode 100644 index 00000000000..0b1b18eb507 --- /dev/null +++ b/libcxx/test/std/re/re.traits/lookup_classname.pass.cpp @@ -0,0 +1,211 @@ +//===----------------------------------------------------------------------===// +// +// 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> struct regex_traits; + +// template <class ForwardIterator> +// char_class_type +// lookup_classname(ForwardIterator first, ForwardIterator last, +// bool icase = false) const; + +#include <regex> +#include <cassert> +#include "test_iterators.h" + +template <class char_type> +void +test(const char_type* A, + typename std::regex_traits<char_type>::char_class_type 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() +{ + 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", std::ctype_base::mask()); + test("", std::ctype_base::mask()); + test("digits", std::ctype_base::mask()); + + 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", std::ctype_base::mask()); + test(L"", std::ctype_base::mask()); + test(L"digits", std::ctype_base::mask()); +} diff --git a/libcxx/test/std/re/re.traits/lookup_collatename.pass.cpp b/libcxx/test/std/re/re.traits/lookup_collatename.pass.cpp new file mode 100644 index 00000000000..d495f8aaf07 --- /dev/null +++ b/libcxx/test/std/re/re.traits/lookup_collatename.pass.cpp @@ -0,0 +1,190 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// REQUIRES: locale.cs_CZ.ISO8859-2 + +// <regex> + +// template <class charT> struct regex_traits; + +// template <class ForwardIterator> +// string_type +// lookup_collatename(ForwardIterator first, ForwardIterator last) const; + +// TODO: investigation needed +// XFAIL: linux-gnu + +#include <regex> +#include <iterator> +#include <cassert> +#include "test_iterators.h" + +template <class char_type> +void +test(const char_type* A, const std::basic_string<char_type>& expected) +{ + std::regex_traits<char_type> t; + typedef forward_iterator<const char_type*> F; + assert(t.lookup_collatename(F(A), F(A + t.length(A))) == expected); +} + +int main() +{ + test("NUL", std::string("\x00", 1)); + test("alert", std::string("\x07")); + test("backspace", std::string("\x08")); + test("tab", std::string("\x09")); + test("carriage-return", std::string("\x0D")); + test("newline", std::string("\x0A")); + test("vertical-tab", std::string("\x0B")); + test("form-feed", std::string("\x0C")); + test("space", std::string(" ")); + test("exclamation-mark", std::string("!")); + test("quotation-mark", std::string("\"")); + test("number-sign", std::string("#")); + test("dollar-sign", std::string("$")); + test("percent-sign", std::string("%")); + test("ampersand", std::string("&")); + test("apostrophe", std::string("\'")); + test("left-parenthesis", std::string("(")); + test("right-parenthesis", std::string(")")); + test("asterisk", std::string("*")); + test("plus-sign", std::string("+")); + test("comma", std::string(",")); + test("hyphen-minus", std::string("-")); + test("hyphen", std::string("-")); + test("full-stop", std::string(".")); + test("period", std::string(".")); + test("slash", std::string("/")); + test("solidus", std::string("/")); + test("zero", std::string("0")); + test("one", std::string("1")); + test("two", std::string("2")); + test("three", std::string("3")); + test("four", std::string("4")); + test("five", std::string("5")); + test("six", std::string("6")); + test("seven", std::string("7")); + test("eight", std::string("8")); + test("nine", std::string("9")); + test("colon", std::string(":")); + test("semicolon", std::string(";")); + test("less-than-sign", std::string("<")); + test("equals-sign", std::string("=")); + test("greater-than-sign", std::string(">")); + test("question-mark", std::string("?")); + test("commercial-at", std::string("@")); + for (char c = 'A'; c <= 'Z'; ++c) + { + const char a[2] = {c}; + test(a, std::string(a)); + } + test("left-square-bracket", std::string("[")); + test("backslash", std::string("\\")); + test("reverse-solidus", std::string("\\")); + test("right-square-bracket", std::string("]")); + test("circumflex-accent", std::string("^")); + test("circumflex", std::string("^")); + test("low-line", std::string("_")); + test("underscore", std::string("_")); + test("grave-accent", std::string("`")); + for (char c = 'a'; c <= 'z'; ++c) + { + const char a[2] = {c}; + test(a, std::string(a)); + } + test("left-brace", std::string("{")); + test("left-curly-bracket", std::string("{")); + test("vertical-line", std::string("|")); + test("right-brace", std::string("}")); + test("right-curly-bracket", std::string("}")); + test("tilde", std::string("~")); + + test("tild", std::string("")); + test("ch", std::string("")); + std::locale::global(std::locale("cs_CZ.ISO8859-2")); + test("ch", std::string("ch")); + std::locale::global(std::locale("C")); + + test(L"NUL", std::wstring(L"\x00", 1)); + test(L"alert", std::wstring(L"\x07")); + test(L"backspace", std::wstring(L"\x08")); + test(L"tab", std::wstring(L"\x09")); + test(L"carriage-return", std::wstring(L"\x0D")); + test(L"newline", std::wstring(L"\x0A")); + test(L"vertical-tab", std::wstring(L"\x0B")); + test(L"form-feed", std::wstring(L"\x0C")); + test(L"space", std::wstring(L" ")); + test(L"exclamation-mark", std::wstring(L"!")); + test(L"quotation-mark", std::wstring(L"\"")); + test(L"number-sign", std::wstring(L"#")); + test(L"dollar-sign", std::wstring(L"$")); + test(L"percent-sign", std::wstring(L"%")); + test(L"ampersand", std::wstring(L"&")); + test(L"apostrophe", std::wstring(L"\'")); + test(L"left-parenthesis", std::wstring(L"(")); + test(L"right-parenthesis", std::wstring(L")")); + test(L"asterisk", std::wstring(L"*")); + test(L"plus-sign", std::wstring(L"+")); + test(L"comma", std::wstring(L",")); + test(L"hyphen-minus", std::wstring(L"-")); + test(L"hyphen", std::wstring(L"-")); + test(L"full-stop", std::wstring(L".")); + test(L"period", std::wstring(L".")); + test(L"slash", std::wstring(L"/")); + test(L"solidus", std::wstring(L"/")); + test(L"zero", std::wstring(L"0")); + test(L"one", std::wstring(L"1")); + test(L"two", std::wstring(L"2")); + test(L"three", std::wstring(L"3")); + test(L"four", std::wstring(L"4")); + test(L"five", std::wstring(L"5")); + test(L"six", std::wstring(L"6")); + test(L"seven", std::wstring(L"7")); + test(L"eight", std::wstring(L"8")); + test(L"nine", std::wstring(L"9")); + test(L"colon", std::wstring(L":")); + test(L"semicolon", std::wstring(L";")); + test(L"less-than-sign", std::wstring(L"<")); + test(L"equals-sign", std::wstring(L"=")); + test(L"greater-than-sign", std::wstring(L">")); + test(L"question-mark", std::wstring(L"?")); + test(L"commercial-at", std::wstring(L"@")); + for (wchar_t c = L'A'; c <= L'Z'; ++c) + { + const wchar_t a[2] = {c}; + test(a, std::wstring(a)); + } + test(L"left-square-bracket", std::wstring(L"[")); + test(L"backslash", std::wstring(L"\\")); + test(L"reverse-solidus", std::wstring(L"\\")); + test(L"right-square-bracket", std::wstring(L"]")); + test(L"circumflex-accent", std::wstring(L"^")); + test(L"circumflex", std::wstring(L"^")); + test(L"low-line", std::wstring(L"_")); + test(L"underscore", std::wstring(L"_")); + test(L"grave-accent", std::wstring(L"`")); + for (wchar_t c = L'a'; c <= L'z'; ++c) + { + const wchar_t a[2] = {c}; + test(a, std::wstring(a)); + } + test(L"left-brace", std::wstring(L"{")); + test(L"left-curly-bracket", std::wstring(L"{")); + test(L"vertical-line", std::wstring(L"|")); + test(L"right-brace", std::wstring(L"}")); + test(L"right-curly-bracket", std::wstring(L"}")); + test(L"tilde", std::wstring(L"~")); + + test(L"tild", std::wstring(L"")); + test(L"ch", std::wstring(L"")); + std::locale::global(std::locale("cs_CZ.ISO8859-2")); + test(L"ch", std::wstring(L"ch")); + std::locale::global(std::locale("C")); +} diff --git a/libcxx/test/std/re/re.traits/transform.pass.cpp b/libcxx/test/std/re/re.traits/transform.pass.cpp new file mode 100644 index 00000000000..c3bce7939fe --- /dev/null +++ b/libcxx/test/std/re/re.traits/transform.pass.cpp @@ -0,0 +1,44 @@ +// -*- 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. +// +//===----------------------------------------------------------------------===// + +// REQUIRES: locale.cs_CZ.ISO8859-2 + +// <regex> + +// template <class charT> struct regex_traits; + +// template <class ForwardIterator> +// string_type transform(ForwardIterator first, ForwardIterator last) const; + +#include <regex> +#include <cassert> +#include "test_iterators.h" + +int main() +{ + { + std::regex_traits<char> t; + const char a[] = "a"; + const char B[] = "B"; + typedef forward_iterator<const char*> F; + assert(t.transform(F(a), F(a+1)) > t.transform(F(B), F(B+1))); + t.imbue(std::locale("cs_CZ.ISO8859-2")); + assert(t.transform(F(a), F(a+1)) < t.transform(F(B), F(B+1))); + } + { + std::regex_traits<wchar_t> t; + const wchar_t a[] = L"a"; + const wchar_t B[] = L"B"; + typedef forward_iterator<const wchar_t*> F; + assert(t.transform(F(a), F(a+1)) > t.transform(F(B), F(B+1))); + t.imbue(std::locale("cs_CZ.ISO8859-2")); + assert(t.transform(F(a), F(a+1)) < t.transform(F(B), F(B+1))); + } +} diff --git a/libcxx/test/std/re/re.traits/transform_primary.pass.cpp b/libcxx/test/std/re/re.traits/transform_primary.pass.cpp new file mode 100644 index 00000000000..28734d621ad --- /dev/null +++ b/libcxx/test/std/re/re.traits/transform_primary.pass.cpp @@ -0,0 +1,49 @@ +// -*- 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. +// +//===----------------------------------------------------------------------===// + +// REQUIRES: locale.cs_CZ.ISO8859-2 + +// <regex> + +// template <class charT> struct regex_traits; + +// template <class ForwardIterator> +// string_type +// transform_primary(ForwardIterator first, ForwardIterator last) const; + +#include <regex> +#include <cassert> +#include "test_iterators.h" + +int main() +{ + { + std::regex_traits<char> t; + const char A[] = "A"; + const char Aacute[] = "\xC1"; + typedef forward_iterator<const char*> F; + assert(t.transform_primary(F(A), F(A+1)) != + t.transform_primary(F(Aacute), F(Aacute+1))); + t.imbue(std::locale("cs_CZ.ISO8859-2")); + assert(t.transform_primary(F(A), F(A+1)) == + t.transform_primary(F(Aacute), F(Aacute+1))); + } + { + std::regex_traits<wchar_t> t; + const wchar_t A[] = L"A"; + const wchar_t Aacute[] = L"\xC1"; + typedef forward_iterator<const wchar_t*> F; + assert(t.transform_primary(F(A), F(A+1)) != + t.transform_primary(F(Aacute), F(Aacute+1))); + t.imbue(std::locale("cs_CZ.ISO8859-2")); + assert(t.transform_primary(F(A), F(A+1)) == + t.transform_primary(F(Aacute), F(Aacute+1))); + } +} diff --git a/libcxx/test/std/re/re.traits/translate.pass.cpp b/libcxx/test/std/re/re.traits/translate.pass.cpp new file mode 100644 index 00000000000..c3523387c56 --- /dev/null +++ b/libcxx/test/std/re/re.traits/translate.pass.cpp @@ -0,0 +1,34 @@ +// -*- 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> + +// template <class charT> struct regex_traits; + +// charT translate(charT c) const; + +#include <regex> +#include <cassert> + +int main() +{ + { + std::regex_traits<char> t; + assert(t.translate('a') == 'a'); + assert(t.translate('B') == 'B'); + assert(t.translate('c') == 'c'); + } + { + std::regex_traits<wchar_t> t; + assert(t.translate(L'a') == L'a'); + assert(t.translate(L'B') == L'B'); + assert(t.translate(L'c') == L'c'); + } +} diff --git a/libcxx/test/std/re/re.traits/translate_nocase.pass.cpp b/libcxx/test/std/re/re.traits/translate_nocase.pass.cpp new file mode 100644 index 00000000000..0692e000d3f --- /dev/null +++ b/libcxx/test/std/re/re.traits/translate_nocase.pass.cpp @@ -0,0 +1,72 @@ +// -*- 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> + +// template <class charT> struct regex_traits; + +// charT translate_nocase(charT c) const; + +// REQUIRES: locale.en_US.UTF-8 + +// XFAIL: with_system_lib=x86_64-apple-darwin11 +// XFAIL: with_system_lib=x86_64-apple-darwin12 + +// TODO: investigation needed +// XFAIL: linux-gnu + +#include <regex> +#include <cassert> + +#include "platform_support.h" + +int main() +{ + { + std::regex_traits<char> t; + assert(t.translate_nocase(' ') == ' '); + assert(t.translate_nocase('A') == 'a'); + assert(t.translate_nocase('\x07') == '\x07'); + assert(t.translate_nocase('.') == '.'); + assert(t.translate_nocase('a') == 'a'); + assert(t.translate_nocase('1') == '1'); + assert(t.translate_nocase('\xDA') == '\xDA'); + assert(t.translate_nocase('\xFA') == '\xFA'); + t.imbue(std::locale(LOCALE_en_US_UTF_8)); + assert(t.translate_nocase(' ') == ' '); + assert(t.translate_nocase('A') == 'a'); + assert(t.translate_nocase('\x07') == '\x07'); + assert(t.translate_nocase('.') == '.'); + assert(t.translate_nocase('a') == 'a'); + assert(t.translate_nocase('1') == '1'); + assert(t.translate_nocase('\xDA') == '\xFA'); + assert(t.translate_nocase('\xFA') == '\xFA'); + } + { + std::regex_traits<wchar_t> t; + assert(t.translate_nocase(L' ') == L' '); + assert(t.translate_nocase(L'A') == L'a'); + assert(t.translate_nocase(L'\x07') == L'\x07'); + assert(t.translate_nocase(L'.') == L'.'); + assert(t.translate_nocase(L'a') == L'a'); + assert(t.translate_nocase(L'1') == L'1'); + assert(t.translate_nocase(L'\xDA') == L'\xDA'); + assert(t.translate_nocase(L'\xFA') == L'\xFA'); + t.imbue(std::locale(LOCALE_en_US_UTF_8)); + assert(t.translate_nocase(L' ') == L' '); + assert(t.translate_nocase(L'A') == L'a'); + assert(t.translate_nocase(L'\x07') == L'\x07'); + assert(t.translate_nocase(L'.') == L'.'); + assert(t.translate_nocase(L'a') == L'a'); + assert(t.translate_nocase(L'1') == L'1'); + assert(t.translate_nocase(L'\xDA') == L'\xFA'); + assert(t.translate_nocase(L'\xFA') == L'\xFA'); + } +} diff --git a/libcxx/test/std/re/re.traits/types.pass.cpp b/libcxx/test/std/re/re.traits/types.pass.cpp new file mode 100644 index 00000000000..50586a1f29f --- /dev/null +++ b/libcxx/test/std/re/re.traits/types.pass.cpp @@ -0,0 +1,32 @@ +// -*- 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> + +// template <class charT> +// struct regex_traits +// { +// public: +// typedef charT char_type; +// typedef basic_string<char_type> string_type; +// typedef locale locale_type; + +#include <regex> +#include <type_traits> + +int main() +{ + static_assert((std::is_same<std::regex_traits<char>::char_type, char>::value), ""); + static_assert((std::is_same<std::regex_traits<char>::string_type, std::string>::value), ""); + static_assert((std::is_same<std::regex_traits<char>::locale_type, std::locale>::value), ""); + static_assert((std::is_same<std::regex_traits<wchar_t>::char_type, wchar_t>::value), ""); + static_assert((std::is_same<std::regex_traits<wchar_t>::string_type, std::wstring>::value), ""); + static_assert((std::is_same<std::regex_traits<wchar_t>::locale_type, std::locale>::value), ""); +} diff --git a/libcxx/test/std/re/re.traits/value.pass.cpp b/libcxx/test/std/re/re.traits/value.pass.cpp new file mode 100644 index 00000000000..349a29cc6bc --- /dev/null +++ b/libcxx/test/std/re/re.traits/value.pass.cpp @@ -0,0 +1,125 @@ +//===----------------------------------------------------------------------===// +// +// 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> struct regex_traits; + +// int value(charT ch, int radix) const; + +#include <regex> +#include <cassert> + +int main() +{ + { + 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); + } + } +} |