From 92b3c2dcff3e85ad3d455f6ab845d9a97d3b525b Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Mon, 7 Dec 2020 12:22:15 +0200 Subject: Rewrite meson build scripts into cmakelists --- lib/configuration/test/qt.cpp | 71 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 lib/configuration/test/qt.cpp (limited to 'lib/configuration/test/qt.cpp') diff --git a/lib/configuration/test/qt.cpp b/lib/configuration/test/qt.cpp new file mode 100644 index 0000000..44114df --- /dev/null +++ b/lib/configuration/test/qt.cpp @@ -0,0 +1,71 @@ +// clazy:excludeall=non-pod-global-static +#define CATCH_CONFIG_RUNNER + +#include "configuration.h" +#include +#include + +SCENARIO("Configuration") +{ + GIVEN("a Configuration object with some initial values") + { + Configuration conf{ + { "name", std::string() }, + { "over", std::string() }, + // this entry is not in the conf file + { "other", std::string("not in cfg") }, + // commented out entry in the conf file + { "comment", std::string("123.456") }, + { "number", 0 }, + { "toggle", false }, + + { "main/name", std::string() }, + { "main/number", 0 }, + { "main/toggle", true }, + + { "extra/name", std::string() }, + { "extra/number", 0 }, + { "extra/toggle", false }, + }; + + WHEN("reading default values") + { + } + + WHEN("reading configuration file") + { + conf.read_file(std::getenv("CONFIGFILE")); + + THEN("Qt cast specialization") + { + REQUIRE(conf.value("name").value() == "Top level"); + REQUIRE(conf.value("number").value() == "12"); + REQUIRE(conf.value("toggle").value() == "true"); + REQUIRE(conf.value("main/toggle").value() == "false"); + REQUIRE(!conf.value("nullopt")); + + REQUIRE(conf.value("list").value() == QStringList({ "one", "two", "three", "for four" })); + REQUIRE(!conf.value("nullopt")); + } + + THEN("Qt shortcut") + { + REQUIRE(conf.value("qt/shortcut") == "Ctrl+Q"); + QAction action; + REQUIRE(conf.shortcut(action, "qt/shortcut").shortcut().toString() == "Ctrl+Q"); + REQUIRE(conf.shortcut(action, "qt/nil").shortcut().toString() == "Ctrl+Q"); + + QKeySequence sequence; + REQUIRE(conf.shortcut(sequence, "qt/shortcut").toString() == "Ctrl+Q"); + REQUIRE(conf.shortcut(sequence, "qt/nil").toString() == "Ctrl+Q"); + } + } + } +} + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + int result = Catch::Session().run(argc, argv); + return result; +} -- cgit v1.2.1