diff options
author | MarcoFalke <falke.marco@gmail.com> | 2019-10-28 10:30:45 -0400 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2019-10-28 10:30:51 -0400 |
commit | cfec3e01b4d6153efecc1d767511c616029cb974 (patch) | |
tree | f1b933588927264eefc6dc6dceb5a5b4a03bae90 /src/test | |
parent | 1ab6c1267e342e034758d4c18e0b3291705d7edb (diff) | |
parent | e7b02b54ccfb6b2e119a67799220f8d8d8b5cccd (diff) |
Merge #17266: util: Rename DecodeDumpTime to ParseISO8601DateTime
e7b02b54ccfb6b2e119a67799220f8d8d8b5cccd Add roundtrip and more tests to ParseISO8601DateTime and FormatISO8601DateTime (Elichai Turkel)
9e2c623be50ee7e586a411923b9ed136acfa2b3f Rename DecodeDumpTime to ParseISO8601DateTime and move to time.cpp (Elichai Turkel)
Pull request description:
As discussed in #17245.
1. Renamed the function.
2. Moved it from `rpcdump.cpp` to `time.cpp`.
3. Added a check if the time is less then epoch return 0 to prevent an overflow.
4. Added more edge cases tests and a roundtrip test.
ACKs for top commit:
laanwj:
ACK e7b02b54ccfb6b2e119a67799220f8d8d8b5cccd
MarcoFalke:
ACK e7b02b54ccfb6b2e119a67799220f8d8d8b5cccd
promag:
Code review ACK e7b02b54ccfb6b2e119a67799220f8d8d8b5cccd. Moved code is correct, left a comment regarding the test change.
Tree-SHA512: 703c21e09b2aabc992235149e67acba63d9d77a593ec8f6d2fec3eb63a7e5c406d56cbce6c6513ab32fba43367d073d2345f3b589843e3c5fe4f55ea3e00bf29
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/util_tests.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/test/util_tests.cpp b/src/test/util_tests.cpp index 02303d0f65..569ce53092 100644 --- a/src/test/util_tests.cpp +++ b/src/test/util_tests.cpp @@ -145,9 +145,17 @@ BOOST_AUTO_TEST_CASE(util_Join) BOOST_CHECK_EQUAL(Join<std::string>({"foo", "bar"}, ", ", op_upper), "FOO, BAR"); } -BOOST_AUTO_TEST_CASE(util_FormatISO8601DateTime) +BOOST_AUTO_TEST_CASE(util_FormatParseISO8601DateTime) { BOOST_CHECK_EQUAL(FormatISO8601DateTime(1317425777), "2011-09-30T23:36:17Z"); + BOOST_CHECK_EQUAL(FormatISO8601DateTime(0), "1970-01-01T00:00:00Z"); + + BOOST_CHECK_EQUAL(ParseISO8601DateTime("1970-01-01T00:00:00Z"), 0); + BOOST_CHECK_EQUAL(ParseISO8601DateTime("1960-01-01T00:00:00Z"), 0); + BOOST_CHECK_EQUAL(ParseISO8601DateTime("2011-09-30T23:36:17Z"), 1317425777); + + auto time = GetSystemTimeInSeconds(); + BOOST_CHECK_EQUAL(ParseISO8601DateTime(FormatISO8601DateTime(time)), time); } BOOST_AUTO_TEST_CASE(util_FormatISO8601Date) |