forked from mirror/libcxx
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
2.2 KiB
C++
59 lines
2.2 KiB
C++
//===----------------------------------------------------------------------===//
|
|
//
|
|
// 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.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
|
|
|
|
// <string>
|
|
|
|
// template<> struct char_traits<char8_t>
|
|
|
|
// static constexpr int compare(const char_type* s1, const char_type* s2, size_t n);
|
|
|
|
#include <string>
|
|
#include <cassert>
|
|
|
|
#include "test_macros.h"
|
|
|
|
#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L
|
|
constexpr bool test_constexpr()
|
|
{
|
|
return std::char_traits<char8_t>::compare(u8"123", u8"223", 3) < 0
|
|
&& std::char_traits<char8_t>::compare(u8"223", u8"123", 3) > 0
|
|
&& std::char_traits<char8_t>::compare(u8"123", u8"123", 3) == 0;
|
|
}
|
|
|
|
|
|
int main()
|
|
{
|
|
assert(std::char_traits<char8_t>::compare(u8"", u8"", 0) == 0);
|
|
assert(std::char_traits<char8_t>::compare(NULL, NULL, 0) == 0);
|
|
|
|
assert(std::char_traits<char8_t>::compare(u8"1", u8"1", 1) == 0);
|
|
assert(std::char_traits<char8_t>::compare(u8"1", u8"2", 1) < 0);
|
|
assert(std::char_traits<char8_t>::compare(u8"2", u8"1", 1) > 0);
|
|
|
|
assert(std::char_traits<char8_t>::compare(u8"12", u8"12", 2) == 0);
|
|
assert(std::char_traits<char8_t>::compare(u8"12", u8"13", 2) < 0);
|
|
assert(std::char_traits<char8_t>::compare(u8"12", u8"22", 2) < 0);
|
|
assert(std::char_traits<char8_t>::compare(u8"13", u8"12", 2) > 0);
|
|
assert(std::char_traits<char8_t>::compare(u8"22", u8"12", 2) > 0);
|
|
|
|
assert(std::char_traits<char8_t>::compare(u8"123", u8"123", 3) == 0);
|
|
assert(std::char_traits<char8_t>::compare(u8"123", u8"223", 3) < 0);
|
|
assert(std::char_traits<char8_t>::compare(u8"123", u8"133", 3) < 0);
|
|
assert(std::char_traits<char8_t>::compare(u8"123", u8"124", 3) < 0);
|
|
assert(std::char_traits<char8_t>::compare(u8"223", u8"123", 3) > 0);
|
|
assert(std::char_traits<char8_t>::compare(u8"133", u8"123", 3) > 0);
|
|
assert(std::char_traits<char8_t>::compare(u8"124", u8"123", 3) > 0);
|
|
|
|
static_assert(test_constexpr(), "" );
|
|
}
|
|
#else
|
|
int main () {}
|
|
#endif
|