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 // <streambuf> 10 11 // template <class charT, class traits = char_traits<charT> > 12 // class basic_streambuf; 13 14 // void pbump(int n); 15 // 16 // REQUIRES: long_tests 17 18 #include <sstream> 19 #include <cassert> 20 #include "test_macros.h" 21 22 struct SB : std::stringbuf 23 { SBSB24 SB() : std::stringbuf(std::ios::ate|std::ios::out) { } pubpbaseSB25 const char* pubpbase() const { return pbase(); } pubpptrSB26 const char* pubpptr() const { return pptr(); } 27 }; 28 main(int,char **)29int main(int, char**) 30 { 31 #ifndef TEST_HAS_NO_EXCEPTIONS 32 try { 33 #endif 34 std::string str(2147483648, 'a'); 35 SB sb; 36 sb.str(str); 37 assert(sb.pubpbase() <= sb.pubpptr()); 38 #ifndef TEST_HAS_NO_EXCEPTIONS 39 } 40 catch (const std::length_error &) {} // maybe the string can't take 2GB 41 catch (const std::bad_alloc &) {} // maybe we don't have enough RAM 42 #endif 43 44 return 0; 45 } 46