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 // <strstream> 11 12 // class strstreambuf 13 14 // int_type overflow(int_type c = EOF); 15 16 #include <strstream> 17 #include <cassert> 18 19 int main() 20 { 21 { 22 char buf[12] = "abc"; 23 std::strstreambuf sb(buf, sizeof(buf), buf); 24 assert(sb.sputc('1') == '1'); 25 assert(sb.str() == std::string("1bc")); 26 assert(sb.sputc('2') == '2'); 27 assert(sb.str() == std::string("12c")); 28 assert(sb.sputc('3') == '3'); 29 assert(sb.str() == std::string("123")); 30 assert(sb.sputc('4') == '4'); 31 assert(sb.str() == std::string("1234")); 32 assert(sb.sputc('5') == '5'); 33 assert(sb.str() == std::string("12345")); 34 assert(sb.sputc('6') == '6'); 35 assert(sb.str() == std::string("123456")); 36 assert(sb.sputc('7') == '7'); 37 assert(sb.str() == std::string("1234567")); 38 assert(sb.sputc('8') == '8'); 39 assert(sb.str() == std::string("12345678")); 40 assert(sb.sputc('9') == '9'); 41 assert(sb.str() == std::string("123456789")); 42 assert(sb.sputc('0') == '0'); 43 assert(sb.str() == std::string("1234567890")); 44 assert(sb.sputc('1') == '1'); 45 assert(sb.str() == std::string("12345678901")); 46 } 47 } 48