1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
11 // we get this comparison "for free" because the string implicitly converts to the string_view
16 #include "test_macros.h"
17 #include "min_allocator.h"
19 template <class S
, class SV
>
20 TEST_CONSTEXPR_CXX20
void test(SV lhs
, const S
& rhs
, bool x
) {
21 assert((lhs
> rhs
) == x
);
24 template <class CharT
, template <class> class Alloc
>
25 TEST_CONSTEXPR_CXX20
void test_string() {
26 using S
= std::basic_string
<CharT
, std::char_traits
<CharT
>, Alloc
<CharT
> >;
27 using SV
= std::basic_string_view
<CharT
, std::char_traits
<CharT
> >;
28 test(SV(""), S(""), false);
29 test(SV(""), S("abcde"), false);
30 test(SV(""), S("abcdefghij"), false);
31 test(SV(""), S("abcdefghijklmnopqrst"), false);
32 test(SV("abcde"), S(""), true);
33 test(SV("abcde"), S("abcde"), false);
34 test(SV("abcde"), S("abcdefghij"), false);
35 test(SV("abcde"), S("abcdefghijklmnopqrst"), false);
36 test(SV("abcdefghij"), S(""), true);
37 test(SV("abcdefghij"), S("abcde"), true);
38 test(SV("abcdefghij"), S("abcdefghij"), false);
39 test(SV("abcdefghij"), S("abcdefghijklmnopqrst"), false);
40 test(SV("abcdefghijklmnopqrst"), S(""), true);
41 test(SV("abcdefghijklmnopqrst"), S("abcde"), true);
42 test(SV("abcdefghijklmnopqrst"), S("abcdefghij"), true);
43 test(SV("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false);
46 TEST_CONSTEXPR_CXX20
bool test() {
47 test_string
<char, std::allocator
>();
48 #if TEST_STD_VER >= 11
49 test_string
<char, min_allocator
>();
55 int main(int, char**) {
58 static_assert(test());