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>
125a83710eSEric Fiselier //   basic_string<charT,traits,Allocator>
13*425620ccSNikolas Klauser //   operator+(const basic_string<charT,traits,Allocator>& lhs, charT rhs); // constexpr since C++20
145a83710eSEric Fiselier 
155a83710eSEric Fiselier // template<class charT, class traits, class Allocator>
165a83710eSEric Fiselier //   basic_string<charT,traits,Allocator>&&
17*425620ccSNikolas Klauser //   operator+(basic_string<charT,traits,Allocator>&& lhs, charT rhs); // constexpr since C++20
185a83710eSEric Fiselier 
195a83710eSEric Fiselier #include <string>
20e21582e7SMarshall Clow #include <utility>
215a83710eSEric Fiselier #include <cassert>
225a83710eSEric Fiselier 
23414d17c6SEric Fiselier #include "test_macros.h"
245a83710eSEric Fiselier #include "min_allocator.h"
255a83710eSEric Fiselier 
265a83710eSEric Fiselier template <class S>
test0(const S & lhs,typename S::value_type rhs,const S & x)2730046a31SNikolas Klauser TEST_CONSTEXPR_CXX20 void test0(const S& lhs, typename S::value_type rhs, const S& x) {
285a83710eSEric Fiselier   assert(lhs + rhs == x);
295a83710eSEric Fiselier }
305a83710eSEric Fiselier 
31414d17c6SEric Fiselier #if TEST_STD_VER >= 11
325a83710eSEric Fiselier template <class S>
test1(S && lhs,typename S::value_type rhs,const S & x)3330046a31SNikolas Klauser TEST_CONSTEXPR_CXX20 void test1(S&& lhs, typename S::value_type rhs, const S& x) {
3478533711SArthur O'Dwyer   assert(std::move(lhs) + rhs == x);
355a83710eSEric Fiselier }
36414d17c6SEric Fiselier #endif
375a83710eSEric Fiselier 
test()38*425620ccSNikolas Klauser TEST_CONSTEXPR_CXX20 bool test() {
395a83710eSEric Fiselier   {
405a83710eSEric Fiselier     typedef std::string S;
415a83710eSEric Fiselier     test0(S(""), '1', S("1"));
425a83710eSEric Fiselier     test0(S("abcde"), '1', S("abcde1"));
435a83710eSEric Fiselier     test0(S("abcdefghij"), '1', S("abcdefghij1"));
445a83710eSEric Fiselier     test0(S("abcdefghijklmnopqrst"), '1', S("abcdefghijklmnopqrst1"));
45414d17c6SEric Fiselier   }
46414d17c6SEric Fiselier #if TEST_STD_VER >= 11
47414d17c6SEric Fiselier   {
48414d17c6SEric Fiselier     typedef std::string S;
495a83710eSEric Fiselier     test1(S(""), '1', S("1"));
505a83710eSEric Fiselier     test1(S("abcde"), '1', S("abcde1"));
515a83710eSEric Fiselier     test1(S("abcdefghij"), '1', S("abcdefghij1"));
525a83710eSEric Fiselier     test1(S("abcdefghijklmnopqrst"), '1', S("abcdefghijklmnopqrst1"));
535a83710eSEric Fiselier   }
545a83710eSEric Fiselier   {
55414d17c6SEric Fiselier     typedef std::basic_string<char, std::char_traits<char>,
56414d17c6SEric Fiselier                               min_allocator<char> >
57414d17c6SEric Fiselier         S;
585a83710eSEric Fiselier     test0(S(""), '1', S("1"));
595a83710eSEric Fiselier     test0(S("abcde"), '1', S("abcde1"));
605a83710eSEric Fiselier     test0(S("abcdefghij"), '1', S("abcdefghij1"));
615a83710eSEric Fiselier     test0(S("abcdefghijklmnopqrst"), '1', S("abcdefghijklmnopqrst1"));
625a83710eSEric Fiselier 
635a83710eSEric Fiselier     test1(S(""), '1', S("1"));
645a83710eSEric Fiselier     test1(S("abcde"), '1', S("abcde1"));
655a83710eSEric Fiselier     test1(S("abcdefghij"), '1', S("abcdefghij1"));
665a83710eSEric Fiselier     test1(S("abcdefghijklmnopqrst"), '1', S("abcdefghijklmnopqrst1"));
675a83710eSEric Fiselier   }
685a83710eSEric Fiselier #endif
692df59c50SJF Bastien 
7030046a31SNikolas Klauser   return true;
7130046a31SNikolas Klauser }
7230046a31SNikolas Klauser 
main(int,char **)7330046a31SNikolas Klauser int main(int, char**) {
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