15a83710eSEric Fiselier //===----------------------------------------------------------------------===//
25a83710eSEric Fiselier //
357b08b09SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
457b08b09SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
557b08b09SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
65a83710eSEric Fiselier //
75a83710eSEric Fiselier //===----------------------------------------------------------------------===//
85a83710eSEric Fiselier 
95a83710eSEric Fiselier // <string>
105a83710eSEric Fiselier 
115a83710eSEric Fiselier // template<class charT, class traits, class Allocator>
12*425620ccSNikolas Klauser //   bool operator<(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs); // constexpr since C++20
135a83710eSEric Fiselier 
145a83710eSEric Fiselier #include <string>
155a83710eSEric Fiselier #include <cassert>
165a83710eSEric Fiselier 
177fc6a556SMarshall Clow #include "test_macros.h"
185a83710eSEric Fiselier #include "min_allocator.h"
195a83710eSEric Fiselier 
205a83710eSEric Fiselier template <class S>
2130046a31SNikolas Klauser TEST_CONSTEXPR_CXX20 void
test(const S & lhs,const typename S::value_type * rhs,bool x)225a83710eSEric Fiselier test(const S& lhs, const typename S::value_type* rhs, bool x)
235a83710eSEric Fiselier {
245a83710eSEric Fiselier     assert((lhs < rhs) == x);
255a83710eSEric Fiselier }
265a83710eSEric Fiselier 
test()27*425620ccSNikolas Klauser TEST_CONSTEXPR_CXX20 bool test() {
285a83710eSEric Fiselier   {
295a83710eSEric Fiselier     typedef std::string S;
305a83710eSEric Fiselier     test(S(""), "", false);
315a83710eSEric Fiselier     test(S(""), "abcde", true);
325a83710eSEric Fiselier     test(S(""), "abcdefghij", true);
335a83710eSEric Fiselier     test(S(""), "abcdefghijklmnopqrst", true);
345a83710eSEric Fiselier     test(S("abcde"), "", false);
355a83710eSEric Fiselier     test(S("abcde"), "abcde", false);
365a83710eSEric Fiselier     test(S("abcde"), "abcdefghij", true);
375a83710eSEric Fiselier     test(S("abcde"), "abcdefghijklmnopqrst", true);
385a83710eSEric Fiselier     test(S("abcdefghij"), "", false);
395a83710eSEric Fiselier     test(S("abcdefghij"), "abcde", false);
405a83710eSEric Fiselier     test(S("abcdefghij"), "abcdefghij", false);
415a83710eSEric Fiselier     test(S("abcdefghij"), "abcdefghijklmnopqrst", true);
425a83710eSEric Fiselier     test(S("abcdefghijklmnopqrst"), "", false);
435a83710eSEric Fiselier     test(S("abcdefghijklmnopqrst"), "abcde", false);
445a83710eSEric Fiselier     test(S("abcdefghijklmnopqrst"), "abcdefghij", false);
455a83710eSEric Fiselier     test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", false);
465a83710eSEric Fiselier   }
47f2f2a639SEric Fiselier #if TEST_STD_VER >= 11
485a83710eSEric Fiselier   {
495a83710eSEric Fiselier     typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
505a83710eSEric Fiselier     test(S(""), "", false);
515a83710eSEric Fiselier     test(S(""), "abcde", true);
525a83710eSEric Fiselier     test(S(""), "abcdefghij", true);
535a83710eSEric Fiselier     test(S(""), "abcdefghijklmnopqrst", true);
545a83710eSEric Fiselier     test(S("abcde"), "", false);
555a83710eSEric Fiselier     test(S("abcde"), "abcde", false);
565a83710eSEric Fiselier     test(S("abcde"), "abcdefghij", true);
575a83710eSEric Fiselier     test(S("abcde"), "abcdefghijklmnopqrst", true);
585a83710eSEric Fiselier     test(S("abcdefghij"), "", false);
595a83710eSEric Fiselier     test(S("abcdefghij"), "abcde", false);
605a83710eSEric Fiselier     test(S("abcdefghij"), "abcdefghij", false);
615a83710eSEric Fiselier     test(S("abcdefghij"), "abcdefghijklmnopqrst", true);
625a83710eSEric Fiselier     test(S("abcdefghijklmnopqrst"), "", false);
635a83710eSEric Fiselier     test(S("abcdefghijklmnopqrst"), "abcde", false);
645a83710eSEric Fiselier     test(S("abcdefghijklmnopqrst"), "abcdefghij", false);
655a83710eSEric Fiselier     test(S("abcdefghijklmnopqrst"), "abcdefghijklmnopqrst", false);
665a83710eSEric Fiselier   }
675a83710eSEric Fiselier #endif
682df59c50SJF Bastien 
6930046a31SNikolas Klauser   return true;
7030046a31SNikolas Klauser }
7130046a31SNikolas Klauser 
main(int,char **)7230046a31SNikolas Klauser int main(int, char**)
7330046a31SNikolas Klauser {
7430046a31SNikolas Klauser   test();
7530046a31SNikolas Klauser #if TEST_STD_VER > 17
76*425620ccSNikolas Klauser   static_assert(test());
7730046a31SNikolas Klauser #endif
7830046a31SNikolas Klauser 
792df59c50SJF Bastien   return 0;
805a83710eSEric Fiselier }
81