mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-09-22 20:58:10 +08:00
execute IWYU and add some coverage tests.
This commit is contained in:
@@ -43,6 +43,53 @@ TEST(MenuTest, RemoveEntries) {
|
||||
EXPECT_EQ(focused_entry, 1);
|
||||
}
|
||||
|
||||
TEST(MenuTest, Directions) {
|
||||
int selected = 0;
|
||||
std::vector<std::string> entries = {"1", "2", "3"};
|
||||
MenuOption option;
|
||||
auto menu = Menu(&entries, &selected, &option);
|
||||
|
||||
{
|
||||
option.direction = MenuOption::Down;
|
||||
Screen screen(4, 3);
|
||||
Render(screen, menu->Render());
|
||||
EXPECT_EQ(screen.ToString(),
|
||||
"\x1B[1m\x1B[7m> 1 \x1B[22m\x1B[27m\r\n"
|
||||
" 2 \r\n"
|
||||
" 3 ");
|
||||
}
|
||||
|
||||
{
|
||||
option.direction = MenuOption::Up;
|
||||
Screen screen(4, 3);
|
||||
Render(screen, menu->Render());
|
||||
EXPECT_EQ(screen.ToString(),
|
||||
" 3 \r\n"
|
||||
" 2 \r\n"
|
||||
"\x1B[1m\x1B[7m> 1 \x1B[22m\x1B[27m");
|
||||
}
|
||||
|
||||
{
|
||||
option.direction = MenuOption::Right;
|
||||
Screen screen(10, 1);
|
||||
Render(screen, menu->Render());
|
||||
EXPECT_EQ(screen.ToString(),
|
||||
"\x1B[1m\x1B[7m> 1\x1B[22m\x1B[27m"
|
||||
" 2"
|
||||
" 3 ");
|
||||
}
|
||||
|
||||
{
|
||||
option.direction = MenuOption::Left;
|
||||
Screen screen(10, 1);
|
||||
Render(screen, menu->Render());
|
||||
EXPECT_EQ(screen.ToString(),
|
||||
" 3"
|
||||
" 2"
|
||||
"\x1B[1m\x1B[7m> 1\x1B[22m\x1B[27m ");
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace ftxui
|
||||
|
||||
// Copyright 2022 Arthur Sonzogni. All rights reserved.
|
||||
|
Reference in New Issue
Block a user