diff options
author | Eric Fiselier <eric@efcs.ca> | 2014-12-20 01:40:03 +0000 |
---|---|---|
committer | Eric Fiselier <eric@efcs.ca> | 2014-12-20 01:40:03 +0000 |
commit | 5a83710e371fe68a06e6e3876c6a2c8b820a8976 (patch) | |
tree | afde4c82ad6704681781c5cd49baa3fbd05c85db /libcxx/test/std/strings/char.traits/char.traits.specializations | |
parent | f11e8eab527fba316c64112f6e05de1a79693a3e (diff) | |
download | bcm5719-llvm-5a83710e371fe68a06e6e3876c6a2c8b820a8976.tar.gz bcm5719-llvm-5a83710e371fe68a06e6e3876c6a2c8b820a8976.zip |
Move test into test/std subdirectory.
llvm-svn: 224658
Diffstat (limited to 'libcxx/test/std/strings/char.traits/char.traits.specializations')
61 files changed, 1722 insertions, 0 deletions
diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/assign2.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/assign2.pass.cpp new file mode 100644 index 00000000000..2c3deaefd06 --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/assign2.pass.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<> struct char_traits<char> + +// static void assign(char_type& c1, const char_type& c2); + +#include <string> +#include <cassert> + +int main() +{ + char c = '\0'; + std::char_traits<char>::assign(c, 'a'); + assert(c == 'a'); +} diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/assign3.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/assign3.pass.cpp new file mode 100644 index 00000000000..2b192994f36 --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/assign3.pass.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<> struct char_traits<char> + +// static char_type* assign(char_type* s, size_t n, char_type a); + +#include <string> +#include <cassert> + +int main() +{ + char s1[] = {1, 2, 3}; + char s2[3] = {0}; + assert(std::char_traits<char>::assign(s2, 3, char(5)) == s2); + assert(s2[0] == char(5)); + assert(s2[1] == char(5)); + assert(s2[2] == char(5)); +} diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/compare.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/compare.pass.cpp new file mode 100644 index 00000000000..a7190e73db3 --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/compare.pass.cpp @@ -0,0 +1,40 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<> struct char_traits<char> + +// static int compare(const char_type* s1, const char_type* s2, size_t n); + +#include <string> +#include <cassert> + +int main() +{ + assert(std::char_traits<char>::compare("", "", 0) == 0); + + assert(std::char_traits<char>::compare("1", "1", 1) == 0); + assert(std::char_traits<char>::compare("1", "2", 1) < 0); + assert(std::char_traits<char>::compare("2", "1", 1) > 0); + + assert(std::char_traits<char>::compare("12", "12", 2) == 0); + assert(std::char_traits<char>::compare("12", "13", 2) < 0); + assert(std::char_traits<char>::compare("12", "22", 2) < 0); + assert(std::char_traits<char>::compare("13", "12", 2) > 0); + assert(std::char_traits<char>::compare("22", "12", 2) > 0); + + assert(std::char_traits<char>::compare("123", "123", 3) == 0); + assert(std::char_traits<char>::compare("123", "223", 3) < 0); + assert(std::char_traits<char>::compare("123", "133", 3) < 0); + assert(std::char_traits<char>::compare("123", "124", 3) < 0); + assert(std::char_traits<char>::compare("223", "123", 3) > 0); + assert(std::char_traits<char>::compare("133", "123", 3) > 0); + assert(std::char_traits<char>::compare("124", "123", 3) > 0); +} diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/copy.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/copy.pass.cpp new file mode 100644 index 00000000000..e57a677b9a3 --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/copy.pass.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<> struct char_traits<char> + +// static char_type* copy(char_type* s1, const char_type* s2, size_t n); + +#include <string> +#include <cassert> + +int main() +{ + char s1[] = {1, 2, 3}; + char s2[3] = {0}; + assert(std::char_traits<char>::copy(s2, s1, 3) == s2); + assert(s2[0] == char(1)); + assert(s2[1] == char(2)); + assert(s2[2] == char(3)); +} diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eof.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eof.pass.cpp new file mode 100644 index 00000000000..39fba6b1c06 --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eof.pass.cpp @@ -0,0 +1,22 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<> struct char_traits<char> + +// static constexpr int_type eof(); + +#include <string> +#include <cassert> + +int main() +{ + assert(std::char_traits<char>::eof() == EOF); +} diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eq.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eq.pass.cpp new file mode 100644 index 00000000000..f7f84e85924 --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eq.pass.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<> struct char_traits<char> + +// static constexpr bool eq(char_type c1, char_type c2); + +#include <string> +#include <cassert> + +int main() +{ + char c = '\0'; + assert(std::char_traits<char>::eq('a', 'a')); + assert(!std::char_traits<char>::eq('a', 'A')); +} diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eq_int_type.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eq_int_type.pass.cpp new file mode 100644 index 00000000000..bdaf431db4d --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eq_int_type.pass.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<> struct char_traits<char> + +// static constexpr bool eq_int_type(int_type c1, int_type c2); + +#include <string> +#include <cassert> + +int main() +{ + assert( std::char_traits<char>::eq_int_type('a', 'a')); + assert(!std::char_traits<char>::eq_int_type('a', 'A')); + assert(!std::char_traits<char>::eq_int_type(std::char_traits<char>::eof(), 'A')); + assert( std::char_traits<char>::eq_int_type(std::char_traits<char>::eof(), + std::char_traits<char>::eof())); +} diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/find.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/find.pass.cpp new file mode 100644 index 00000000000..816b358968b --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/find.pass.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<> struct char_traits<char> + +// static const char_type* find(const char_type* s, size_t n, const char_type& a); + +#include <string> +#include <cassert> + +int main() +{ + char s1[] = {1, 2, 3}; + assert(std::char_traits<char>::find(s1, 3, char(1)) == s1); + assert(std::char_traits<char>::find(s1, 3, char(2)) == s1+1); + assert(std::char_traits<char>::find(s1, 3, char(3)) == s1+2); + assert(std::char_traits<char>::find(s1, 3, char(4)) == 0); + assert(std::char_traits<char>::find(s1, 3, char(0)) == 0); +} diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/length.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/length.pass.cpp new file mode 100644 index 00000000000..56844ef4664 --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/length.pass.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<> struct char_traits<char> + +// static size_t length(const char_type* s); + +#include <string> +#include <cassert> + +int main() +{ + assert(std::char_traits<char>::length("") == 0); + assert(std::char_traits<char>::length("a") == 1); + assert(std::char_traits<char>::length("aa") == 2); + assert(std::char_traits<char>::length("aaa") == 3); + assert(std::char_traits<char>::length("aaaa") == 4); +} diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/lt.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/lt.pass.cpp new file mode 100644 index 00000000000..3ff9c0f1ff9 --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/lt.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<> struct char_traits<char> + +// static constexpr bool lt(char_type c1, char_type c2); + +#include <string> +#include <cassert> + +int main() +{ + char c = '\0'; + assert(!std::char_traits<char>::lt('a', 'a')); + assert( std::char_traits<char>::lt('A', 'a')); + assert(!std::char_traits<char>::lt('A' + 127, 'a')); + assert(!std::char_traits<char>::lt('A' - 127, 'a')); + assert( std::char_traits<char>::lt('A', 'a' + 127)); + assert( std::char_traits<char>::lt('A', 'a' - 127)); +} diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/move.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/move.pass.cpp new file mode 100644 index 00000000000..691b28dd0db --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/move.pass.cpp @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<> struct char_traits<char> + +// static char_type* move(char_type* s1, const char_type* s2, size_t n); + +#include <string> +#include <cassert> + +int main() +{ + char s1[] = {1, 2, 3}; + assert(std::char_traits<char>::move(s1, s1+1, 2) == s1); + assert(s1[0] == char(2)); + assert(s1[1] == char(3)); + assert(s1[2] == char(3)); + s1[2] = char(0); + assert(std::char_traits<char>::move(s1+1, s1, 2) == s1+1); + assert(s1[0] == char(2)); + assert(s1[1] == char(2)); + assert(s1[2] == char(3)); +} diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/not_eof.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/not_eof.pass.cpp new file mode 100644 index 00000000000..69800969a7f --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/not_eof.pass.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<> struct char_traits<char> + +// static constexpr int_type not_eof(int_type c); + +#include <string> +#include <cassert> + +int main() +{ + assert(std::char_traits<char>::not_eof('a') == 'a'); + assert(std::char_traits<char>::not_eof('A') == 'A'); + assert(std::char_traits<char>::not_eof(0) == 0); + assert(std::char_traits<char>::not_eof(std::char_traits<char>::eof()) != + std::char_traits<char>::eof()); +} diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/to_char_type.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/to_char_type.pass.cpp new file mode 100644 index 00000000000..498abfa25fc --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/to_char_type.pass.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<> struct char_traits<char> + +// static constexpr char_type to_char_type(int_type c); + +#include <string> +#include <cassert> + +int main() +{ + assert(std::char_traits<char>::to_char_type('a') == 'a'); + assert(std::char_traits<char>::to_char_type('A') == 'A'); + assert(std::char_traits<char>::to_char_type(0) == 0); +} diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/to_int_type.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/to_int_type.pass.cpp new file mode 100644 index 00000000000..aa9594cfdc4 --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/to_int_type.pass.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<> struct char_traits<char> + +// static constexpr int_type to_int_type(char_type c); + +#include <string> +#include <cassert> + +int main() +{ + assert(std::char_traits<char>::to_int_type('a') == 'a'); + assert(std::char_traits<char>::to_int_type('A') == 'A'); + assert(std::char_traits<char>::to_int_type(0) == 0); +} diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/types.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/types.pass.cpp new file mode 100644 index 00000000000..ff4a93af65f --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/types.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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<> struct char_traits<char> + +// typedef char char_type; +// typedef int int_type; +// typedef streamoff off_type; +// typedef streampos pos_type; +// typedef mbstate_t state_type; + +#include <string> +#include <type_traits> + +int main() +{ + static_assert((std::is_same<std::char_traits<char>::char_type, char>::value), ""); + static_assert((std::is_same<std::char_traits<char>::int_type, int>::value), ""); + static_assert((std::is_same<std::char_traits<char>::off_type, std::streamoff>::value), ""); + static_assert((std::is_same<std::char_traits<char>::pos_type, std::streampos>::value), ""); + static_assert((std::is_same<std::char_traits<char>::state_type, std::mbstate_t>::value), ""); +} diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/assign2.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/assign2.pass.cpp new file mode 100644 index 00000000000..af87052ff21 --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/assign2.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<> struct char_traits<char16_t> + +// static void assign(char_type& c1, const char_type& c2); + +#include <string> +#include <cassert> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +#if __cplusplus >= 201103L + char16_t c = u'\0'; + std::char_traits<char16_t>::assign(c, u'a'); + assert(c == u'a'); +#endif +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/assign3.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/assign3.pass.cpp new file mode 100644 index 00000000000..4d53439ae89 --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/assign3.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<> struct char_traits<char16_t> + +// static char_type* assign(char_type* s, size_t n, char_type a); + +#include <string> +#include <cassert> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + char16_t s1[] = {1, 2, 3}; + char16_t s2[3] = {0}; + assert(std::char_traits<char16_t>::assign(s2, 3, char16_t(5)) == s2); + assert(s2[0] == char16_t(5)); + assert(s2[1] == char16_t(5)); + assert(s2[2] == char16_t(5)); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/compare.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/compare.pass.cpp new file mode 100644 index 00000000000..9f8461e0b2b --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/compare.pass.cpp @@ -0,0 +1,44 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<> struct char_traits<char16_t> + +// static int compare(const char_type* s1, const char_type* s2, size_t n); + +#include <string> +#include <cassert> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +#if __cplusplus >= 201103L + assert(std::char_traits<char16_t>::compare(u"", u"", 0) == 0); + + assert(std::char_traits<char16_t>::compare(u"1", u"1", 1) == 0); + assert(std::char_traits<char16_t>::compare(u"1", u"2", 1) < 0); + assert(std::char_traits<char16_t>::compare(u"2", u"1", 1) > 0); + + assert(std::char_traits<char16_t>::compare(u"12", u"12", 2) == 0); + assert(std::char_traits<char16_t>::compare(u"12", u"13", 2) < 0); + assert(std::char_traits<char16_t>::compare(u"12", u"22", 2) < 0); + assert(std::char_traits<char16_t>::compare(u"13", u"12", 2) > 0); + assert(std::char_traits<char16_t>::compare(u"22", u"12", 2) > 0); + + assert(std::char_traits<char16_t>::compare(u"123", u"123", 3) == 0); + assert(std::char_traits<char16_t>::compare(u"123", u"223", 3) < 0); + assert(std::char_traits<char16_t>::compare(u"123", u"133", 3) < 0); + assert(std::char_traits<char16_t>::compare(u"123", u"124", 3) < 0); + assert(std::char_traits<char16_t>::compare(u"223", u"123", 3) > 0); + assert(std::char_traits<char16_t>::compare(u"133", u"123", 3) > 0); + assert(std::char_traits<char16_t>::compare(u"124", u"123", 3) > 0); +#endif +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/copy.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/copy.pass.cpp new file mode 100644 index 00000000000..1ef44635158 --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/copy.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<> struct char_traits<char16_t> + +// static char_type* copy(char_type* s1, const char_type* s2, size_t n); + +#include <string> +#include <cassert> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + char16_t s1[] = {1, 2, 3}; + char16_t s2[3] = {0}; + assert(std::char_traits<char16_t>::copy(s2, s1, 3) == s2); + assert(s2[0] == char16_t(1)); + assert(s2[1] == char16_t(2)); + assert(s2[2] == char16_t(3)); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eof.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eof.pass.cpp new file mode 100644 index 00000000000..4e5a1834aeb --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eof.pass.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<> struct char_traits<char16_t> + +// static constexpr int_type eof(); + +#include <string> +#include <cassert> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + std::char_traits<char16_t>::int_type i = std::char_traits<char16_t>::eof(); +#endif +} diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eq.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eq.pass.cpp new file mode 100644 index 00000000000..8216934658c --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eq.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<> struct char_traits<char16_t> + +// static constexpr bool eq(char_type c1, char_type c2); + +#include <string> +#include <cassert> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +#if __cplusplus >= 201103L + char16_t c = u'\0'; + assert(std::char_traits<char16_t>::eq(u'a', u'a')); + assert(!std::char_traits<char16_t>::eq(u'a', u'A')); +#endif +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eq_int_type.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eq_int_type.pass.cpp new file mode 100644 index 00000000000..a20aa7d4718 --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eq_int_type.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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<> struct char_traits<char16_t> + +// static constexpr bool eq_int_type(int_type c1, int_type c2); + +#include <string> +#include <cassert> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +#if __cplusplus >= 201103L + assert( std::char_traits<char16_t>::eq_int_type(u'a', u'a')); + assert(!std::char_traits<char16_t>::eq_int_type(u'a', u'A')); + assert(!std::char_traits<char16_t>::eq_int_type(std::char_traits<char16_t>::eof(), u'A')); +#endif + assert( std::char_traits<char16_t>::eq_int_type(std::char_traits<char16_t>::eof(), + std::char_traits<char16_t>::eof())); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/find.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/find.pass.cpp new file mode 100644 index 00000000000..0952d5a016f --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/find.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<> struct char_traits<char16_t> + +// static const char_type* find(const char_type* s, size_t n, const char_type& a); + +#include <string> +#include <cassert> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + char16_t s1[] = {1, 2, 3}; + assert(std::char_traits<char16_t>::find(s1, 3, char16_t(1)) == s1); + assert(std::char_traits<char16_t>::find(s1, 3, char16_t(2)) == s1+1); + assert(std::char_traits<char16_t>::find(s1, 3, char16_t(3)) == s1+2); + assert(std::char_traits<char16_t>::find(s1, 3, char16_t(4)) == 0); + assert(std::char_traits<char16_t>::find(s1, 3, char16_t(0)) == 0); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/length.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/length.pass.cpp new file mode 100644 index 00000000000..9f6acca83e3 --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/length.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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<> struct char_traits<char16_t> + +// static size_t length(const char_type* s); + +#include <string> +#include <cassert> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +#if __cplusplus >= 201103L + assert(std::char_traits<char16_t>::length(u"") == 0); + assert(std::char_traits<char16_t>::length(u"a") == 1); + assert(std::char_traits<char16_t>::length(u"aa") == 2); + assert(std::char_traits<char16_t>::length(u"aaa") == 3); + assert(std::char_traits<char16_t>::length(u"aaaa") == 4); +#endif +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/lt.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/lt.pass.cpp new file mode 100644 index 00000000000..135ecc05e19 --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/lt.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<> struct char_traits<char16_t> + +// static constexpr bool lt(char_type c1, char_type c2); + +#include <string> +#include <cassert> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +#if __cplusplus >= 201103L + char16_t c = u'\0'; + assert(!std::char_traits<char16_t>::lt(u'a', u'a')); + assert( std::char_traits<char16_t>::lt(u'A', u'a')); +#endif +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/move.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/move.pass.cpp new file mode 100644 index 00000000000..1839b91b67c --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/move.pass.cpp @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<> struct char_traits<char16_t> + +// static char_type* move(char_type* s1, const char_type* s2, size_t n); + +#include <string> +#include <cassert> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + char16_t s1[] = {1, 2, 3}; + assert(std::char_traits<char16_t>::move(s1, s1+1, 2) == s1); + assert(s1[0] == char16_t(2)); + assert(s1[1] == char16_t(3)); + assert(s1[2] == char16_t(3)); + s1[2] = char16_t(0); + assert(std::char_traits<char16_t>::move(s1+1, s1, 2) == s1+1); + assert(s1[0] == char16_t(2)); + assert(s1[1] == char16_t(2)); + assert(s1[2] == char16_t(3)); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/not_eof.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/not_eof.pass.cpp new file mode 100644 index 00000000000..3c213e6e0a3 --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/not_eof.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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<> struct char_traits<char16_t> + +// static constexpr int_type not_eof(int_type c); + +#include <string> +#include <cassert> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +#if __cplusplus >= 201103L + assert(std::char_traits<char16_t>::not_eof(u'a') == u'a'); + assert(std::char_traits<char16_t>::not_eof(u'A') == u'A'); +#endif + assert(std::char_traits<char16_t>::not_eof(0) == 0); + assert(std::char_traits<char16_t>::not_eof(std::char_traits<char16_t>::eof()) != + std::char_traits<char16_t>::eof()); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/to_char_type.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/to_char_type.pass.cpp new file mode 100644 index 00000000000..ab47403dbe0 --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/to_char_type.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<> struct char_traits<char16_t> + +// static constexpr char_type to_char_type(int_type c); + +#include <string> +#include <cassert> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +#if __cplusplus >= 201103L + assert(std::char_traits<char16_t>::to_char_type(u'a') == u'a'); + assert(std::char_traits<char16_t>::to_char_type(u'A') == u'A'); +#endif + assert(std::char_traits<char16_t>::to_char_type(0) == 0); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/to_int_type.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/to_int_type.pass.cpp new file mode 100644 index 00000000000..11eb8f52546 --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/to_int_type.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<> struct char_traits<char16_t> + +// static constexpr int_type to_int_type(char_type c); + +#include <string> +#include <cassert> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +#if __cplusplus >= 201103L + assert(std::char_traits<char16_t>::to_int_type(u'a') == u'a'); + assert(std::char_traits<char16_t>::to_int_type(u'A') == u'A'); +#endif + assert(std::char_traits<char16_t>::to_int_type(0) == 0); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/types.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/types.pass.cpp new file mode 100644 index 00000000000..a40296b25b1 --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/types.pass.cpp @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<> struct char_traits<char16_t> + +// typedef char16_t char_type; +// typedef uint_least16_t int_type; +// typedef streamoff off_type; +// typedef u16streampos pos_type; +// typedef mbstate_t state_type; + +#include <string> +#include <type_traits> +#include <cstdint> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + static_assert((std::is_same<std::char_traits<char16_t>::char_type, char16_t>::value), ""); + static_assert((std::is_same<std::char_traits<char16_t>::int_type, std::uint_least16_t>::value), ""); + static_assert((std::is_same<std::char_traits<char16_t>::off_type, std::streamoff>::value), ""); + static_assert((std::is_same<std::char_traits<char16_t>::pos_type, std::u16streampos>::value), ""); + static_assert((std::is_same<std::char_traits<char16_t>::state_type, std::mbstate_t>::value), ""); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/assign2.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/assign2.pass.cpp new file mode 100644 index 00000000000..35dcd9602d3 --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/assign2.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<> struct char_traits<char32_t> + +// static void assign(char_type& c1, const char_type& c2); + +#include <string> +#include <cassert> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +#if __cplusplus >= 201103L + char32_t c = U'\0'; + std::char_traits<char32_t>::assign(c, U'a'); + assert(c == U'a'); +#endif +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/assign3.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/assign3.pass.cpp new file mode 100644 index 00000000000..cce0420be85 --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/assign3.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<> struct char_traits<char32_t> + +// static char_type* assign(char_type* s, size_t n, char_type a); + +#include <string> +#include <cassert> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + char32_t s1[] = {1, 2, 3}; + char32_t s2[3] = {0}; + assert(std::char_traits<char32_t>::assign(s2, 3, char32_t(5)) == s2); + assert(s2[0] == char32_t(5)); + assert(s2[1] == char32_t(5)); + assert(s2[2] == char32_t(5)); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/compare.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/compare.pass.cpp new file mode 100644 index 00000000000..ee3019cf274 --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/compare.pass.cpp @@ -0,0 +1,44 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<> struct char_traits<char32_t> + +// static int compare(const char_type* s1, const char_type* s2, size_t n); + +#include <string> +#include <cassert> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +#if __cplusplus >= 201103L + assert(std::char_traits<char32_t>::compare(U"", U"", 0) == 0); + + assert(std::char_traits<char32_t>::compare(U"1", U"1", 1) == 0); + assert(std::char_traits<char32_t>::compare(U"1", U"2", 1) < 0); + assert(std::char_traits<char32_t>::compare(U"2", U"1", 1) > 0); + + assert(std::char_traits<char32_t>::compare(U"12", U"12", 2) == 0); + assert(std::char_traits<char32_t>::compare(U"12", U"13", 2) < 0); + assert(std::char_traits<char32_t>::compare(U"12", U"22", 2) < 0); + assert(std::char_traits<char32_t>::compare(U"13", U"12", 2) > 0); + assert(std::char_traits<char32_t>::compare(U"22", U"12", 2) > 0); + + assert(std::char_traits<char32_t>::compare(U"123", U"123", 3) == 0); + assert(std::char_traits<char32_t>::compare(U"123", U"223", 3) < 0); + assert(std::char_traits<char32_t>::compare(U"123", U"133", 3) < 0); + assert(std::char_traits<char32_t>::compare(U"123", U"124", 3) < 0); + assert(std::char_traits<char32_t>::compare(U"223", U"123", 3) > 0); + assert(std::char_traits<char32_t>::compare(U"133", U"123", 3) > 0); + assert(std::char_traits<char32_t>::compare(U"124", U"123", 3) > 0); +#endif +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/copy.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/copy.pass.cpp new file mode 100644 index 00000000000..5f23514abd3 --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/copy.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<> struct char_traits<char32_t> + +// static char_type* copy(char_type* s1, const char_type* s2, size_t n); + +#include <string> +#include <cassert> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + char32_t s1[] = {1, 2, 3}; + char32_t s2[3] = {0}; + assert(std::char_traits<char32_t>::copy(s2, s1, 3) == s2); + assert(s2[0] == char32_t(1)); + assert(s2[1] == char32_t(2)); + assert(s2[2] == char32_t(3)); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eof.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eof.pass.cpp new file mode 100644 index 00000000000..8f804aa22e7 --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eof.pass.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<> struct char_traits<char32_t> + +// static constexpr int_type eof(); + +#include <string> +#include <cassert> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + std::char_traits<char32_t>::int_type i = std::char_traits<char32_t>::eof(); +#endif +} diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eq.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eq.pass.cpp new file mode 100644 index 00000000000..ffeff0cf45a --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eq.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<> struct char_traits<char32_t> + +// static constexpr bool eq(char_type c1, char_type c2); + +#include <string> +#include <cassert> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +#if __cplusplus >= 201103L + char32_t c = U'\0'; + assert(std::char_traits<char32_t>::eq(U'a', U'a')); + assert(!std::char_traits<char32_t>::eq(U'a', U'A')); +#endif +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eq_int_type.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eq_int_type.pass.cpp new file mode 100644 index 00000000000..eb5c6966101 --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eq_int_type.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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<> struct char_traits<char32_t> + +// static constexpr bool eq_int_type(int_type c1, int_type c2); + +#include <string> +#include <cassert> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +#if __cplusplus >= 201103L + assert( std::char_traits<char32_t>::eq_int_type(U'a', U'a')); + assert(!std::char_traits<char32_t>::eq_int_type(U'a', U'A')); + assert(!std::char_traits<char32_t>::eq_int_type(std::char_traits<char32_t>::eof(), U'A')); +#endif + assert( std::char_traits<char32_t>::eq_int_type(std::char_traits<char32_t>::eof(), + std::char_traits<char32_t>::eof())); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/find.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/find.pass.cpp new file mode 100644 index 00000000000..148fc0ccfcc --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/find.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<> struct char_traits<char32_t> + +// static const char_type* find(const char_type* s, size_t n, const char_type& a); + +#include <string> +#include <cassert> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + char32_t s1[] = {1, 2, 3}; + assert(std::char_traits<char32_t>::find(s1, 3, char32_t(1)) == s1); + assert(std::char_traits<char32_t>::find(s1, 3, char32_t(2)) == s1+1); + assert(std::char_traits<char32_t>::find(s1, 3, char32_t(3)) == s1+2); + assert(std::char_traits<char32_t>::find(s1, 3, char32_t(4)) == 0); + assert(std::char_traits<char32_t>::find(s1, 3, char32_t(0)) == 0); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/length.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/length.pass.cpp new file mode 100644 index 00000000000..d80ce051d1f --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/length.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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<> struct char_traits<char32_t> + +// static size_t length(const char_type* s); + +#include <string> +#include <cassert> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +#if __cplusplus >= 201103L + assert(std::char_traits<char32_t>::length(U"") == 0); + assert(std::char_traits<char32_t>::length(U"a") == 1); + assert(std::char_traits<char32_t>::length(U"aa") == 2); + assert(std::char_traits<char32_t>::length(U"aaa") == 3); + assert(std::char_traits<char32_t>::length(U"aaaa") == 4); +#endif +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/lt.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/lt.pass.cpp new file mode 100644 index 00000000000..f667507f045 --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/lt.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<> struct char_traits<char32_t> + +// static constexpr bool lt(char_type c1, char_type c2); + +#include <string> +#include <cassert> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +#if __cplusplus >= 201103L + char32_t c = U'\0'; + assert(!std::char_traits<char32_t>::lt(U'a', U'a')); + assert( std::char_traits<char32_t>::lt(U'A', U'a')); +#endif +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/move.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/move.pass.cpp new file mode 100644 index 00000000000..6fbc6d94fe5 --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/move.pass.cpp @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<> struct char_traits<char32_t> + +// static char_type* move(char_type* s1, const char_type* s2, size_t n); + +#include <string> +#include <cassert> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + char32_t s1[] = {1, 2, 3}; + assert(std::char_traits<char32_t>::move(s1, s1+1, 2) == s1); + assert(s1[0] == char32_t(2)); + assert(s1[1] == char32_t(3)); + assert(s1[2] == char32_t(3)); + s1[2] = char32_t(0); + assert(std::char_traits<char32_t>::move(s1+1, s1, 2) == s1+1); + assert(s1[0] == char32_t(2)); + assert(s1[1] == char32_t(2)); + assert(s1[2] == char32_t(3)); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/not_eof.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/not_eof.pass.cpp new file mode 100644 index 00000000000..d794417bfd7 --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/not_eof.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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<> struct char_traits<char32_t> + +// static constexpr int_type not_eof(int_type c); + +#include <string> +#include <cassert> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +#if __cplusplus >= 201103L + assert(std::char_traits<char32_t>::not_eof(U'a') == U'a'); + assert(std::char_traits<char32_t>::not_eof(U'A') == U'A'); +#endif + assert(std::char_traits<char32_t>::not_eof(0) == 0); + assert(std::char_traits<char32_t>::not_eof(std::char_traits<char32_t>::eof()) != + std::char_traits<char32_t>::eof()); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/to_char_type.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/to_char_type.pass.cpp new file mode 100644 index 00000000000..1f67242b2ae --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/to_char_type.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<> struct char_traits<char32_t> + +// static constexpr char_type to_char_type(int_type c); + +#include <string> +#include <cassert> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +#if __cplusplus >= 201103L + assert(std::char_traits<char32_t>::to_char_type(U'a') == U'a'); + assert(std::char_traits<char32_t>::to_char_type(U'A') == U'A'); +#endif + assert(std::char_traits<char32_t>::to_char_type(0) == 0); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/to_int_type.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/to_int_type.pass.cpp new file mode 100644 index 00000000000..a378186bdd6 --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/to_int_type.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<> struct char_traits<char32_t> + +// static constexpr int_type to_int_type(char_type c); + +#include <string> +#include <cassert> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS +#if __cplusplus >= 201103L + assert(std::char_traits<char32_t>::to_int_type(U'a') == U'a'); + assert(std::char_traits<char32_t>::to_int_type(U'A') == U'A'); +#endif + assert(std::char_traits<char32_t>::to_int_type(0) == 0); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/types.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/types.pass.cpp new file mode 100644 index 00000000000..3b48af14f96 --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/types.pass.cpp @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<> struct char_traits<char32_t> + +// typedef char32_t char_type; +// typedef uint_least32_t int_type; +// typedef streamoff off_type; +// typedef u32streampos pos_type; +// typedef mbstate_t state_type; + +#include <string> +#include <type_traits> +#include <cstdint> + +int main() +{ +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + static_assert((std::is_same<std::char_traits<char32_t>::char_type, char32_t>::value), ""); + static_assert((std::is_same<std::char_traits<char32_t>::int_type, std::uint_least32_t>::value), ""); + static_assert((std::is_same<std::char_traits<char32_t>::off_type, std::streamoff>::value), ""); + static_assert((std::is_same<std::char_traits<char32_t>::pos_type, std::u32streampos>::value), ""); + static_assert((std::is_same<std::char_traits<char32_t>::state_type, std::mbstate_t>::value), ""); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/assign2.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/assign2.pass.cpp new file mode 100644 index 00000000000..7dcf08c2e76 --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/assign2.pass.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<> struct char_traits<wchar_t> + +// static void assign(char_type& c1, const char_type& c2); + +#include <string> +#include <cassert> + +int main() +{ + wchar_t c = L'\0'; + std::char_traits<wchar_t>::assign(c, L'a'); + assert(c == L'a'); +} diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/assign3.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/assign3.pass.cpp new file mode 100644 index 00000000000..4c5ff479d9f --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/assign3.pass.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<> struct char_traits<wchar_t> + +// static char_type* assign(char_type* s, size_t n, char_type a); + +#include <string> +#include <cassert> + +int main() +{ + wchar_t s1[] = {1, 2, 3}; + wchar_t s2[3] = {0}; + assert(std::char_traits<wchar_t>::assign(s2, 3, wchar_t(5)) == s2); + assert(s2[0] == wchar_t(5)); + assert(s2[1] == wchar_t(5)); + assert(s2[2] == wchar_t(5)); +} diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/compare.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/compare.pass.cpp new file mode 100644 index 00000000000..046398b3d69 --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/compare.pass.cpp @@ -0,0 +1,40 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<> struct char_traits<wchar_t> + +// static int compare(const char_type* s1, const char_type* s2, size_t n); + +#include <string> +#include <cassert> + +int main() +{ + assert(std::char_traits<wchar_t>::compare(L"", L"", 0) == 0); + + assert(std::char_traits<wchar_t>::compare(L"1", L"1", 1) == 0); + assert(std::char_traits<wchar_t>::compare(L"1", L"2", 1) < 0); + assert(std::char_traits<wchar_t>::compare(L"2", L"1", 1) > 0); + + assert(std::char_traits<wchar_t>::compare(L"12", L"12", 2) == 0); + assert(std::char_traits<wchar_t>::compare(L"12", L"13", 2) < 0); + assert(std::char_traits<wchar_t>::compare(L"12", L"22", 2) < 0); + assert(std::char_traits<wchar_t>::compare(L"13", L"12", 2) > 0); + assert(std::char_traits<wchar_t>::compare(L"22", L"12", 2) > 0); + + assert(std::char_traits<wchar_t>::compare(L"123", L"123", 3) == 0); + assert(std::char_traits<wchar_t>::compare(L"123", L"223", 3) < 0); + assert(std::char_traits<wchar_t>::compare(L"123", L"133", 3) < 0); + assert(std::char_traits<wchar_t>::compare(L"123", L"124", 3) < 0); + assert(std::char_traits<wchar_t>::compare(L"223", L"123", 3) > 0); + assert(std::char_traits<wchar_t>::compare(L"133", L"123", 3) > 0); + assert(std::char_traits<wchar_t>::compare(L"124", L"123", 3) > 0); +} diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/copy.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/copy.pass.cpp new file mode 100644 index 00000000000..71ed6fb8a30 --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/copy.pass.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<> struct char_traits<wchar_t> + +// static char_type* copy(char_type* s1, const char_type* s2, size_t n); + +#include <string> +#include <cassert> + +int main() +{ + wchar_t s1[] = {1, 2, 3}; + wchar_t s2[3] = {0}; + assert(std::char_traits<wchar_t>::copy(s2, s1, 3) == s2); + assert(s2[0] == wchar_t(1)); + assert(s2[1] == wchar_t(2)); + assert(s2[2] == wchar_t(3)); +} diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eof.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eof.pass.cpp new file mode 100644 index 00000000000..61499b5809f --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eof.pass.cpp @@ -0,0 +1,22 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<> struct char_traits<wchar_t> + +// static constexpr int_type eof(); + +#include <string> +#include <cassert> + +int main() +{ + assert(std::char_traits<wchar_t>::eof() == WEOF); +} diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eq.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eq.pass.cpp new file mode 100644 index 00000000000..98d0926e307 --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eq.pass.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<> struct char_traits<wchar_t> + +// static constexpr bool eq(char_type c1, char_type c2); + +#include <string> +#include <cassert> + +int main() +{ + wchar_t c = L'\0'; + assert(std::char_traits<wchar_t>::eq(L'a', L'a')); + assert(!std::char_traits<wchar_t>::eq(L'a', L'A')); +} diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eq_int_type.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eq_int_type.pass.cpp new file mode 100644 index 00000000000..6b523dbdda2 --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eq_int_type.pass.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<> struct char_traits<wchar_t> + +// static constexpr bool eq_int_type(int_type c1, int_type c2); + +#include <string> +#include <cassert> + +int main() +{ + assert( std::char_traits<wchar_t>::eq_int_type(L'a', L'a')); + assert(!std::char_traits<wchar_t>::eq_int_type(L'a', L'A')); + assert(!std::char_traits<wchar_t>::eq_int_type(std::char_traits<wchar_t>::eof(), L'A')); + assert( std::char_traits<wchar_t>::eq_int_type(std::char_traits<wchar_t>::eof(), + std::char_traits<wchar_t>::eof())); +} diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/find.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/find.pass.cpp new file mode 100644 index 00000000000..49757390e02 --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/find.pass.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<> struct char_traits<wchar_t> + +// static const char_type* find(const char_type* s, size_t n, const char_type& a); + +#include <string> +#include <cassert> + +int main() +{ + wchar_t s1[] = {1, 2, 3}; + assert(std::char_traits<wchar_t>::find(s1, 3, wchar_t(1)) == s1); + assert(std::char_traits<wchar_t>::find(s1, 3, wchar_t(2)) == s1+1); + assert(std::char_traits<wchar_t>::find(s1, 3, wchar_t(3)) == s1+2); + assert(std::char_traits<wchar_t>::find(s1, 3, wchar_t(4)) == 0); + assert(std::char_traits<wchar_t>::find(s1, 3, wchar_t(0)) == 0); +} diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/length.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/length.pass.cpp new file mode 100644 index 00000000000..691e968ed24 --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/length.pass.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<> struct char_traits<wchar_t> + +// static size_t length(const char_type* s); + +#include <string> +#include <cassert> + +int main() +{ + assert(std::char_traits<wchar_t>::length(L"") == 0); + assert(std::char_traits<wchar_t>::length(L"a") == 1); + assert(std::char_traits<wchar_t>::length(L"aa") == 2); + assert(std::char_traits<wchar_t>::length(L"aaa") == 3); + assert(std::char_traits<wchar_t>::length(L"aaaa") == 4); +} diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/lt.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/lt.pass.cpp new file mode 100644 index 00000000000..147a57914e0 --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/lt.pass.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<> struct char_traits<wchar_t> + +// static constexpr bool lt(char_type c1, char_type c2); + +#include <string> +#include <cassert> + +int main() +{ + wchar_t c = L'\0'; + assert(!std::char_traits<wchar_t>::lt(L'a', L'a')); + assert( std::char_traits<wchar_t>::lt(L'A', L'a')); +} diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/move.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/move.pass.cpp new file mode 100644 index 00000000000..f19fa93e0c6 --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/move.pass.cpp @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<> struct char_traits<wchar_t> + +// static char_type* move(char_type* s1, const char_type* s2, size_t n); + +#include <string> +#include <cassert> + +int main() +{ + wchar_t s1[] = {1, 2, 3}; + assert(std::char_traits<wchar_t>::move(s1, s1+1, 2) == s1); + assert(s1[0] == wchar_t(2)); + assert(s1[1] == wchar_t(3)); + assert(s1[2] == wchar_t(3)); + s1[2] = wchar_t(0); + assert(std::char_traits<wchar_t>::move(s1+1, s1, 2) == s1+1); + assert(s1[0] == wchar_t(2)); + assert(s1[1] == wchar_t(2)); + assert(s1[2] == wchar_t(3)); +} diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/not_eof.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/not_eof.pass.cpp new file mode 100644 index 00000000000..ee44f313b58 --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/not_eof.pass.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<> struct char_traits<wchar_t> + +// static constexpr int_type not_eof(int_type c); + +#include <string> +#include <cassert> + +int main() +{ + assert(std::char_traits<wchar_t>::not_eof(L'a') == L'a'); + assert(std::char_traits<wchar_t>::not_eof(L'A') == L'A'); + assert(std::char_traits<wchar_t>::not_eof(0) == 0); + assert(std::char_traits<wchar_t>::not_eof(std::char_traits<wchar_t>::eof()) != + std::char_traits<wchar_t>::eof()); +} diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/to_char_type.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/to_char_type.pass.cpp new file mode 100644 index 00000000000..9b4c04829a9 --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/to_char_type.pass.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<> struct char_traits<wchar_t> + +// static constexpr char_type to_char_type(int_type c); + +#include <string> +#include <cassert> + +int main() +{ + assert(std::char_traits<wchar_t>::to_char_type(L'a') == L'a'); + assert(std::char_traits<wchar_t>::to_char_type(L'A') == L'A'); + assert(std::char_traits<wchar_t>::to_char_type(0) == 0); +} diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/to_int_type.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/to_int_type.pass.cpp new file mode 100644 index 00000000000..488b03e0f01 --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/to_int_type.pass.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<> struct char_traits<wchar_t> + +// static constexpr int_type to_int_type(char_type c); + +#include <string> +#include <cassert> + +int main() +{ + assert(std::char_traits<wchar_t>::to_int_type(L'a') == L'a'); + assert(std::char_traits<wchar_t>::to_int_type(L'A') == L'A'); + assert(std::char_traits<wchar_t>::to_int_type(0) == 0); +} diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/types.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/types.pass.cpp new file mode 100644 index 00000000000..12598975c4f --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/types.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. +// +//===----------------------------------------------------------------------===// + +// <string> + +// template<> struct char_traits<wchar_t> + +// typedef wchar_t char_type; +// typedef int int_type; +// typedef streamoff off_type; +// typedef streampos pos_type; +// typedef mbstate_t state_type; + +#include <string> +#include <type_traits> + +int main() +{ + static_assert((std::is_same<std::char_traits<wchar_t>::char_type, wchar_t>::value), ""); + static_assert((std::is_same<std::char_traits<wchar_t>::int_type, std::wint_t>::value), ""); + static_assert((std::is_same<std::char_traits<wchar_t>::off_type, std::streamoff>::value), ""); + static_assert((std::is_same<std::char_traits<wchar_t>::pos_type, std::wstreampos>::value), ""); + static_assert((std::is_same<std::char_traits<wchar_t>::state_type, std::mbstate_t>::value), ""); +} diff --git a/libcxx/test/std/strings/char.traits/char.traits.specializations/nothing_to_do.pass.cpp b/libcxx/test/std/strings/char.traits/char.traits.specializations/nothing_to_do.pass.cpp new file mode 100644 index 00000000000..b58f5c55b64 --- /dev/null +++ b/libcxx/test/std/strings/char.traits/char.traits.specializations/nothing_to_do.pass.cpp @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} |