Home | History | Annotate | Download | only in streambuf.put.area
      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 // <streambuf>
     11 
     12 // template <class charT, class traits = char_traits<charT> >
     13 // class basic_streambuf;
     14 
     15 // void pbump(int n);
     16 //
     17 // REQUIRES: long_tests
     18 
     19 // This test allocates 4GiB of 'a', which is not possible on a typical mobile
     20 // device.
     21 // UNSUPPORTED: android
     22 
     23 #include <sstream>
     24 #include <cassert>
     25 #include "test_macros.h"
     26 
     27 struct SB : std::stringbuf
     28 {
     29   SB() : std::stringbuf(std::ios::ate|std::ios::out) { }
     30   const char* pubpbase() const { return pbase(); }
     31   const char* pubpptr() const { return pptr(); }
     32 };
     33 
     34 int main()
     35 {
     36 #ifndef TEST_HAS_NO_EXCEPTIONS
     37     try {
     38 #endif
     39     	std::string str(2147483648, 'a');
     40 		SB sb;
     41 		sb.str(str);
     42 		assert(sb.pubpbase() <= sb.pubpptr());
     43 #ifndef TEST_HAS_NO_EXCEPTIONS
     44 	}
     45 	catch (const std::bad_alloc &) {}
     46 #endif
     47 }
     48