diff options
Diffstat (limited to 'libcxx/test/strings/char.traits')
64 files changed, 1722 insertions, 0 deletions
diff --git a/libcxx/test/strings/char.traits/char.traits.require/nothing_to_do.pass.cpp b/libcxx/test/strings/char.traits/char.traits.require/nothing_to_do.pass.cpp new file mode 100644 index 00000000000..fa4d462f18d --- /dev/null +++ b/libcxx/test/strings/char.traits/char.traits.require/nothing_to_do.pass.cpp @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} diff --git a/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/assign2.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/assign2.pass.cpp new file mode 100644 index 00000000000..92b1ea40883 --- /dev/null +++ b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/assign2.pass.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. 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/strings/char.traits/char.traits.specializations/char.traits.specializations.char/assign3.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/assign3.pass.cpp new file mode 100644 index 00000000000..5a44ea35d65 --- /dev/null +++ b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/assign3.pass.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. 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/strings/char.traits/char.traits.specializations/char.traits.specializations.char/compare.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/compare.pass.cpp new file mode 100644 index 00000000000..6f51db7b479 --- /dev/null +++ b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/compare.pass.cpp @@ -0,0 +1,40 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. 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/strings/char.traits/char.traits.specializations/char.traits.specializations.char/copy.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/copy.pass.cpp new file mode 100644 index 00000000000..45cfc5031b3 --- /dev/null +++ b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/copy.pass.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. 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/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eof.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eof.pass.cpp new file mode 100644 index 00000000000..041b4d001ed --- /dev/null +++ b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eof.pass.cpp @@ -0,0 +1,22 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. 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/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eq.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eq.pass.cpp new file mode 100644 index 00000000000..f2ddbfa1c99 --- /dev/null +++ b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eq.pass.cpp @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. 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/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eq_int_type.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eq_int_type.pass.cpp new file mode 100644 index 00000000000..446a83f108c --- /dev/null +++ b/libcxx/test/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 distributed under the University of Illinois Open Source +// License. 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/strings/char.traits/char.traits.specializations/char.traits.specializations.char/find.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/find.pass.cpp new file mode 100644 index 00000000000..2e0f2ff860a --- /dev/null +++ b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/find.pass.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. 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/strings/char.traits/char.traits.specializations/char.traits.specializations.char/length.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/length.pass.cpp new file mode 100644 index 00000000000..b111ba4a4eb --- /dev/null +++ b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/length.pass.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. 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/strings/char.traits/char.traits.specializations/char.traits.specializations.char/lt.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/lt.pass.cpp new file mode 100644 index 00000000000..6479c6671d1 --- /dev/null +++ b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/lt.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. 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/strings/char.traits/char.traits.specializations/char.traits.specializations.char/move.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/move.pass.cpp new file mode 100644 index 00000000000..3627550d14f --- /dev/null +++ b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/move.pass.cpp @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. 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/strings/char.traits/char.traits.specializations/char.traits.specializations.char/not_eof.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/not_eof.pass.cpp new file mode 100644 index 00000000000..44d26be60c8 --- /dev/null +++ b/libcxx/test/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 distributed under the University of Illinois Open Source +// License. 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/strings/char.traits/char.traits.specializations/char.traits.specializations.char/to_char_type.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/to_char_type.pass.cpp new file mode 100644 index 00000000000..8b5d1b14e5f --- /dev/null +++ b/libcxx/test/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 distributed under the University of Illinois Open Source +// License. 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/strings/char.traits/char.traits.specializations/char.traits.specializations.char/to_int_type.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/to_int_type.pass.cpp new file mode 100644 index 00000000000..2cb41debfb9 --- /dev/null +++ b/libcxx/test/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 distributed under the University of Illinois Open Source +// License. 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/strings/char.traits/char.traits.specializations/char.traits.specializations.char/types.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/types.pass.cpp new file mode 100644 index 00000000000..dd0afbfc69e --- /dev/null +++ b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char/types.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. 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/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/assign2.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/assign2.pass.cpp new file mode 100644 index 00000000000..6002d0b0831 --- /dev/null +++ b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/assign2.pass.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. 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 + char16_t c = u'\0'; + std::char_traits<char16_t>::assign(c, u'a'); + assert(c == u'a'); +#endif +} diff --git a/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/assign3.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/assign3.pass.cpp new file mode 100644 index 00000000000..c5a98a53353 --- /dev/null +++ b/libcxx/test/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 distributed under the University of Illinois Open Source +// License. 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 +} diff --git a/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/compare.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/compare.pass.cpp new file mode 100644 index 00000000000..55e82d5e1b0 --- /dev/null +++ b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/compare.pass.cpp @@ -0,0 +1,42 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. 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 + 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 +} diff --git a/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/copy.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/copy.pass.cpp new file mode 100644 index 00000000000..7edf6e6dd7a --- /dev/null +++ b/libcxx/test/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 distributed under the University of Illinois Open Source +// License. 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 +} diff --git a/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eof.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eof.pass.cpp new file mode 100644 index 00000000000..dad0ba93ebe --- /dev/null +++ b/libcxx/test/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 distributed under the University of Illinois Open Source +// License. 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/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eq.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eq.pass.cpp new file mode 100644 index 00000000000..1a8be4e52fe --- /dev/null +++ b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eq.pass.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. 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 + 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 +} diff --git a/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eq_int_type.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eq_int_type.pass.cpp new file mode 100644 index 00000000000..13befcecf18 --- /dev/null +++ b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eq_int_type.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. 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 + 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')); + assert( std::char_traits<char16_t>::eq_int_type(std::char_traits<char16_t>::eof(), + std::char_traits<char16_t>::eof())); +#endif +} diff --git a/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/find.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/find.pass.cpp new file mode 100644 index 00000000000..765da3e5538 --- /dev/null +++ b/libcxx/test/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 distributed under the University of Illinois Open Source +// License. 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 +} diff --git a/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/length.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/length.pass.cpp new file mode 100644 index 00000000000..48109807f84 --- /dev/null +++ b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/length.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. 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 + 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 +} diff --git a/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/lt.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/lt.pass.cpp new file mode 100644 index 00000000000..a322196caff --- /dev/null +++ b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/lt.pass.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. 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 + 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 +} diff --git a/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/move.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/move.pass.cpp new file mode 100644 index 00000000000..7c172e6839b --- /dev/null +++ b/libcxx/test/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 distributed under the University of Illinois Open Source +// License. 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 +} diff --git a/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/not_eof.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/not_eof.pass.cpp new file mode 100644 index 00000000000..3de319c2538 --- /dev/null +++ b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/not_eof.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. 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 + assert(std::char_traits<char16_t>::not_eof(u'a') == u'a'); + assert(std::char_traits<char16_t>::not_eof(u'A') == u'A'); + 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 +} diff --git a/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/to_char_type.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/to_char_type.pass.cpp new file mode 100644 index 00000000000..e60ef917fb5 --- /dev/null +++ b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/to_char_type.pass.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. 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 + 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'); + assert(std::char_traits<char16_t>::to_char_type(0) == 0); +#endif +} diff --git a/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/to_int_type.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/to_int_type.pass.cpp new file mode 100644 index 00000000000..6d07b79573f --- /dev/null +++ b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/to_int_type.pass.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. 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 + 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'); + assert(std::char_traits<char16_t>::to_int_type(0) == 0); +#endif +} diff --git a/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/types.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/types.pass.cpp new file mode 100644 index 00000000000..95ce8ecb892 --- /dev/null +++ b/libcxx/test/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 distributed under the University of Illinois Open Source +// License. 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 +} diff --git a/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/assign2.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/assign2.pass.cpp new file mode 100644 index 00000000000..0caf5fdfe3f --- /dev/null +++ b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/assign2.pass.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. 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 + char32_t c = U'\0'; + std::char_traits<char32_t>::assign(c, U'a'); + assert(c == U'a'); +#endif +} diff --git a/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/assign3.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/assign3.pass.cpp new file mode 100644 index 00000000000..e3702d4931d --- /dev/null +++ b/libcxx/test/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 distributed under the University of Illinois Open Source +// License. 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 +} diff --git a/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/compare.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/compare.pass.cpp new file mode 100644 index 00000000000..0f0999b8466 --- /dev/null +++ b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/compare.pass.cpp @@ -0,0 +1,42 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. 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 + 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 +} diff --git a/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/copy.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/copy.pass.cpp new file mode 100644 index 00000000000..8e5aa6614d2 --- /dev/null +++ b/libcxx/test/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 distributed under the University of Illinois Open Source +// License. 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 +} diff --git a/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eof.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eof.pass.cpp new file mode 100644 index 00000000000..f783867bc45 --- /dev/null +++ b/libcxx/test/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 distributed under the University of Illinois Open Source +// License. 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/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eq.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eq.pass.cpp new file mode 100644 index 00000000000..fddd200ff06 --- /dev/null +++ b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eq.pass.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. 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 + 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 +} diff --git a/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eq_int_type.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eq_int_type.pass.cpp new file mode 100644 index 00000000000..d52172cc110 --- /dev/null +++ b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eq_int_type.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. 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 + 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')); + assert( std::char_traits<char32_t>::eq_int_type(std::char_traits<char32_t>::eof(), + std::char_traits<char32_t>::eof())); +#endif +} diff --git a/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/find.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/find.pass.cpp new file mode 100644 index 00000000000..4352ecf6728 --- /dev/null +++ b/libcxx/test/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 distributed under the University of Illinois Open Source +// License. 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 +} diff --git a/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/length.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/length.pass.cpp new file mode 100644 index 00000000000..2c35e502c76 --- /dev/null +++ b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/length.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. 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 + 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 +} diff --git a/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/lt.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/lt.pass.cpp new file mode 100644 index 00000000000..2b7e3cd12a4 --- /dev/null +++ b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/lt.pass.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. 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 + 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 +} diff --git a/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/move.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/move.pass.cpp new file mode 100644 index 00000000000..dc0bb78daff --- /dev/null +++ b/libcxx/test/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 distributed under the University of Illinois Open Source +// License. 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 +} diff --git a/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/not_eof.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/not_eof.pass.cpp new file mode 100644 index 00000000000..17222826268 --- /dev/null +++ b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/not_eof.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. 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 + assert(std::char_traits<char32_t>::not_eof(U'a') == U'a'); + assert(std::char_traits<char32_t>::not_eof(U'A') == U'A'); + 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 +} diff --git a/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/to_char_type.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/to_char_type.pass.cpp new file mode 100644 index 00000000000..fd1825a27f5 --- /dev/null +++ b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/to_char_type.pass.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. 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 + 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'); + assert(std::char_traits<char32_t>::to_char_type(0) == 0); +#endif +} diff --git a/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/to_int_type.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/to_int_type.pass.cpp new file mode 100644 index 00000000000..7d5dbe4fd20 --- /dev/null +++ b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/to_int_type.pass.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. 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 + 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'); + assert(std::char_traits<char32_t>::to_int_type(0) == 0); +#endif +} diff --git a/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/types.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/types.pass.cpp new file mode 100644 index 00000000000..db1d3935039 --- /dev/null +++ b/libcxx/test/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 distributed under the University of Illinois Open Source +// License. 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 +} diff --git a/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/assign2.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/assign2.pass.cpp new file mode 100644 index 00000000000..650b8bab353 --- /dev/null +++ b/libcxx/test/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 distributed under the University of Illinois Open Source +// License. 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/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/assign3.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/assign3.pass.cpp new file mode 100644 index 00000000000..a28da61276f --- /dev/null +++ b/libcxx/test/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 distributed under the University of Illinois Open Source +// License. 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/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/compare.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/compare.pass.cpp new file mode 100644 index 00000000000..d8cac4fdf3e --- /dev/null +++ b/libcxx/test/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 distributed under the University of Illinois Open Source +// License. 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/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/copy.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/copy.pass.cpp new file mode 100644 index 00000000000..abecfc1013a --- /dev/null +++ b/libcxx/test/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 distributed under the University of Illinois Open Source +// License. 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/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eof.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eof.pass.cpp new file mode 100644 index 00000000000..77637e01859 --- /dev/null +++ b/libcxx/test/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 distributed under the University of Illinois Open Source +// License. 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/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eq.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eq.pass.cpp new file mode 100644 index 00000000000..53ff74e3be5 --- /dev/null +++ b/libcxx/test/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 distributed under the University of Illinois Open Source +// License. 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/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eq_int_type.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eq_int_type.pass.cpp new file mode 100644 index 00000000000..3cb1df9efb1 --- /dev/null +++ b/libcxx/test/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 distributed under the University of Illinois Open Source +// License. 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/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/find.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/find.pass.cpp new file mode 100644 index 00000000000..6a416e8676a --- /dev/null +++ b/libcxx/test/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 distributed under the University of Illinois Open Source +// License. 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/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/length.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/length.pass.cpp new file mode 100644 index 00000000000..8d437cefa1c --- /dev/null +++ b/libcxx/test/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 distributed under the University of Illinois Open Source +// License. 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/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/lt.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/lt.pass.cpp new file mode 100644 index 00000000000..b4978e12eec --- /dev/null +++ b/libcxx/test/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 distributed under the University of Illinois Open Source +// License. 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/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/move.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/move.pass.cpp new file mode 100644 index 00000000000..3227e7e0615 --- /dev/null +++ b/libcxx/test/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 distributed under the University of Illinois Open Source +// License. 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/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/not_eof.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/not_eof.pass.cpp new file mode 100644 index 00000000000..f68b05cae61 --- /dev/null +++ b/libcxx/test/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 distributed under the University of Illinois Open Source +// License. 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/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/to_char_type.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/to_char_type.pass.cpp new file mode 100644 index 00000000000..40d941a6009 --- /dev/null +++ b/libcxx/test/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 distributed under the University of Illinois Open Source +// License. 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/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/to_int_type.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/to_int_type.pass.cpp new file mode 100644 index 00000000000..e993cd96670 --- /dev/null +++ b/libcxx/test/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 distributed under the University of Illinois Open Source +// License. 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/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/types.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/types.pass.cpp new file mode 100644 index 00000000000..2353cb161ae --- /dev/null +++ b/libcxx/test/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 distributed under the University of Illinois Open Source +// License. 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/strings/char.traits/char.traits.specializations/nothing_to_do.pass.cpp b/libcxx/test/strings/char.traits/char.traits.specializations/nothing_to_do.pass.cpp new file mode 100644 index 00000000000..fa4d462f18d --- /dev/null +++ b/libcxx/test/strings/char.traits/char.traits.specializations/nothing_to_do.pass.cpp @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} diff --git a/libcxx/test/strings/char.traits/char.traits.typedefs/nothing_to_do.pass.cpp b/libcxx/test/strings/char.traits/char.traits.typedefs/nothing_to_do.pass.cpp new file mode 100644 index 00000000000..fa4d462f18d --- /dev/null +++ b/libcxx/test/strings/char.traits/char.traits.typedefs/nothing_to_do.pass.cpp @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} diff --git a/libcxx/test/strings/char.traits/nothing_to_do.pass.cpp b/libcxx/test/strings/char.traits/nothing_to_do.pass.cpp new file mode 100644 index 00000000000..fa4d462f18d --- /dev/null +++ b/libcxx/test/strings/char.traits/nothing_to_do.pass.cpp @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} |