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