aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src/vcpkg-tests/chrono.cpp
diff options
context:
space:
mode:
authornicole mazzuca <mazzucan@outlook.com>2019-07-18 19:07:00 -0700
committerGriffin Downs <35574547+grdowns@users.noreply.github.com>2019-07-18 19:07:00 -0700
commit825055378998ae6bc24e8cb0bce2e1fbf9a425da (patch)
treedce29d762b06e5f44e985051c3d5520c7ca1cc19 /toolsrc/src/vcpkg-tests/chrono.cpp
parent9b5ee9941232dc3dd07085de747b1e95bb059525 (diff)
downloadvcpkg-825055378998ae6bc24e8cb0bce2e1fbf9a425da.tar.gz
vcpkg-825055378998ae6bc24e8cb0bce2e1fbf9a425da.zip
Rewrite the tests! now they're cross-platform! (#7315)
* begin exploratory rewriting of tests * continue working on tests * more test work! holy butts vcpkg-tests/plan.cpp was a bunch of work * finish writing new tests - [x] write catch2 tests - [ ] rewrite/at least delete the VS project files - [ ] document running tests * Fix tests to work on WSL, rewrite test vcxproj still need to test on macOS also, delete tests.pch.h * Condense add_test calls
Diffstat (limited to 'toolsrc/src/vcpkg-tests/chrono.cpp')
-rw-r--r--toolsrc/src/vcpkg-tests/chrono.cpp34
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);
+}