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 charT* lhs, const basic_string<charT,traits,Allocator>& 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 typename S::value_type * lhs,const S & rhs,bool x)225a83710eSEric Fiselier test(const typename S::value_type* lhs, const S& 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"), false);
325a83710eSEric Fiselier test("", S("abcdefghij"), false);
335a83710eSEric Fiselier test("", S("abcdefghijklmnopqrst"), false);
345a83710eSEric Fiselier test("abcde", S(""), true);
355a83710eSEric Fiselier test("abcde", S("abcde"), false);
365a83710eSEric Fiselier test("abcde", S("abcdefghij"), false);
375a83710eSEric Fiselier test("abcde", S("abcdefghijklmnopqrst"), false);
385a83710eSEric Fiselier test("abcdefghij", S(""), true);
395a83710eSEric Fiselier test("abcdefghij", S("abcde"), true);
405a83710eSEric Fiselier test("abcdefghij", S("abcdefghij"), false);
415a83710eSEric Fiselier test("abcdefghij", S("abcdefghijklmnopqrst"), false);
425a83710eSEric Fiselier test("abcdefghijklmnopqrst", S(""), true);
435a83710eSEric Fiselier test("abcdefghijklmnopqrst", S("abcde"), true);
445a83710eSEric Fiselier test("abcdefghijklmnopqrst", S("abcdefghij"), true);
455a83710eSEric Fiselier test("abcdefghijklmnopqrst", S("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"), false);
525a83710eSEric Fiselier test("", S("abcdefghij"), false);
535a83710eSEric Fiselier test("", S("abcdefghijklmnopqrst"), false);
545a83710eSEric Fiselier test("abcde", S(""), true);
555a83710eSEric Fiselier test("abcde", S("abcde"), false);
565a83710eSEric Fiselier test("abcde", S("abcdefghij"), false);
575a83710eSEric Fiselier test("abcde", S("abcdefghijklmnopqrst"), false);
585a83710eSEric Fiselier test("abcdefghij", S(""), true);
595a83710eSEric Fiselier test("abcdefghij", S("abcde"), true);
605a83710eSEric Fiselier test("abcdefghij", S("abcdefghij"), false);
615a83710eSEric Fiselier test("abcdefghij", S("abcdefghijklmnopqrst"), false);
625a83710eSEric Fiselier test("abcdefghijklmnopqrst", S(""), true);
635a83710eSEric Fiselier test("abcdefghijklmnopqrst", S("abcde"), true);
645a83710eSEric Fiselier test("abcdefghijklmnopqrst", S("abcdefghij"), true);
655a83710eSEric Fiselier test("abcdefghijklmnopqrst", S("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