~singpolyma/biboumi

ref: 0bb4f144fcded6b5753b5de7493b7b10474c9a1f biboumi/tests/io_tester.cpp -rw-r--r-- 478 bytes
0bb4f144 — Félix Baylac-Jacqué CLI: Add a test config flag 2 years ago
                                                                                
6430479a Florent Le Coz
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include "io_tester.hpp"
#include "catch.hpp"
#include <iostream>

/**
 * Directly test this class here
 */
TEST_CASE()
{
  {
    IoTester<std::ostream> out(std::cout);
    std::cout << "test";
    CHECK(out.str() == "test");
  }
  {
    IoTester<std::ostream> out(std::cout);
    CHECK(out.str().empty());
  }
}

TEST_CASE()
{
  {
    IoTester<std::istream> is(std::cin);
    is.set_string("coucou");
    std::string res;
    std::cin >> res;
    CHECK(res == "coucou");
  }
}