Gauge direction (#326)

Add `gauge` with all the different directions.

Co-authored-by: Aleksandar Brakmic <13668697+brakmic-aleksandar@users.noreply.github.com>
This commit is contained in:
Arthur Sonzogni
2022-02-06 19:17:21 +01:00
committed by GitHub
parent 7c3ca1beb5
commit 8ba3698437
7 changed files with 369 additions and 19 deletions

View File

@@ -11,7 +11,7 @@
using namespace ftxui;
using namespace ftxui;
TEST(GaugeTest, zero) {
TEST(GaugeTest, ZeroHorizontal) {
auto root = gauge(0);
Screen screen(11, 1);
Render(screen, root);
@@ -19,16 +19,15 @@ TEST(GaugeTest, zero) {
EXPECT_EQ(" ", screen.ToString());
}
TEST(GaugeTest, half) {
TEST(GaugeTest, HalfHorizontal) {
auto root = gauge(0.5);
Screen screen(11, 1);
Render(screen, root);
EXPECT_EQ("█████▍ ", screen.ToString());
//" ▏▎▍▌▊▉█";
}
TEST(GaugeTest, one) {
TEST(GaugeTest, OneHorizontal) {
auto root = gauge(1.0);
Screen screen(11, 1);
Render(screen, root);
@@ -36,6 +35,66 @@ TEST(GaugeTest, one) {
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());
}
// 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.