1 //===----------------------------------------------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 // <string>
11
12 // template<> struct char_traits<char16_t>
13
14 // static int compare(const char_type* s1, const char_type* s2, size_t n);
15
16 #include <string>
17 #include <cassert>
18
main()19 int main()
20 {
21 #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
22 #if __cplusplus >= 201103L
23 assert(std::char_traits<char16_t>::compare(u"", u"", 0) == 0);
24 assert(std::char_traits<char16_t>::compare(NULL, NULL, 0) == 0);
25
26 assert(std::char_traits<char16_t>::compare(u"1", u"1", 1) == 0);
27 assert(std::char_traits<char16_t>::compare(u"1", u"2", 1) < 0);
28 assert(std::char_traits<char16_t>::compare(u"2", u"1", 1) > 0);
29
30 assert(std::char_traits<char16_t>::compare(u"12", u"12", 2) == 0);
31 assert(std::char_traits<char16_t>::compare(u"12", u"13", 2) < 0);
32 assert(std::char_traits<char16_t>::compare(u"12", u"22", 2) < 0);
33 assert(std::char_traits<char16_t>::compare(u"13", u"12", 2) > 0);
34 assert(std::char_traits<char16_t>::compare(u"22", u"12", 2) > 0);
35
36 assert(std::char_traits<char16_t>::compare(u"123", u"123", 3) == 0);
37 assert(std::char_traits<char16_t>::compare(u"123", u"223", 3) < 0);
38 assert(std::char_traits<char16_t>::compare(u"123", u"133", 3) < 0);
39 assert(std::char_traits<char16_t>::compare(u"123", u"124", 3) < 0);
40 assert(std::char_traits<char16_t>::compare(u"223", u"123", 3) > 0);
41 assert(std::char_traits<char16_t>::compare(u"133", u"123", 3) > 0);
42 assert(std::char_traits<char16_t>::compare(u"124", u"123", 3) > 0);
43 #endif
44 #endif // _LIBCPP_HAS_NO_UNICODE_CHARS
45 }
46