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