mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-11 05:23:29 -04:00
chore: support using real terminal in test_iolayer
This commit is contained in:
parent
3dbe63b7df
commit
f3b8dc29e4
@ -240,6 +240,7 @@ class test_iolayer {
|
|||||||
std::string out() const;
|
std::string out() const;
|
||||||
std::string err() const;
|
std::string err() const;
|
||||||
|
|
||||||
|
void use_real_terminal(bool use);
|
||||||
void set_in(std::string in);
|
void set_in(std::string in);
|
||||||
void set_terminal_fancy(bool fancy);
|
void set_terminal_fancy(bool fancy);
|
||||||
void set_terminal_width(size_t width);
|
void set_terminal_width(size_t width);
|
||||||
@ -259,6 +260,7 @@ class test_iolayer {
|
|||||||
std::ostringstream out_;
|
std::ostringstream out_;
|
||||||
std::ostringstream err_;
|
std::ostringstream err_;
|
||||||
std::unique_ptr<iolayer> iol_;
|
std::unique_ptr<iolayer> iol_;
|
||||||
|
std::shared_ptr<terminal const> real_term_;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern std::map<std::string, simplestat> statmap;
|
extern std::map<std::string, simplestat> statmap;
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
#include <fmt/format.h>
|
#include <fmt/format.h>
|
||||||
|
|
||||||
@ -316,6 +317,16 @@ test_iolayer::~test_iolayer() = default;
|
|||||||
|
|
||||||
iolayer const& test_iolayer::get() {
|
iolayer const& test_iolayer::get() {
|
||||||
if (!iol_) {
|
if (!iol_) {
|
||||||
|
if (real_term_) {
|
||||||
|
iol_ = std::make_unique<iolayer>(iolayer{
|
||||||
|
.os = os_,
|
||||||
|
.term = real_term_,
|
||||||
|
.file = fa_,
|
||||||
|
.in = std::cin,
|
||||||
|
.out = std::cout,
|
||||||
|
.err = std::cerr,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
iol_ = std::make_unique<iolayer>(iolayer{
|
iol_ = std::make_unique<iolayer>(iolayer{
|
||||||
.os = os_,
|
.os = os_,
|
||||||
.term = term_,
|
.term = term_,
|
||||||
@ -325,9 +336,14 @@ iolayer const& test_iolayer::get() {
|
|||||||
.err = err_,
|
.err = err_,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return *iol_;
|
return *iol_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void test_iolayer::use_real_terminal(bool use) {
|
||||||
|
real_term_ = terminal::create();
|
||||||
|
}
|
||||||
|
|
||||||
void test_iolayer::set_terminal_fancy(bool fancy) { term_->set_fancy(fancy); }
|
void test_iolayer::set_terminal_fancy(bool fancy) { term_->set_fancy(fancy); }
|
||||||
void test_iolayer::set_terminal_width(size_t width) { term_->set_width(width); }
|
void test_iolayer::set_terminal_width(size_t width) { term_->set_width(width); }
|
||||||
void test_iolayer::set_in(std::string in) { in_.str(std::move(in)); }
|
void test_iolayer::set_in(std::string in) { in_.str(std::move(in)); }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user