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

source code of libcxx/test/std/strings/basic.string/string.nonmembers/string_oplt/string_string.pass.cpp