diff options
Diffstat (limited to 'tests/utils.cpp')
-rw-r--r-- | tests/utils.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/utils.cpp b/tests/utils.cpp index 48951da..c5ef7e7 100644 --- a/tests/utils.cpp +++ b/tests/utils.cpp @@ -8,6 +8,9 @@ #include <utils/empty_if_fixed_server.hpp> #include <utils/get_first_non_empty.hpp> #include <utils/time.hpp> +#include <utils/system.hpp> +#include <utils/scopeguard.hpp> +#include <utils/dirname.hpp> using namespace std::string_literals; @@ -140,3 +143,31 @@ TEST_CASE("parse_datetime") CHECK(utils::parse_datetime("1970-01-02T00:00:12*00:00") == -1); CHECK(utils::parse_datetime("1970-01-02T00:00:12+0000") == -1); } + +TEST_CASE("scope_guard") +{ + bool res = false; + { + auto guard = utils::make_scope_guard([&res](){ res = true; }); + CHECK(!res); + } + CHECK(res); +} + +TEST_CASE("system_name") +{ + CHECK(utils::get_system_name() != "Unknown"); + CHECK(!utils::get_system_name().empty()); +} + +TEST_CASE("dirname") +{ + CHECK(utils::dirname("/") == "/"); + CHECK(utils::dirname("coucou.txt") == "./"); + CHECK(utils::dirname("../coucou.txt") == "../"); + CHECK(utils::dirname("/etc/biboumi/coucou.txt") == "/etc/biboumi/"); + CHECK(utils::dirname("..") == ".."); + CHECK(utils::dirname("../") == "../"); + CHECK(utils::dirname(".") == "."); + CHECK(utils::dirname("./") == "./"); +} |