Skip to content

Commit f6962f7

Browse files
committed
tests: use explicit conversion to system_clock::duration
1 parent 9fc725c commit f6962f7

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

test/test_unit_chrono_utils.cxx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,9 @@ TEST_CASE("to_iso8601_utc with system_clock::time_point", "[unit][chrono_utils]"
140140
{
141141
// Nanoseconds will be truncated to microseconds
142142
auto duration = std::chrono::seconds(1000000000) + std::chrono::nanoseconds(123456789);
143-
auto time_point = std::chrono::system_clock::time_point{ duration };
143+
auto time_point = std::chrono::system_clock::time_point{
144+
std::chrono::duration_cast<std::chrono::system_clock::duration>(duration)
145+
};
144146
auto result = to_iso8601_utc(time_point);
145147
REQUIRE(result == "2001-09-09T01:46:40.123456Z");
146148
}
@@ -380,9 +382,13 @@ TEST_CASE("to_iso8601_utc with chrono time_point edge cases", "[unit][chrono_uti
380382
{
381383
SECTION("time_point with only nanosecond precision below microsecond threshold")
382384
{
385+
383386
auto duration =
384387
std::chrono::seconds(1000000000) + std::chrono::nanoseconds(999); // Less than 1 microsecond
385-
auto time_point = std::chrono::system_clock::time_point{ duration };
388+
auto time_point = std::chrono::system_clock::time_point{
389+
std::chrono::duration_cast<std::chrono::system_clock::duration>(duration)
390+
};
391+
386392
auto result = to_iso8601_utc(time_point);
387393
// Should truncate to 0 microseconds
388394
REQUIRE(result == "2001-09-09T01:46:40.000000Z");

0 commit comments

Comments
 (0)