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 19 int main() 20 { 21 #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS 22 #if __cplusplus >= 201103L 23 assert(std::char_traits<char32_t>::compare(U"", U"", 0) == 0); 24 assert(std::char_traits<char32_t>::compare(NULL, NULL, 0) == 0); 25 26 assert(std::char_traits<char32_t>::compare(U"1", U"1", 1) == 0); 27 assert(std::char_traits<char32_t>::compare(U"1", U"2", 1) < 0); 28 assert(std::char_traits<char32_t>::compare(U"2", U"1", 1) > 0); 29 30 assert(std::char_traits<char32_t>::compare(U"12", U"12", 2) == 0); 31 assert(std::char_traits<char32_t>::compare(U"12", U"13", 2) < 0); 32 assert(std::char_traits<char32_t>::compare(U"12", U"22", 2) < 0); 33 assert(std::char_traits<char32_t>::compare(U"13", U"12", 2) > 0); 34 assert(std::char_traits<char32_t>::compare(U"22", U"12", 2) > 0); 35 36 assert(std::char_traits<char32_t>::compare(U"123", U"123", 3) == 0); 37 assert(std::char_traits<char32_t>::compare(U"123", U"223", 3) < 0); 38 assert(std::char_traits<char32_t>::compare(U"123", U"133", 3) < 0); 39 assert(std::char_traits<char32_t>::compare(U"123", U"124", 3) < 0); 40 assert(std::char_traits<char32_t>::compare(U"223", U"123", 3) > 0); 41 assert(std::char_traits<char32_t>::compare(U"133", U"123", 3) > 0); 42 assert(std::char_traits<char32_t>::compare(U"124", U"123", 3) > 0); 43 #endif 44 #endif // _LIBCPP_HAS_NO_UNICODE_CHARS 45 } 46