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:
Eric Fiselier
2014-12-20 01:40:03 +00:00
parent 669a8a5a19
commit a90c6dd460
4817 changed files with 13 additions and 0 deletions

View File

@@ -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');
}

View File

@@ -0,0 +1,27 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// template<> struct char_traits<char>
// static char_type* assign(char_type* s, size_t n, char_type a);
#include <string>
#include <cassert>
int main()
{
char s1[] = {1, 2, 3};
char s2[3] = {0};
assert(std::char_traits<char>::assign(s2, 3, char(5)) == s2);
assert(s2[0] == char(5));
assert(s2[1] == char(5));
assert(s2[2] == char(5));
}

View File

@@ -0,0 +1,40 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// template<> struct char_traits<char>
// static int compare(const char_type* s1, const char_type* s2, size_t n);
#include <string>
#include <cassert>
int main()
{
assert(std::char_traits<char>::compare("", "", 0) == 0);
assert(std::char_traits<char>::compare("1", "1", 1) == 0);
assert(std::char_traits<char>::compare("1", "2", 1) < 0);
assert(std::char_traits<char>::compare("2", "1", 1) > 0);
assert(std::char_traits<char>::compare("12", "12", 2) == 0);
assert(std::char_traits<char>::compare("12", "13", 2) < 0);
assert(std::char_traits<char>::compare("12", "22", 2) < 0);
assert(std::char_traits<char>::compare("13", "12", 2) > 0);
assert(std::char_traits<char>::compare("22", "12", 2) > 0);
assert(std::char_traits<char>::compare("123", "123", 3) == 0);
assert(std::char_traits<char>::compare("123", "223", 3) < 0);
assert(std::char_traits<char>::compare("123", "133", 3) < 0);
assert(std::char_traits<char>::compare("123", "124", 3) < 0);
assert(std::char_traits<char>::compare("223", "123", 3) > 0);
assert(std::char_traits<char>::compare("133", "123", 3) > 0);
assert(std::char_traits<char>::compare("124", "123", 3) > 0);
}

View File

@@ -0,0 +1,27 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// template<> struct char_traits<char>
// static char_type* copy(char_type* s1, const char_type* s2, size_t n);
#include <string>
#include <cassert>
int main()
{
char s1[] = {1, 2, 3};
char s2[3] = {0};
assert(std::char_traits<char>::copy(s2, s1, 3) == s2);
assert(s2[0] == char(1));
assert(s2[1] == char(2));
assert(s2[2] == char(3));
}

View File

@@ -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);
}

View File

@@ -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'));
}

View File

@@ -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()));
}

View File

@@ -0,0 +1,27 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// template<> struct char_traits<char>
// static const char_type* find(const char_type* s, size_t n, const char_type& a);
#include <string>
#include <cassert>
int main()
{
char s1[] = {1, 2, 3};
assert(std::char_traits<char>::find(s1, 3, char(1)) == s1);
assert(std::char_traits<char>::find(s1, 3, char(2)) == s1+1);
assert(std::char_traits<char>::find(s1, 3, char(3)) == s1+2);
assert(std::char_traits<char>::find(s1, 3, char(4)) == 0);
assert(std::char_traits<char>::find(s1, 3, char(0)) == 0);
}

View File

@@ -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);
}

View File

@@ -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));
}

View File

@@ -0,0 +1,31 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <string>
// template<> struct char_traits<char>
// static char_type* move(char_type* s1, const char_type* s2, size_t n);
#include <string>
#include <cassert>
int main()
{
char s1[] = {1, 2, 3};
assert(std::char_traits<char>::move(s1, s1+1, 2) == s1);
assert(s1[0] == char(2));
assert(s1[1] == char(3));
assert(s1[2] == char(3));
s1[2] = char(0);
assert(std::char_traits<char>::move(s1+1, s1, 2) == s1+1);
assert(s1[0] == char(2));
assert(s1[1] == char(2));
assert(s1[2] == char(3));
}

View File

@@ -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());
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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), "");
}