Move test into test/std subdirectory.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@224658 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -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
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<char16_t>
|
||||
|
||||
// static char_type* assign(char_type* s, size_t n, char_type a);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
|
||||
char16_t s1[] = {1, 2, 3};
|
||||
char16_t s2[3] = {0};
|
||||
assert(std::char_traits<char16_t>::assign(s2, 3, char16_t(5)) == s2);
|
||||
assert(s2[0] == char16_t(5));
|
||||
assert(s2[1] == char16_t(5));
|
||||
assert(s2[2] == char16_t(5));
|
||||
#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<char16_t>
|
||||
|
||||
// static int compare(const char_type* s1, const char_type* s2, size_t n);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
|
||||
#if __cplusplus >= 201103L
|
||||
assert(std::char_traits<char16_t>::compare(u"", u"", 0) == 0);
|
||||
|
||||
assert(std::char_traits<char16_t>::compare(u"1", u"1", 1) == 0);
|
||||
assert(std::char_traits<char16_t>::compare(u"1", u"2", 1) < 0);
|
||||
assert(std::char_traits<char16_t>::compare(u"2", u"1", 1) > 0);
|
||||
|
||||
assert(std::char_traits<char16_t>::compare(u"12", u"12", 2) == 0);
|
||||
assert(std::char_traits<char16_t>::compare(u"12", u"13", 2) < 0);
|
||||
assert(std::char_traits<char16_t>::compare(u"12", u"22", 2) < 0);
|
||||
assert(std::char_traits<char16_t>::compare(u"13", u"12", 2) > 0);
|
||||
assert(std::char_traits<char16_t>::compare(u"22", u"12", 2) > 0);
|
||||
|
||||
assert(std::char_traits<char16_t>::compare(u"123", u"123", 3) == 0);
|
||||
assert(std::char_traits<char16_t>::compare(u"123", u"223", 3) < 0);
|
||||
assert(std::char_traits<char16_t>::compare(u"123", u"133", 3) < 0);
|
||||
assert(std::char_traits<char16_t>::compare(u"123", u"124", 3) < 0);
|
||||
assert(std::char_traits<char16_t>::compare(u"223", u"123", 3) > 0);
|
||||
assert(std::char_traits<char16_t>::compare(u"133", u"123", 3) > 0);
|
||||
assert(std::char_traits<char16_t>::compare(u"124", u"123", 3) > 0);
|
||||
#endif
|
||||
#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<char16_t>
|
||||
|
||||
// static char_type* copy(char_type* s1, const char_type* s2, size_t n);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
|
||||
char16_t s1[] = {1, 2, 3};
|
||||
char16_t s2[3] = {0};
|
||||
assert(std::char_traits<char16_t>::copy(s2, s1, 3) == s2);
|
||||
assert(s2[0] == char16_t(1));
|
||||
assert(s2[1] == char16_t(2));
|
||||
assert(s2[2] == char16_t(3));
|
||||
#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<char16_t>
|
||||
|
||||
// static const char_type* find(const char_type* s, size_t n, const char_type& a);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
|
||||
char16_t s1[] = {1, 2, 3};
|
||||
assert(std::char_traits<char16_t>::find(s1, 3, char16_t(1)) == s1);
|
||||
assert(std::char_traits<char16_t>::find(s1, 3, char16_t(2)) == s1+1);
|
||||
assert(std::char_traits<char16_t>::find(s1, 3, char16_t(3)) == s1+2);
|
||||
assert(std::char_traits<char16_t>::find(s1, 3, char16_t(4)) == 0);
|
||||
assert(std::char_traits<char16_t>::find(s1, 3, char16_t(0)) == 0);
|
||||
#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <string>
|
||||
|
||||
// template<> struct char_traits<char16_t>
|
||||
|
||||
// static char_type* move(char_type* s1, const char_type* s2, size_t n);
|
||||
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
|
||||
char16_t s1[] = {1, 2, 3};
|
||||
assert(std::char_traits<char16_t>::move(s1, s1+1, 2) == s1);
|
||||
assert(s1[0] == char16_t(2));
|
||||
assert(s1[1] == char16_t(3));
|
||||
assert(s1[2] == char16_t(3));
|
||||
s1[2] = char16_t(0);
|
||||
assert(std::char_traits<char16_t>::move(s1+1, s1, 2) == s1+1);
|
||||
assert(s1[0] == char16_t(2));
|
||||
assert(s1[1] == char16_t(2));
|
||||
assert(s1[2] == char16_t(3));
|
||||
#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user