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