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