char.pass.cpp (1237B)
1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // <string> 11 12 // basic_string<charT,traits,Allocator>& operator+=(charT c); 13 14 #include <string> 15 #include <cassert> 16 17 #include "test_macros.h" 18 #include "min_allocator.h" 19 20 template <class S> 21 void 22 test(S s, typename S::value_type str, S expected) 23 { 24 s += str; 25 LIBCPP_ASSERT(s.__invariants()); 26 assert(s == expected); 27 } 28 29 int main() 30 { 31 { 32 typedef std::string S; 33 test(S(), 'a', S("a")); 34 test(S("12345"), 'a', S("12345a")); 35 test(S("1234567890"), 'a', S("1234567890a")); 36 test(S("12345678901234567890"), 'a', S("12345678901234567890a")); 37 } 38 #if TEST_STD_VER >= 11 39 { 40 typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S; 41 test(S(), 'a', S("a")); 42 test(S("12345"), 'a', S("12345a")); 43 test(S("1234567890"), 'a', S("1234567890a")); 44 test(S("12345678901234567890"), 'a', S("12345678901234567890a")); 45 } 46 #endif 47 }