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