diff options
Diffstat (limited to 'test/std/strings/char.traits')
64 files changed, 1786 insertions, 0 deletions
diff --git a/test/std/strings/char.traits/char.traits.require/nothing_to_do.pass.cpp b/test/std/strings/char.traits/char.traits.require/nothing_to_do.pass.cpp new file mode 100644 index 0000000000000..b58f5c55b643a --- /dev/null +++ b/test/std/strings/char.traits/char.traits.require/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() +{ +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/assign2.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/assign2.pass.cpp new file mode 100644 index 0000000000000..2c3deaefd0638 --- /dev/null +++ b/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/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/assign3.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/assign3.pass.cpp new file mode 100644 index 0000000000000..a4a0e294c2624 --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/assign3.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 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)); + assert(std::char_traits<char>::assign(NULL, 0, char(5)) == NULL); +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/compare.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/compare.pass.cpp new file mode 100644 index 0000000000000..ba58684b8e2e4 --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/compare.pass.cpp @@ -0,0 +1,41 @@ +//===----------------------------------------------------------------------===// +// +// 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(NULL, NULL, 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/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/copy.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/copy.pass.cpp new file mode 100644 index 0000000000000..179df9e19dde1 --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/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<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)); + assert(std::char_traits<char>::copy(NULL, s1, 0) == NULL); + assert(std::char_traits<char>::copy(s1, NULL, 0) == s1); +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eof.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eof.pass.cpp new file mode 100644 index 0000000000000..39fba6b1c0687 --- /dev/null +++ b/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/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eq.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eq.pass.cpp new file mode 100644 index 0000000000000..f7f84e85924c6 --- /dev/null +++ b/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/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eq_int_type.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/eq_int_type.pass.cpp new file mode 100644 index 0000000000000..bdaf431db4dc0 --- /dev/null +++ b/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/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/find.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/find.pass.cpp new file mode 100644 index 0000000000000..a640af28d8ac3 --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/find.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 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); + assert(std::char_traits<char>::find(NULL, 0, char(0)) == 0); +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/length.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/length.pass.cpp new file mode 100644 index 0000000000000..56844ef466443 --- /dev/null +++ b/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/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/lt.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/lt.pass.cpp new file mode 100644 index 0000000000000..3ff9c0f1ff92b --- /dev/null +++ b/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/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/move.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/move.pass.cpp new file mode 100644 index 0000000000000..67f0216a28b12 --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/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<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)); + assert(std::char_traits<char>::move(NULL, s1, 0) == NULL); + assert(std::char_traits<char>::move(s1, NULL, 0) == s1); +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/not_eof.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/not_eof.pass.cpp new file mode 100644 index 0000000000000..69800969a7f30 --- /dev/null +++ b/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/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/to_char_type.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/to_char_type.pass.cpp new file mode 100644 index 0000000000000..498abfa25fc03 --- /dev/null +++ b/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/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/to_int_type.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/to_int_type.pass.cpp new file mode 100644 index 0000000000000..aa9594cfdc420 --- /dev/null +++ b/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/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/types.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char/types.pass.cpp new file mode 100644 index 0000000000000..ff4a93af65f2a --- /dev/null +++ b/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/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/assign2.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/assign2.pass.cpp new file mode 100644 index 0000000000000..af87052ff2194 --- /dev/null +++ b/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/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/assign3.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/assign3.pass.cpp new file mode 100644 index 0000000000000..fc1ba6e8670a1 --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/assign3.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 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)); + assert(std::char_traits<char16_t>::assign(NULL, 0, char16_t(5)) == NULL); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/compare.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/compare.pass.cpp new file mode 100644 index 0000000000000..b5039072dbfda --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/compare.pass.cpp @@ -0,0 +1,45 @@ +//===----------------------------------------------------------------------===// +// +// 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(NULL, NULL, 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/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/copy.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/copy.pass.cpp new file mode 100644 index 0000000000000..4f66d2c2cadee --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/copy.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<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)); + assert(std::char_traits<char16_t>::copy(NULL, s1, 0) == NULL); + assert(std::char_traits<char16_t>::copy(s1, NULL, 0) == s1); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eof.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eof.pass.cpp new file mode 100644 index 0000000000000..4e5a1834aeb5f --- /dev/null +++ b/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/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eq.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eq.pass.cpp new file mode 100644 index 0000000000000..8216934658ce9 --- /dev/null +++ b/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/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eq_int_type.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/eq_int_type.pass.cpp new file mode 100644 index 0000000000000..a20aa7d471895 --- /dev/null +++ b/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/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/find.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/find.pass.cpp new file mode 100644 index 0000000000000..22db05b55a875 --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/find.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 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); + assert(std::char_traits<char16_t>::find(NULL, 0, char16_t(0)) == 0); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/length.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/length.pass.cpp new file mode 100644 index 0000000000000..9f6acca83e368 --- /dev/null +++ b/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/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/lt.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/lt.pass.cpp new file mode 100644 index 0000000000000..135ecc05e1996 --- /dev/null +++ b/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/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/move.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/move.pass.cpp new file mode 100644 index 0000000000000..b2ae8040ec243 --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/move.pass.cpp @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +// 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)); + assert(std::char_traits<char16_t>::move(NULL, s1, 0) == NULL); + assert(std::char_traits<char16_t>::move(s1, NULL, 0) == s1); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/not_eof.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/not_eof.pass.cpp new file mode 100644 index 0000000000000..3c213e6e0a37c --- /dev/null +++ b/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/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/to_char_type.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/to_char_type.pass.cpp new file mode 100644 index 0000000000000..ab47403dbe01b --- /dev/null +++ b/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/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/to_int_type.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/to_int_type.pass.cpp new file mode 100644 index 0000000000000..11eb8f5254664 --- /dev/null +++ b/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/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/types.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char16_t/types.pass.cpp new file mode 100644 index 0000000000000..a40296b25b1d0 --- /dev/null +++ b/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/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/assign2.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/assign2.pass.cpp new file mode 100644 index 0000000000000..35dcd9602d3cf --- /dev/null +++ b/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/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/assign3.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/assign3.pass.cpp new file mode 100644 index 0000000000000..0c31ea7ae97e2 --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/assign3.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 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)); + assert(std::char_traits<char32_t>::assign(NULL, 0, char32_t(5)) == NULL); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/compare.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/compare.pass.cpp new file mode 100644 index 0000000000000..25f2099896a64 --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/compare.pass.cpp @@ -0,0 +1,45 @@ +//===----------------------------------------------------------------------===// +// +// 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(NULL, NULL, 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/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/copy.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/copy.pass.cpp new file mode 100644 index 0000000000000..89c22250b3063 --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/copy.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<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)); + assert(std::char_traits<char32_t>::copy(NULL, s1, 0) == NULL); + assert(std::char_traits<char32_t>::copy(s1, NULL, 0) == s1); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eof.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eof.pass.cpp new file mode 100644 index 0000000000000..8f804aa22e7a2 --- /dev/null +++ b/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/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eq.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eq.pass.cpp new file mode 100644 index 0000000000000..ffeff0cf45a40 --- /dev/null +++ b/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/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eq_int_type.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/eq_int_type.pass.cpp new file mode 100644 index 0000000000000..eb5c696610146 --- /dev/null +++ b/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/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/find.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/find.pass.cpp new file mode 100644 index 0000000000000..d0b17999d3e16 --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/find.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 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); + assert(std::char_traits<char32_t>::find(NULL, 0, char32_t(0)) == 0); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/length.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/length.pass.cpp new file mode 100644 index 0000000000000..d80ce051d1fa7 --- /dev/null +++ b/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/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/lt.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/lt.pass.cpp new file mode 100644 index 0000000000000..f667507f04571 --- /dev/null +++ b/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/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/move.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/move.pass.cpp new file mode 100644 index 0000000000000..8641525d92bdb --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/move.pass.cpp @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +// 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)); + assert(std::char_traits<char32_t>::move(NULL, s1, 0) == NULL); + assert(std::char_traits<char32_t>::move(s1, NULL, 0) == s1); +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/not_eof.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/not_eof.pass.cpp new file mode 100644 index 0000000000000..d794417bfd7aa --- /dev/null +++ b/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/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/to_char_type.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/to_char_type.pass.cpp new file mode 100644 index 0000000000000..1f67242b2aec5 --- /dev/null +++ b/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/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/to_int_type.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/to_int_type.pass.cpp new file mode 100644 index 0000000000000..a378186bdd6fb --- /dev/null +++ b/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/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/types.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.char32_t/types.pass.cpp new file mode 100644 index 0000000000000..3b48af14f963b --- /dev/null +++ b/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/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/assign2.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/assign2.pass.cpp new file mode 100644 index 0000000000000..7dcf08c2e76f0 --- /dev/null +++ b/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/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/assign3.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/assign3.pass.cpp new file mode 100644 index 0000000000000..2a00fe06e5a26 --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/assign3.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<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)); + assert(std::char_traits<wchar_t>::assign(NULL, 0, wchar_t(5)) == NULL); +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/compare.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/compare.pass.cpp new file mode 100644 index 0000000000000..124201bb82f3d --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/compare.pass.cpp @@ -0,0 +1,41 @@ +//===----------------------------------------------------------------------===// +// +// 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(NULL, NULL, 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/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/copy.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/copy.pass.cpp new file mode 100644 index 0000000000000..f6d254f4c7c50 --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.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<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)); + assert(std::char_traits<wchar_t>::copy(NULL, s1, 0) == NULL); + assert(std::char_traits<wchar_t>::copy(s1, NULL, 0) == s1); +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eof.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eof.pass.cpp new file mode 100644 index 0000000000000..61499b5809f83 --- /dev/null +++ b/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/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eq.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eq.pass.cpp new file mode 100644 index 0000000000000..98d0926e30713 --- /dev/null +++ b/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/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eq_int_type.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/eq_int_type.pass.cpp new file mode 100644 index 0000000000000..6b523dbdda230 --- /dev/null +++ b/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/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/find.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/find.pass.cpp new file mode 100644 index 0000000000000..ead3f32fcc72e --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/find.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<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); + assert(std::char_traits<wchar_t>::find(NULL, 0, wchar_t(0)) == 0); +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/length.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/length.pass.cpp new file mode 100644 index 0000000000000..691e968ed246e --- /dev/null +++ b/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/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/lt.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/lt.pass.cpp new file mode 100644 index 0000000000000..147a57914e09e --- /dev/null +++ b/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/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/move.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/move.pass.cpp new file mode 100644 index 0000000000000..0d80446e71189 --- /dev/null +++ b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.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<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)); + assert(std::char_traits<wchar_t>::move(NULL, s1, 0) == NULL); + assert(std::char_traits<wchar_t>::move(s1, NULL, 0) == s1); +} diff --git a/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/not_eof.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/not_eof.pass.cpp new file mode 100644 index 0000000000000..ee44f313b58c4 --- /dev/null +++ b/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/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/to_char_type.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/to_char_type.pass.cpp new file mode 100644 index 0000000000000..9b4c04829a920 --- /dev/null +++ b/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/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/to_int_type.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/to_int_type.pass.cpp new file mode 100644 index 0000000000000..488b03e0f014f --- /dev/null +++ b/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/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/types.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/char.traits.specializations.wchar.t/types.pass.cpp new file mode 100644 index 0000000000000..12598975c4feb --- /dev/null +++ b/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/test/std/strings/char.traits/char.traits.specializations/nothing_to_do.pass.cpp b/test/std/strings/char.traits/char.traits.specializations/nothing_to_do.pass.cpp new file mode 100644 index 0000000000000..b58f5c55b643a --- /dev/null +++ b/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() +{ +} diff --git a/test/std/strings/char.traits/char.traits.typedefs/nothing_to_do.pass.cpp b/test/std/strings/char.traits/char.traits.typedefs/nothing_to_do.pass.cpp new file mode 100644 index 0000000000000..b58f5c55b643a --- /dev/null +++ b/test/std/strings/char.traits/char.traits.typedefs/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() +{ +} diff --git a/test/std/strings/char.traits/nothing_to_do.pass.cpp b/test/std/strings/char.traits/nothing_to_do.pass.cpp new file mode 100644 index 0000000000000..b58f5c55b643a --- /dev/null +++ b/test/std/strings/char.traits/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() +{ +} |