| 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 | template <class S> |
| 26 | TEST_CONSTEXPR_CXX20 void test_string() { |
| 27 | test("" , S("" ), false); |
| 28 | test("" , S("abcde" ), true); |
| 29 | test("" , S("abcdefghij" ), true); |
| 30 | test("" , S("abcdefghijklmnopqrst" ), true); |
| 31 | test("abcde" , S("" ), false); |
| 32 | test("abcde" , S("abcde" ), false); |
| 33 | test("abcde" , S("abcdefghij" ), true); |
| 34 | test("abcde" , S("abcdefghijklmnopqrst" ), true); |
| 35 | test("abcdefghij" , S("" ), false); |
| 36 | test("abcdefghij" , S("abcde" ), false); |
| 37 | test("abcdefghij" , S("abcdefghij" ), false); |
| 38 | test("abcdefghij" , S("abcdefghijklmnopqrst" ), true); |
| 39 | test("abcdefghijklmnopqrst" , S("" ), false); |
| 40 | test("abcdefghijklmnopqrst" , S("abcde" ), false); |
| 41 | test("abcdefghijklmnopqrst" , S("abcdefghij" ), false); |
| 42 | test("abcdefghijklmnopqrst" , S("abcdefghijklmnopqrst" ), false); |
| 43 | } |
| 44 | |
| 45 | TEST_CONSTEXPR_CXX20 bool test() { |
| 46 | test_string<std::string>(); |
| 47 | #if TEST_STD_VER >= 11 |
| 48 | test_string<std::basic_string<char, std::char_traits<char>, min_allocator<char> > >(); |
| 49 | #endif |
| 50 | |
| 51 | return true; |
| 52 | } |
| 53 | |
| 54 | int main(int, char**) { |
| 55 | test(); |
| 56 | #if TEST_STD_VER > 17 |
| 57 | static_assert(test()); |
| 58 | #endif |
| 59 | |
| 60 | return 0; |
| 61 | } |
| 62 | |