diff options
author | louiz’ <louiz@louiz.org> | 2016-08-31 01:17:45 +0200 |
---|---|---|
committer | louiz’ <louiz@louiz.org> | 2016-08-31 01:17:45 +0200 |
commit | 2a4905df0153c47656555a21f3d57bbad6f3ffe1 (patch) | |
tree | b2b0608e1a809056c580b1bd4ca9531a11b42c6d /tests | |
parent | 9727f4cf00e85e90f89c9b5443ec035c44d4c3f6 (diff) | |
download | biboumi-2a4905df0153c47656555a21f3d57bbad6f3ffe1.tar.gz biboumi-2a4905df0153c47656555a21f3d57bbad6f3ffe1.tar.bz2 biboumi-2a4905df0153c47656555a21f3d57bbad6f3ffe1.tar.xz biboumi-2a4905df0153c47656555a21f3d57bbad6f3ffe1.zip |
Fix to_string(time_t) and write a unit test for it
Diffstat (limited to 'tests')
-rw-r--r-- | tests/utils.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/utils.cpp b/tests/utils.cpp index e7ba415..abe7ef7 100644 --- a/tests/utils.cpp +++ b/tests/utils.cpp @@ -7,6 +7,7 @@ #include <utils/xdg.hpp> #include <utils/empty_if_fixed_server.hpp> #include <utils/get_first_non_empty.hpp> +#include <utils/time.hpp> using namespace std::string_literals; @@ -111,3 +112,12 @@ TEST_CASE("first non-empty string") CHECK(get_first_non_empty("first"s) == "first"s); CHECK(get_first_non_empty(0, 1, 2, 3) == 1); } + +TEST_CASE("time_to_string") +{ + const std::time_t stamp = 1472480968; + const std::string result = "2016-08-29T14:29:28Z"; + CHECK(utils::to_string(stamp) == result); + CHECK(utils::to_string(stamp).size() == result.size()); + CHECK(utils::to_string(0) == "1970-01-01T00:00:00Z"); +} |