execute IWYU and add some coverage tests.

This commit is contained in:
ArthurSonzogni
2022-04-27 18:57:48 +02:00
parent 84d6e6b3dd
commit d0890f94d1
20 changed files with 124 additions and 96 deletions

View File

@@ -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.