aboutsummaryrefslogtreecommitdiff
path: root/source/tests
diff options
context:
space:
mode:
Diffstat (limited to 'source/tests')
-rw-r--r--source/tests/CMakeLists.txt4
-rw-r--r--source/tests/app/wandac/CMakeLists.txt11
-rw-r--r--source/tests/app/wandac/src/cli.cpp80
-rw-r--r--source/tests/lib/system/CMakeLists.txt11
-rw-r--r--source/tests/lib/system/src/xdg.cpp171
5 files changed, 0 insertions, 277 deletions
diff --git a/source/tests/CMakeLists.txt b/source/tests/CMakeLists.txt
deleted file mode 100644
index 07b922b..0000000
--- a/source/tests/CMakeLists.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-include("Catch")
-
-add_subdirectory("app/wandac")
-add_subdirectory("lib/system") \ No newline at end of file
diff --git a/source/tests/app/wandac/CMakeLists.txt b/source/tests/app/wandac/CMakeLists.txt
deleted file mode 100644
index ab07030..0000000
--- a/source/tests/app/wandac/CMakeLists.txt
+++ /dev/null
@@ -1,11 +0,0 @@
-add_executable("wanda-tests-wandac"
- "src/cli.cpp"
-)
-
-target_link_libraries("wanda-tests-wandac" PRIVATE
- "${PROJECT_NAME}c-components"
-
- "Catch2::Catch2WithMain"
-)
-
-catch_discover_tests("wanda-tests-wandac") \ No newline at end of file
diff --git a/source/tests/app/wandac/src/cli.cpp b/source/tests/app/wandac/src/cli.cpp
deleted file mode 100644
index ed02b4a..0000000
--- a/source/tests/app/wandac/src/cli.cpp
+++ /dev/null
@@ -1,80 +0,0 @@
-#include "wandac/cli.hpp"
-
-#include <catch2/catch_all.hpp>
-#include <catch2/catch_test_macros.hpp>
-#include <lyra/args.hpp>
-
-#include <sstream>
-#include <string>
-
-using namespace std::string_literals;
-
-namespace wanda::tests::app::wandac
-{
-
- template<typename ...Ts>
- auto make_argument_list(Ts const & ... args) -> lyra::args
- {
- return {"wanda"s, static_cast<std::string>(args)...};
- }
-
- SCENARIO("Empty argument list parsing", "[app][client][cli]")
- {
- GIVEN("A fresh cli instance and error stream")
- {
- auto cli = ::wandac::cli{};
- auto error_stream = std::ostringstream{};
-
- WHEN("invoking parse without any program arguments")
- {
- auto result = cli.parse(make_argument_list(), error_stream);
-
- THEN("the return value is false") { REQUIRE_FALSE(result); }
- THEN("the error stream is not empty") { REQUIRE_FALSE(error_stream.view().empty()); }
- THEN("the help flag is not set") { REQUIRE_FALSE(cli.help); }
- THEN("the command is empty") { REQUIRE(cli.command.empty()); }
- }
- }
- }
-
- SCENARIO("Valid argument list parsing", "[app][client][cli]")
- {
- GIVEN("A fresh cli instance and error stream")
- {
- auto cli = ::wandac::cli{};
- auto error_stream = std::ostringstream{};
-
- AND_GIVEN("'-h' in the argument list")
- {
- auto argument_list = make_argument_list("-h");
-
- WHEN("invoking parse without additional arguments")
- {
- auto result = cli.parse(argument_list, error_stream);
-
- THEN("the return value is true") { REQUIRE(result); }
- THEN("the error stream is empty") { REQUIRE(error_stream.view().empty()); }
- THEN("the help flag is set") { REQUIRE(cli.help); }
- THEN("the command is empty") { REQUIRE(cli.command.empty()); }
- }
- }
-
- AND_GIVEN("'change' in the argument list")
- {
- auto argument_list = make_argument_list("change");
-
- WHEN("invoking parse without additional arguments")
- {
- auto result = cli.parse(argument_list, error_stream);
-
- THEN("the return valis is true") { REQUIRE(result); }
- THEN("the error stream is empty") { REQUIRE(error_stream.view().empty()); }
- THEN("the help flag is not set") { REQUIRE_FALSE(cli.help); }
- THEN("the command is not empty") { REQUIRE_FALSE(cli.command.empty()); }
- THEN("the command is 'change'") { REQUIRE(cli.command == "change"); }
- }
- }
- }
- }
-
-} // namespace wanda::tests::app::wandac
diff --git a/source/tests/lib/system/CMakeLists.txt b/source/tests/lib/system/CMakeLists.txt
deleted file mode 100644
index a33c495..0000000
--- a/source/tests/lib/system/CMakeLists.txt
+++ /dev/null
@@ -1,11 +0,0 @@
-add_executable("wanda-tests-system"
- "src/xdg.cpp"
-)
-
-target_link_libraries("wanda-tests-system" PRIVATE
- "wanda::system"
-
- "Catch2::Catch2WithMain"
-)
-
-catch_discover_tests("wanda-tests-system") \ No newline at end of file
diff --git a/source/tests/lib/system/src/xdg.cpp b/source/tests/lib/system/src/xdg.cpp
deleted file mode 100644
index 5872dc6..0000000
--- a/source/tests/lib/system/src/xdg.cpp
+++ /dev/null
@@ -1,171 +0,0 @@
-#include "wanda/system/xdg.hpp"
-
-#include "wanda/system/environment.hpp"
-
-#include <catch2/catch_all.hpp>
-#include <unistd.h>
-
-#include <filesystem>
-#include <string>
-#include <utility>
-
-using namespace std::string_literals;
-
-namespace wanda::system::test
-{
-
- TEST_CASE("XDG variable names match the specification", "[system][xdg][spec]")
- {
- REQUIRE(xdg_variable(xdg_directory::data_home) == "XDG_DATA_HOME");
- REQUIRE(xdg_variable(xdg_directory::config_home) == "XDG_CONFIG_HOME");
- REQUIRE(xdg_variable(xdg_directory::cache_home) == "XDG_CACHE_HOME");
- REQUIRE(xdg_variable(xdg_directory::runtime_dir) == "XDG_RUNTIME_DIR");
- }
-
- SCENARIO("The values of the XDG variables depend on the environment", "[system][xdg][spec]")
- {
- auto const home_directory = std::filesystem::path{"/home/test"};
- auto const run_directory = std::filesystem::path{"/run/user"};
- auto const uid = std::to_string(::getuid());
-
- GIVEN("An environment that only contains HOME")
- {
- auto home = "HOME="s + home_directory.native();
- char const * env_data[] = {home.c_str(), nullptr};
- auto env = environment{env_data};
-
- THEN("the data home is '<home_directory>/.local/share")
- {
- REQUIRE(xdg_path_for(xdg_directory::data_home, env) == home_directory / ".local/share");
- }
-
- THEN("the config home is '<home_directory>/.config")
- {
- REQUIRE(xdg_path_for(xdg_directory::config_home, env) == home_directory / ".config");
- }
-
- THEN("the cache home is '<home_directory>/.cache")
- {
- REQUIRE(xdg_path_for(xdg_directory::cache_home, env) == home_directory / ".cache");
- }
-
- THEN("the runtime directory is '<run_directory>/<uid>'")
- {
- REQUIRE(xdg_path_for(xdg_directory::runtime_dir, env) == run_directory / uid);
- }
- }
-
- GIVEN("An environment that only contains HOME and XDG_DATA_HOME")
- {
- auto home = "HOME="s + home_directory.native();
- auto data_home = "XDG_DATA_HOME=/home/test/xdg_data_home"s;
- char const * env_data[] = {home.c_str(), data_home.c_str(), nullptr};
- auto env = environment{env_data};
-
- THEN("the data home is '$XDG_DATA_HOME")
- {
- REQUIRE(xdg_path_for(xdg_directory::data_home, env) == env["XDG_DATA_HOME"]);
- }
-
- THEN("the config home is '<home_directory>/.config")
- {
- REQUIRE(xdg_path_for(xdg_directory::config_home, env) == home_directory / ".config");
- }
-
- THEN("the cache home is '<home_directory>/.cache")
- {
- REQUIRE(xdg_path_for(xdg_directory::cache_home, env) == home_directory / ".cache");
- }
-
- THEN("the runtime directory is '<run_directory>/<uid>'")
- {
- REQUIRE(xdg_path_for(xdg_directory::runtime_dir, env) == run_directory / uid);
- }
- }
-
- GIVEN("An environment that only contains HOME and XDG_CONFIG_HOME")
- {
- auto home = "HOME="s + home_directory.native();
- auto config_home = "XDG_CONFIG_HOME=/home/test/xdg_config_home"s;
- char const * env_data[] = {home.c_str(), config_home.c_str(), nullptr};
- auto env = environment{env_data};
-
- THEN("the data home is '<home_directory>/.local/share")
- {
- REQUIRE(xdg_path_for(xdg_directory::data_home, env) == home_directory / ".local/share");
- }
-
- THEN("the config home is '$XDG_CONFIG_HOME")
- {
- REQUIRE(xdg_path_for(xdg_directory::config_home, env) == env["XDG_CONFIG_HOME"]);
- }
-
- THEN("the cache home is '<home_directory>/.cache")
- {
- REQUIRE(xdg_path_for(xdg_directory::cache_home, env) == home_directory / ".cache");
- }
-
- THEN("the runtime directory is '<run_directory>/<uid>'")
- {
- REQUIRE(xdg_path_for(xdg_directory::runtime_dir, env) == run_directory / uid);
- }
- }
-
- GIVEN("An environment that only contains HOME and XDG_CACHE_HOME")
- {
- auto home = "HOME="s + home_directory.native();
- auto cache_home = "XDG_CACHE_HOME=/home/test/xdg_cache_home"s;
- char const * env_data[] = {home.c_str(), cache_home.c_str(), nullptr};
- auto env = environment{env_data};
-
- THEN("the data home is '<home_directory>/.local/share")
- {
- REQUIRE(xdg_path_for(xdg_directory::data_home, env) == home_directory / ".local/share");
- }
-
- THEN("the cache home is '<home_directory>/.config")
- {
- REQUIRE(xdg_path_for(xdg_directory::config_home, env) == home_directory / ".config");
- }
-
- THEN("the config home is '$XDG_CACHE_HOME")
- {
- REQUIRE(xdg_path_for(xdg_directory::cache_home, env) == env["XDG_CACHE_HOME"]);
- }
-
- THEN("the runtime directory is '<run_directory>/<uid>'")
- {
- REQUIRE(xdg_path_for(xdg_directory::runtime_dir, env) == run_directory / uid);
- }
- }
-
- GIVEN("An environment that only contains HOME and XDG_RUNTIME_DIR")
- {
- auto home = "HOME="s + home_directory.native();
- auto runtime_dir = "XDG_RUNTIME_DIR=/home/test/xdg_runtime_dir"s;
- char const * env_data[] = {home.c_str(), runtime_dir.c_str(), nullptr};
- auto env = environment{env_data};
-
- THEN("the data home is '<home_directory>/.local/share")
- {
- REQUIRE(xdg_path_for(xdg_directory::data_home, env) == home_directory / ".local/share");
- }
-
- THEN("the config home is '<home_directory>/.config")
- {
- REQUIRE(xdg_path_for(xdg_directory::config_home, env) == home_directory / ".config");
- }
-
- THEN("the cache home is '<home_directory>/.cache")
- {
- REQUIRE(xdg_path_for(xdg_directory::cache_home, env) == home_directory / ".cache");
- }
-
- THEN("the runtime directory is '$XDG_RUNTIME_DIR'")
- {
- REQUIRE(xdg_path_for(xdg_directory::runtime_dir, env) == env["XDG_RUNTIME_DIR"]);
- }
- }
- }
-
-} // namespace wanda::system::test \ No newline at end of file