diff options
| author | xoviat <xoviat@users.noreply.github.com> | 2017-12-20 13:24:59 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-12-20 13:24:59 -0600 |
| commit | f1f373b189453f33a944e9db8b3451b1c785e223 (patch) | |
| tree | 8713b7dc28734e4d4ad0ebba76459850955ce004 /toolsrc/src/tests.chrono.cpp | |
| parent | 6363688b6d2f3522a4ce48cedb60da31775cd923 (diff) | |
| parent | 6cb6a61aaf5ef2c143f974e9f731778bcd3f5cbe (diff) | |
| download | vcpkg-f1f373b189453f33a944e9db8b3451b1c785e223.tar.gz vcpkg-f1f373b189453f33a944e9db8b3451b1c785e223.zip | |
Merge branch 'master' into fftw
Diffstat (limited to 'toolsrc/src/tests.chrono.cpp')
| -rw-r--r-- | toolsrc/src/tests.chrono.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/toolsrc/src/tests.chrono.cpp b/toolsrc/src/tests.chrono.cpp new file mode 100644 index 000000000..269cdca58 --- /dev/null +++ b/toolsrc/src/tests.chrono.cpp @@ -0,0 +1,41 @@ +#include "tests.pch.h" + +using namespace Microsoft::VisualStudio::CppUnitTestFramework; + +namespace Chrono = vcpkg::Chrono; + +namespace UnitTest1 +{ + class ChronoTests : public TestClass<ChronoTests> + { + TEST_METHOD(parse_time) + { + auto timestring = "1990-02-03T04:05:06.0Z"; + auto maybe_time = Chrono::CTime::parse(timestring); + + Assert::IsTrue(maybe_time.has_value()); + + Assert::AreEqual(timestring, maybe_time.get()->to_string().c_str()); + } + + TEST_METHOD(parse_time_blank) + { + auto maybe_time = Chrono::CTime::parse(""); + + Assert::IsFalse(maybe_time.has_value()); + } + + TEST_METHOD(time_difference) + { + auto maybe_time1 = Chrono::CTime::parse("1990-02-03T04:05:06.0Z"); + auto maybe_time2 = Chrono::CTime::parse("1990-02-10T04:05:06.0Z"); + + Assert::IsTrue(maybe_time1.has_value()); + Assert::IsTrue(maybe_time2.has_value()); + + auto delta = maybe_time2.get()->to_time_point() - maybe_time1.get()->to_time_point(); + + Assert::AreEqual(24 * 7, std::chrono::duration_cast<std::chrono::hours>(delta).count()); + } + }; +} |
