2021-12-12 00:58:25 +08:00
|
|
|
#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-01-07 18:03:54 +08:00
|
|
|
#include "ftxui/dom/elements.hpp" // for gauge
|
|
|
|
#include "ftxui/dom/node.hpp" // for Render
|
|
|
|
#include "ftxui/screen/color.hpp" // for ftxui
|
|
|
|
#include "ftxui/screen/screen.hpp" // for Screen
|
|
|
|
#include "gtest/gtest_pred_impl.h" // for Test, EXPECT_EQ, TEST
|
2018-10-10 01:06:03 +08:00
|
|
|
|
2019-01-12 22:00:08 +08:00
|
|
|
using namespace ftxui;
|
|
|
|
using namespace ftxui;
|
2018-10-10 01:06:03 +08:00
|
|
|
|
|
|
|
TEST(GaugeTest, zero) {
|
|
|
|
auto root = gauge(0);
|
2020-03-23 05:32:44 +08:00
|
|
|
Screen screen(11, 1);
|
2020-05-21 03:23:59 +08:00
|
|
|
Render(screen, root);
|
2018-10-10 01:06:03 +08:00
|
|
|
|
|
|
|
EXPECT_EQ(" ", screen.ToString());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(GaugeTest, half) {
|
|
|
|
auto root = gauge(0.5);
|
2020-03-23 05:32:44 +08:00
|
|
|
Screen screen(11, 1);
|
2020-05-21 03:23:59 +08:00
|
|
|
Render(screen, root);
|
2018-10-10 01:06:03 +08:00
|
|
|
|
2019-01-06 23:10:57 +08:00
|
|
|
EXPECT_EQ("█████▍ ", screen.ToString());
|
|
|
|
//" ▏▎▍▌▊▉█";
|
2018-10-10 01:06:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(GaugeTest, one) {
|
|
|
|
auto root = gauge(1.0);
|
2020-03-23 05:32:44 +08:00
|
|
|
Screen screen(11, 1);
|
2020-05-21 03:23:59 +08:00
|
|
|
Render(screen, root);
|
2018-10-10 01:06:03 +08:00
|
|
|
|
|
|
|
EXPECT_EQ("███████████", screen.ToString());
|
|
|
|
}
|
2020-08-16 06:24:18 +08:00
|
|
|
|
|
|
|
// 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.
|