mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2024-11-29 14:45:53 +08:00
53 lines
1.3 KiB
C++
53 lines
1.3 KiB
C++
|
#include <gtest/gtest-message.h> // for Message
|
||
|
#include <gtest/gtest-test-part.h> // for TestPartResult
|
||
|
#include <csignal>
|
||
|
|
||
|
#include "ftxui/component/component.hpp"
|
||
|
#include "ftxui/component/screen_interactive.hpp"
|
||
|
#include "ftxui/dom/elements.hpp"
|
||
|
#include "gtest/gtest_pred_impl.h" // for AssertionResult, Test, EXPECT_EQ
|
||
|
|
||
|
using namespace ftxui;
|
||
|
|
||
|
namespace {
|
||
|
bool TestSignal(int signal) {
|
||
|
int called = 0;
|
||
|
// The tree of components. This defines how to navigate using the keyboard.
|
||
|
auto component = Renderer([&] {
|
||
|
called++;
|
||
|
std::raise(signal);
|
||
|
called++;
|
||
|
return text(L"");
|
||
|
});
|
||
|
|
||
|
auto screen = ScreenInteractive::FitComponent();
|
||
|
screen.Loop(component);
|
||
|
|
||
|
EXPECT_EQ(called, 2);
|
||
|
return true;
|
||
|
}
|
||
|
} // namespace
|
||
|
|
||
|
TEST(ScreenInteractive, Signal_SIGTERM) {
|
||
|
TestSignal(SIGTERM);
|
||
|
}
|
||
|
TEST(ScreenInteractive, Signal_SIGSEGV) {
|
||
|
TestSignal(SIGSEGV);
|
||
|
}
|
||
|
TEST(ScreenInteractive, Signal_SIGINT) {
|
||
|
TestSignal(SIGINT);
|
||
|
}
|
||
|
TEST(ScreenInteractive, Signal_SIGILL) {
|
||
|
TestSignal(SIGILL);
|
||
|
}
|
||
|
TEST(ScreenInteractive, Signal_SIGABRT) {
|
||
|
TestSignal(SIGABRT);
|
||
|
}
|
||
|
TEST(ScreenInteractive, Signal_SIGFPE) {
|
||
|
TestSignal(SIGFPE);
|
||
|
}
|
||
|
|
||
|
// Copyright 2021 Arthur Sonzogni. All rights reserved.
|
||
|
// Use of this source code is governed by the MIT license that can be found in
|
||
|
// the LICENSE file.
|