FTXUI/src/ftxui/dom/gauge_test.cpp

105 lines
2.1 KiB
C++
Raw Normal View History

#include <gtest/gtest-message.h> // for Message
#include <gtest/gtest-test-part.h> // for SuiteApiResolver, TestFactoryImpl, TestPartResult
2021-05-02 02:40:35 +08:00
#include <memory> // for allocator
2022-04-28 16:43:31 +08:00
#include "ftxui/dom/elements.hpp" // for gauge, gaugeUp
2022-01-07 18:03:54 +08:00
#include "ftxui/dom/node.hpp" // for Render
#include "ftxui/screen/screen.hpp" // for Screen
#include "gtest/gtest_pred_impl.h" // for Test, EXPECT_EQ, TEST
2022-04-17 21:47:20 +08:00
namespace ftxui {
TEST(GaugeTest, ZeroHorizontal) {
auto root = gauge(0);
2020-03-23 05:32:44 +08:00
Screen screen(11, 1);
Render(screen, root);
EXPECT_EQ(" ", screen.ToString());
}
TEST(GaugeTest, HalfHorizontal) {
auto root = gauge(0.5);
2020-03-23 05:32:44 +08:00
Screen screen(11, 1);
Render(screen, root);
2022-04-17 21:47:20 +08:00
#if defined(FTXUI_MICROSOFT_TERMINAL_FALLBACK)
EXPECT_EQ("█████▌ ", screen.ToString());
#else
EXPECT_EQ("█████▍ ", screen.ToString());
2022-04-17 21:47:20 +08:00
#endif
}
TEST(GaugeTest, OneHorizontal) {
auto root = gauge(1.0);
2020-03-23 05:32:44 +08:00
Screen screen(11, 1);
Render(screen, root);
EXPECT_EQ("███████████", screen.ToString());
}
TEST(GaugeTest, ZeroVertical) {
auto root = gaugeUp(0);
Screen screen(1, 11);
Render(screen, root);
EXPECT_EQ(
" \r\n"
" \r\n"
" \r\n"
" \r\n"
" \r\n"
" \r\n"
" \r\n"
" \r\n"
" \r\n"
" \r\n"
" ",
screen.ToString());
}
TEST(GaugeTest, HalfVertical) {
auto root = gaugeUp(0.5);
Screen screen(1, 11);
Render(screen, root);
EXPECT_EQ(
" \r\n"
" \r\n"
" \r\n"
" \r\n"
" \r\n"
"\r\n"
"\r\n"
"\r\n"
"\r\n"
"\r\n"
"",
screen.ToString());
}
TEST(GaugeTest, OneVertical) {
auto root = gaugeUp(1.0);
Screen screen(1, 11);
Render(screen, root);
EXPECT_EQ(
"\r\n"
"\r\n"
"\r\n"
"\r\n"
"\r\n"
"\r\n"
"\r\n"
"\r\n"
"\r\n"
"\r\n"
"",
screen.ToString());
}
2022-04-17 21:47:20 +08:00
} // namespace ftxui
// Copyright 2020 Arthur Sonzogni. All rights reserved.
// Use of this source code is governed by the MIT license that can be found in
// the LICENSE file.