diff options
| author | Curtis J Bezault <curtbezault@gmail.com> | 2019-07-19 08:08:08 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-07-19 08:08:08 -0700 |
| commit | 18c849daea115310d7ee985e5af99ba96e6b79fe (patch) | |
| tree | e8fdf76fe31cd299c84a1e16877aa217c9bab9d5 /toolsrc/src/vcpkg-tests/chrono.cpp | |
| parent | e81d22ddec6887a497055d4804a004ca662b4526 (diff) | |
| parent | 618fa203c13c30bd19826988cff66481bca0562f (diff) | |
| download | vcpkg-18c849daea115310d7ee985e5af99ba96e6b79fe.tar.gz vcpkg-18c849daea115310d7ee985e5af99ba96e6b79fe.zip | |
Merge branch 'master' into external_file_abi
Diffstat (limited to 'toolsrc/src/vcpkg-tests/chrono.cpp')
| -rw-r--r-- | toolsrc/src/vcpkg-tests/chrono.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/toolsrc/src/vcpkg-tests/chrono.cpp b/toolsrc/src/vcpkg-tests/chrono.cpp new file mode 100644 index 000000000..c164753f9 --- /dev/null +++ b/toolsrc/src/vcpkg-tests/chrono.cpp @@ -0,0 +1,34 @@ +#include <vcpkg-tests/catch.h> + +#include <vcpkg/base/chrono.h> + +namespace Chrono = vcpkg::Chrono; + +TEST_CASE ("parse time", "[chrono]") +{ + auto timestring = "1990-02-03T04:05:06.0Z"; + auto maybe_time = Chrono::CTime::parse(timestring); + + REQUIRE(maybe_time.has_value()); + REQUIRE(maybe_time.get()->to_string() == timestring); +} + +TEST_CASE ("parse blank time", "[chrono]") +{ + auto maybe_time = Chrono::CTime::parse(""); + + REQUIRE_FALSE(maybe_time.has_value()); +} + +TEST_CASE ("difference of times", "[chrono]") +{ + auto maybe_time1 = Chrono::CTime::parse("1990-02-03T04:05:06.0Z"); + auto maybe_time2 = Chrono::CTime::parse("1990-02-10T04:05:06.0Z"); + + REQUIRE(maybe_time1.has_value()); + REQUIRE(maybe_time2.has_value()); + + auto delta = maybe_time2.get()->to_time_point() - maybe_time1.get()->to_time_point(); + + REQUIRE(std::chrono::duration_cast<std::chrono::hours>(delta).count() == 24 * 7); +} |
