From ed419140280553b070943b7ba539120a26ff5686 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Tue, 11 Dec 2018 07:42:05 +0100 Subject: wanda: restructure directory hierarchy --- tests/core_driver.cpp | 18 -------- tests/test_suite_xdg.cpp | 95 ------------------------------------------ tests/test_suite_xdg.hpp | 16 ------- tests/wanda/core_driver.cpp | 18 ++++++++ tests/wanda/test_suite_xdg.cpp | 95 ++++++++++++++++++++++++++++++++++++++++++ tests/wanda/test_suite_xdg.hpp | 16 +++++++ 6 files changed, 129 insertions(+), 129 deletions(-) delete mode 100644 tests/core_driver.cpp delete mode 100644 tests/test_suite_xdg.cpp delete mode 100644 tests/test_suite_xdg.hpp create mode 100644 tests/wanda/core_driver.cpp create mode 100644 tests/wanda/test_suite_xdg.cpp create mode 100644 tests/wanda/test_suite_xdg.hpp (limited to 'tests') diff --git a/tests/core_driver.cpp b/tests/core_driver.cpp deleted file mode 100644 index 3643da0..0000000 --- a/tests/core_driver.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include "test_suite_xdg.hpp" - -#include "cute/cute.h" -#include "cute/cute_runner.h" -#include "cute/tap_listener.h" - -#include -#include -#include -#include - -int main(int argc, char const *const *argv) -{ - auto listener = cute::tap_listener<>{std::cout}; - auto runner = cute::makeRunner(listener, argc, argv); - auto suites = std::vector>{wanda::test_suite_xdg()}; - return !all_of(cbegin(suites), cend(suites), [&](auto const &suite) { return runner(suite.first, suite.second.c_str()); }); -} \ No newline at end of file diff --git a/tests/test_suite_xdg.cpp b/tests/test_suite_xdg.cpp deleted file mode 100644 index 48f3eaa..0000000 --- a/tests/test_suite_xdg.cpp +++ /dev/null @@ -1,95 +0,0 @@ -#include "test_suite_xdg.hpp" -#include "xdg.hpp" - -#include "cute/cute.h" - -#include - -#include - -namespace wanda -{ - -namespace -{ - char const * home_only_environment[2] = {"HOME=/home/cute"}; - char const * xdg_data_home_environment[2] = {"XDG_DATA_HOME=/home/cute/xdg_data_home"}; - char const * xdg_config_home_environment[2] = {"XDG_CONFIG_HOME=/home/cute/xdg_config_home"}; - char const * xdg_cache_home_environment[2] = {"XDG_CACHE_HOME=/home/cute/xdg_cache_home"}; - char const * xdg_runtime_dir_environment[2] = {"XDG_RUNTIME_DIR=/home/cute/xdg_runtime_dir"}; -} - -void test_xdg_variables() -{ - ASSERT_EQUAL("XDG_DATA_HOME", xdg_variable(xdg_directory::data_home)); - ASSERT_EQUAL("XDG_CONFIG_HOME", xdg_variable(xdg_directory::config_home)); - ASSERT_EQUAL("XDG_CACHE_HOME", xdg_variable(xdg_directory::cache_home)); - ASSERT_EQUAL("XDG_RUNTIME_DIR", xdg_variable(xdg_directory::runtime_dir)); -} - -void test_xdg_path_for_data_home_without_xdg_data_home_in_environment() -{ - auto env = environment{home_only_environment}; - ASSERT_EQUAL("/home/cute/.local/share", xdg_path_for(xdg_directory::data_home, env)); -} - -void test_xdg_path_for_data_home_with_xdg_data_home_in_environment() -{ - auto env = environment{xdg_data_home_environment}; - ASSERT_EQUAL("/home/cute/xdg_data_home", xdg_path_for(xdg_directory::data_home, env)); -} - -void test_xdg_path_for_config_home_without_xdg_config_home_in_environment() -{ - auto env = environment{home_only_environment}; - ASSERT_EQUAL("/home/cute/.config", xdg_path_for(xdg_directory::config_home, env)); -} - -void test_xdg_path_for_config_home_with_xdg_config_home_in_environment() -{ - auto env = environment{xdg_config_home_environment}; - ASSERT_EQUAL("/home/cute/xdg_config_home", xdg_path_for(xdg_directory::config_home, env)); -} - -void test_xdg_path_for_cache_home_without_xdg_cache_home_in_environment() -{ - auto env = environment{home_only_environment}; - ASSERT_EQUAL("/home/cute/.cache", xdg_path_for(xdg_directory::cache_home, env)); -} - -void test_xdg_path_for_cache_home_with_xdg_cache_home_in_environment() -{ - auto env = environment{xdg_cache_home_environment}; - ASSERT_EQUAL("/home/cute/xdg_cache_home", xdg_path_for(xdg_directory::cache_home, env)); -} - -void test_xdg_path_for_runtime_dir_without_xdg_runtime_dir_in_environment() -{ - auto env = environment{home_only_environment}; - auto expected = std::filesystem::path{"/run/user"} / std::to_string(::getuid()); - ASSERT_EQUAL(expected, xdg_path_for(xdg_directory::runtime_dir, env)); -} - -void test_xdg_path_for_runtime_dir_with_xdg_runtime_dir_in_environment() -{ - auto env = environment{xdg_runtime_dir_environment}; - ASSERT_EQUAL("/home/cute/xdg_runtime_dir", xdg_path_for(xdg_directory::runtime_dir, env)); -} - -std::pair test_suite_xdg() -{ - return std::make_pair(cute::suite{ - CUTE(test_xdg_variables), - CUTE(test_xdg_path_for_data_home_without_xdg_data_home_in_environment), - CUTE(test_xdg_path_for_data_home_with_xdg_data_home_in_environment), - CUTE(test_xdg_path_for_config_home_without_xdg_config_home_in_environment), - CUTE(test_xdg_path_for_config_home_with_xdg_config_home_in_environment), - CUTE(test_xdg_path_for_cache_home_without_xdg_cache_home_in_environment), - CUTE(test_xdg_path_for_cache_home_with_xdg_cache_home_in_environment), - CUTE(test_xdg_path_for_runtime_dir_without_xdg_runtime_dir_in_environment), - CUTE(test_xdg_path_for_runtime_dir_with_xdg_runtime_dir_in_environment), - }, - "XDG Utilities"); -} - -} // namespace wanda \ No newline at end of file diff --git a/tests/test_suite_xdg.hpp b/tests/test_suite_xdg.hpp deleted file mode 100644 index 698ad9a..0000000 --- a/tests/test_suite_xdg.hpp +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef WANDA_TEST_SUITE_XDG_HPP -#define WANDA_TEST_SUITE_XDG_HPP - -#include "cute/cute.h" - -#include -#include - -namespace wanda -{ - -std::pair test_suite_xdg(); - -} // namespace wanda - -#endif \ No newline at end of file diff --git a/tests/wanda/core_driver.cpp b/tests/wanda/core_driver.cpp new file mode 100644 index 0000000..3643da0 --- /dev/null +++ b/tests/wanda/core_driver.cpp @@ -0,0 +1,18 @@ +#include "test_suite_xdg.hpp" + +#include "cute/cute.h" +#include "cute/cute_runner.h" +#include "cute/tap_listener.h" + +#include +#include +#include +#include + +int main(int argc, char const *const *argv) +{ + auto listener = cute::tap_listener<>{std::cout}; + auto runner = cute::makeRunner(listener, argc, argv); + auto suites = std::vector>{wanda::test_suite_xdg()}; + return !all_of(cbegin(suites), cend(suites), [&](auto const &suite) { return runner(suite.first, suite.second.c_str()); }); +} \ No newline at end of file diff --git a/tests/wanda/test_suite_xdg.cpp b/tests/wanda/test_suite_xdg.cpp new file mode 100644 index 0000000..0338ee3 --- /dev/null +++ b/tests/wanda/test_suite_xdg.cpp @@ -0,0 +1,95 @@ +#include "test_suite_xdg.hpp" +#include + +#include "cute/cute.h" + +#include + +#include + +namespace wanda +{ + +namespace +{ + char const * home_only_environment[2] = {"HOME=/home/cute"}; + char const * xdg_data_home_environment[2] = {"XDG_DATA_HOME=/home/cute/xdg_data_home"}; + char const * xdg_config_home_environment[2] = {"XDG_CONFIG_HOME=/home/cute/xdg_config_home"}; + char const * xdg_cache_home_environment[2] = {"XDG_CACHE_HOME=/home/cute/xdg_cache_home"}; + char const * xdg_runtime_dir_environment[2] = {"XDG_RUNTIME_DIR=/home/cute/xdg_runtime_dir"}; +} + +void test_xdg_variables() +{ + ASSERT_EQUAL("XDG_DATA_HOME", xdg_variable(xdg_directory::data_home)); + ASSERT_EQUAL("XDG_CONFIG_HOME", xdg_variable(xdg_directory::config_home)); + ASSERT_EQUAL("XDG_CACHE_HOME", xdg_variable(xdg_directory::cache_home)); + ASSERT_EQUAL("XDG_RUNTIME_DIR", xdg_variable(xdg_directory::runtime_dir)); +} + +void test_xdg_path_for_data_home_without_xdg_data_home_in_environment() +{ + auto env = environment{home_only_environment}; + ASSERT_EQUAL("/home/cute/.local/share", xdg_path_for(xdg_directory::data_home, env)); +} + +void test_xdg_path_for_data_home_with_xdg_data_home_in_environment() +{ + auto env = environment{xdg_data_home_environment}; + ASSERT_EQUAL("/home/cute/xdg_data_home", xdg_path_for(xdg_directory::data_home, env)); +} + +void test_xdg_path_for_config_home_without_xdg_config_home_in_environment() +{ + auto env = environment{home_only_environment}; + ASSERT_EQUAL("/home/cute/.config", xdg_path_for(xdg_directory::config_home, env)); +} + +void test_xdg_path_for_config_home_with_xdg_config_home_in_environment() +{ + auto env = environment{xdg_config_home_environment}; + ASSERT_EQUAL("/home/cute/xdg_config_home", xdg_path_for(xdg_directory::config_home, env)); +} + +void test_xdg_path_for_cache_home_without_xdg_cache_home_in_environment() +{ + auto env = environment{home_only_environment}; + ASSERT_EQUAL("/home/cute/.cache", xdg_path_for(xdg_directory::cache_home, env)); +} + +void test_xdg_path_for_cache_home_with_xdg_cache_home_in_environment() +{ + auto env = environment{xdg_cache_home_environment}; + ASSERT_EQUAL("/home/cute/xdg_cache_home", xdg_path_for(xdg_directory::cache_home, env)); +} + +void test_xdg_path_for_runtime_dir_without_xdg_runtime_dir_in_environment() +{ + auto env = environment{home_only_environment}; + auto expected = std::filesystem::path{"/run/user"} / std::to_string(::getuid()); + ASSERT_EQUAL(expected, xdg_path_for(xdg_directory::runtime_dir, env)); +} + +void test_xdg_path_for_runtime_dir_with_xdg_runtime_dir_in_environment() +{ + auto env = environment{xdg_runtime_dir_environment}; + ASSERT_EQUAL("/home/cute/xdg_runtime_dir", xdg_path_for(xdg_directory::runtime_dir, env)); +} + +std::pair test_suite_xdg() +{ + return std::make_pair(cute::suite{ + CUTE(test_xdg_variables), + CUTE(test_xdg_path_for_data_home_without_xdg_data_home_in_environment), + CUTE(test_xdg_path_for_data_home_with_xdg_data_home_in_environment), + CUTE(test_xdg_path_for_config_home_without_xdg_config_home_in_environment), + CUTE(test_xdg_path_for_config_home_with_xdg_config_home_in_environment), + CUTE(test_xdg_path_for_cache_home_without_xdg_cache_home_in_environment), + CUTE(test_xdg_path_for_cache_home_with_xdg_cache_home_in_environment), + CUTE(test_xdg_path_for_runtime_dir_without_xdg_runtime_dir_in_environment), + CUTE(test_xdg_path_for_runtime_dir_with_xdg_runtime_dir_in_environment), + }, + "XDG Utilities"); +} + +} // namespace wanda \ No newline at end of file diff --git a/tests/wanda/test_suite_xdg.hpp b/tests/wanda/test_suite_xdg.hpp new file mode 100644 index 0000000..698ad9a --- /dev/null +++ b/tests/wanda/test_suite_xdg.hpp @@ -0,0 +1,16 @@ +#ifndef WANDA_TEST_SUITE_XDG_HPP +#define WANDA_TEST_SUITE_XDG_HPP + +#include "cute/cute.h" + +#include +#include + +namespace wanda +{ + +std::pair test_suite_xdg(); + +} // namespace wanda + +#endif \ No newline at end of file -- cgit v1.2.3