utempl/tests/menu.cpp

24 lines
547 B
C++
Raw Normal View History

2024-07-31 02:19:28 +00:00
module;
2024-02-27 22:35:29 +00:00
#include <gtest/gtest.h>
2024-07-31 02:19:28 +00:00
export module tests.menu;
import utempl.menu;
2024-02-27 22:35:29 +00:00
namespace utempl {
TEST(Menu, Basic) {
testing::internal::CaptureStdout();
std::istringstream stream("t\n");
int value = 0;
menu::Menu{}
2024-07-31 02:19:28 +00:00
.With<{"t", "This is t"}>([&] {
std::cout << "Success!" << std::endl;
value = 1;
})
.Run<"[{0}]{2} - ({1})\n">(stream);
2024-02-27 22:35:29 +00:00
auto captured = testing::internal::GetCapturedStdout();
EXPECT_EQ(captured, "[t] - (This is t)\n|> Success!\n");
EXPECT_EQ(value, 1);
};
2024-07-31 02:19:28 +00:00
} // namespace utempl