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 assert((lhs > rhs) == x); 24 } 25 26 TEST_CONSTEXPR_CXX20 bool test() { 27 { 28 typedef std::string S; 29 test(S(""), S(""), false); 30 test(S(""), S("abcde"), false); 31 test(S(""), S("abcdefghij"), false); 32 test(S(""), S("abcdefghijklmnopqrst"), false); 33 test(S("abcde"), S(""), true); 34 test(S("abcde"), S("abcde"), false); 35 test(S("abcde"), S("abcdefghij"), false); 36 test(S("abcde"), S("abcdefghijklmnopqrst"), false); 37 test(S("abcdefghij"), S(""), true); 38 test(S("abcdefghij"), S("abcde"), true); 39 test(S("abcdefghij"), S("abcdefghij"), false); 40 test(S("abcdefghij"), S("abcdefghijklmnopqrst"), false); 41 test(S("abcdefghijklmnopqrst"), S(""), true); 42 test(S("abcdefghijklmnopqrst"), S("abcde"), true); 43 test(S("abcdefghijklmnopqrst"), S("abcdefghij"), true); 44 test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false); 45 } 46 #if TEST_STD_VER >= 11 47 { 48 typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; 49 test(S(""), S(""), false); 50 test(S(""), S("abcde"), false); 51 test(S(""), S("abcdefghij"), false); 52 test(S(""), S("abcdefghijklmnopqrst"), false); 53 test(S("abcde"), S(""), true); 54 test(S("abcde"), S("abcde"), false); 55 test(S("abcde"), S("abcdefghij"), false); 56 test(S("abcde"), S("abcdefghijklmnopqrst"), false); 57 test(S("abcdefghij"), S(""), true); 58 test(S("abcdefghij"), S("abcde"), true); 59 test(S("abcdefghij"), S("abcdefghij"), false); 60 test(S("abcdefghij"), S("abcdefghijklmnopqrst"), false); 61 test(S("abcdefghijklmnopqrst"), S(""), true); 62 test(S("abcdefghijklmnopqrst"), S("abcde"), true); 63 test(S("abcdefghijklmnopqrst"), S("abcdefghij"), true); 64 test(S("abcdefghijklmnopqrst"), S("abcdefghijklmnopqrst"), false); 65 } 66 #endif 67 68 return true; 69 } 70 71 int main(int, char**) { 72 test(); 73 #if TEST_STD_VER > 17 74 static_assert(test()); 75 #endif 76 77 return 0; 78 } 79