• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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<char32_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     assert(std::char_traits<char32_t>::compare(U"", U"", 0) == 0);
23 
24     assert(std::char_traits<char32_t>::compare(U"1", U"1", 1) == 0);
25     assert(std::char_traits<char32_t>::compare(U"1", U"2", 1) < 0);
26     assert(std::char_traits<char32_t>::compare(U"2", U"1", 1) > 0);
27 
28     assert(std::char_traits<char32_t>::compare(U"12", U"12", 2) == 0);
29     assert(std::char_traits<char32_t>::compare(U"12", U"13", 2) < 0);
30     assert(std::char_traits<char32_t>::compare(U"12", U"22", 2) < 0);
31     assert(std::char_traits<char32_t>::compare(U"13", U"12", 2) > 0);
32     assert(std::char_traits<char32_t>::compare(U"22", U"12", 2) > 0);
33 
34     assert(std::char_traits<char32_t>::compare(U"123", U"123", 3) == 0);
35     assert(std::char_traits<char32_t>::compare(U"123", U"223", 3) < 0);
36     assert(std::char_traits<char32_t>::compare(U"123", U"133", 3) < 0);
37     assert(std::char_traits<char32_t>::compare(U"123", U"124", 3) < 0);
38     assert(std::char_traits<char32_t>::compare(U"223", U"123", 3) > 0);
39     assert(std::char_traits<char32_t>::compare(U"133", U"123", 3) > 0);
40     assert(std::char_traits<char32_t>::compare(U"124", U"123", 3) > 0);
41 #endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
42 }
43