Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cassert>
- #include <iostream>
- #include <sstream>
- #include <string>
- void print_something() {
- std::cout << "something: " << 123 << std::endl;
- }
- int main() {
- // Zapisujemy stary bufor std::cout
- std::streambuf* cout_buffer = std::cout.rdbuf();
- // Dodajemy nowy bufor
- std::stringbuf test_buffer;
- std::cout.rdbuf(&test_buffer);
- // Drukujemy
- print_something();
- // Sprawdzamy poprawność
- assert(test_buffer.str() == "something: 123\n");
- // Oddajemy stary bufor
- std::cout.rdbuf(cout_buffer);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement