1 //===----------------------------------------------------------------------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
8 
9 // <string>
10 
11 // template<class charT, class traits, class Allocator>
12 //   bool operator>(const charT* lhs, const basic_string<charT,traits,Allocator>& rhs); // constexpr since C++20
13 
14 #include <string>
15 #include <cassert>
16 
17 #include "test_macros.h"
18 #include "min_allocator.h"
19 
20 template <class S>
21 TEST_CONSTEXPR_CXX20 void test(const typename S::value_type* lhs, const S& rhs, bool x) {
22   assert((lhs > rhs) == x);
23 }
24 
25 TEST_CONSTEXPR_CXX20 bool test() {
26   {
27     typedef std::string S;
28     test("", S(""), false);
29     test("", S("abcde"), false);
30     test("", S("abcdefghij"), false);
31     test("", S("abcdefghijklmnopqrst"), false);
32     test("abcde", S(""), true);
33     test("abcde", S("abcde"), false);
34     test("abcde", S("abcdefghij"), false);
35     test("abcde", S("abcdefghijklmnopqrst"), false);
36     test("abcdefghij", S(""), true);
37     test("abcdefghij", S("abcde"), true);
38     test("abcdefghij", S("abcdefghij"), false);
39     test("abcdefghij", S("abcdefghijklmnopqrst"), false);
40     test("abcdefghijklmnopqrst", S(""), true);
41     test("abcdefghijklmnopqrst", S("abcde"), true);
42     test("abcdefghijklmnopqrst", S("abcdefghij"), true);
43     test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), false);
44   }
45 #if TEST_STD_VER >= 11
46   {
47     typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
48     test("", S(""), false);
49     test("", S("abcde"), false);
50     test("", S("abcdefghij"), false);
51     test("", S("abcdefghijklmnopqrst"), false);
52     test("abcde", S(""), true);
53     test("abcde", S("abcde"), false);
54     test("abcde", S("abcdefghij"), false);
55     test("abcde", S("abcdefghijklmnopqrst"), false);
56     test("abcdefghij", S(""), true);
57     test("abcdefghij", S("abcde"), true);
58     test("abcdefghij", S("abcdefghij"), false);
59     test("abcdefghij", S("abcdefghijklmnopqrst"), false);
60     test("abcdefghijklmnopqrst", S(""), true);
61     test("abcdefghijklmnopqrst", S("abcde"), true);
62     test("abcdefghijklmnopqrst", S("abcdefghij"), true);
63     test("abcdefghijklmnopqrst", S("abcdefghijklmnopqrst"), false);
64   }
65 #endif
66 
67   return true;
68 }
69 
70 int main(int, char**) {
71   test();
72 #if TEST_STD_VER > 17
73   static_assert(test());
74 #endif
75 
76   return 0;
77 }
78