srctree

Robin Linden parent 72646749 631faa2b
tui: Set up a basic sanity-check test

inlinesplit
tui/BUILD added: 45, removed: 3, total 42
@@ -1,4 +1,4 @@
load("@rules_cc//cc:defs.bzl", "cc_library")
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
load("//bzl:copts.bzl", "HASTUR_COPTS")
 
cc_library(
@@ -13,3 +13,18 @@ cc_library(
"@spdlog",
],
)
 
cc_test(
name = "tui_test",
size = "small",
srcs = ["tui_test.cpp"],
copts = HASTUR_COPTS,
deps = [
":tui",
"//dom",
"//etest",
"//layout",
"//style",
"//util:string",
],
)
 
filename was Deleted added: 45, removed: 3, total 42
@@ -0,0 +1,27 @@
// SPDX-FileCopyrightText: 2023 Robin Lindén <dev@robinlinden.eu>
//
// SPDX-License-Identifier: BSD-2-Clause
 
#include "tui/tui.h"
 
#include "dom/dom.h"
#include "etest/etest2.h"
#include "layout/layout.h"
#include "style/style.h"
#include "util/string.h"
 
// There will be some bonus util::trim calls in these tests for now as FTXUI
// adds a lot of whitespace around the rendered layout.
int main() {
etest::Suite s{"tui"};
 
s.add_test("Text in block", [](etest::IActions &a) {
dom::Node dom{dom::Element{"div", {}, {dom::Text{"Hello, world!"}}}};
auto style = style::style_tree(dom, {{css::Rule{{"div"}, {{css::PropertyId::Display, "block"}}}}});
auto layout = layout::create_layout(*style, 9000);
auto rendered = tui::render(layout.value());
a.expect_eq(util::trim(rendered), "Hello, world!");
});
 
return s.run();
}