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