2022-10-03 11:08:39 +02:00
|
|
|
#define CATCH_CONFIG_MAIN
|
|
|
|
#include <catch2/catch_all.hpp>
|
2020-04-23 16:02:12 +02:00
|
|
|
#include <cstdio>
|
2023-12-22 20:42:21 +01:00
|
|
|
#include <iostream>
|
|
|
|
#include <util/io-redirector.h>
|
2020-04-23 16:02:12 +02:00
|
|
|
|
2023-12-22 20:42:21 +01:00
|
|
|
TEST_CASE("io-redirector", "[io-redirector]") {
|
2022-09-30 15:21:01 +02:00
|
|
|
util::IoRedirector::get().start();
|
|
|
|
auto result1 = util::IoRedirector::get().get_output();
|
2020-04-23 16:02:12 +02:00
|
|
|
printf("Some output");
|
2023-12-22 20:42:21 +01:00
|
|
|
std::cout << "Some other output" << std::endl;
|
2022-09-30 15:21:01 +02:00
|
|
|
auto result2 = util::IoRedirector::get().get_output();
|
|
|
|
util::IoRedirector::get().stop();
|
2022-10-03 11:08:39 +02:00
|
|
|
|
2023-12-22 20:42:21 +01:00
|
|
|
REQUIRE(result1 == "");
|
|
|
|
REQUIRE(result2 == "Some outputSome other output\n");
|
2020-04-23 16:02:12 +02:00
|
|
|
}
|