chore: remove unnecessary helper function

This commit is contained in:
Charles Kerr
2026-02-09 16:17:02 -06:00
parent ae61de8910
commit 69ea907836

View File

@@ -40,15 +40,6 @@ constexpr std::chrono::sys_seconds make_sys_seconds(int year, int month, int day
std::chrono::hours{ hour } + std::chrono::minutes{ minute } + std::chrono::seconds{ second };
}
void expect_sys_seconds_eq(std::optional<std::chrono::sys_seconds> const& actual, std::chrono::sys_seconds expected)
{
EXPECT_TRUE(actual.has_value());
if (actual.has_value())
{
EXPECT_EQ(actual->time_since_epoch().count(), expected.time_since_epoch().count());
}
}
template<typename T, size_t N>
void testModeRoundtrip(std::array<std::pair<std::string_view, T>, N> const& items)
{
@@ -125,19 +116,19 @@ TEST_F(ConverterTest, sysSecondsRoundtrip)
EXPECT_TRUE(std::regex_match(std::string{ serialized }, re));
auto actual = to_value<std::chrono::sys_seconds>(tr_variant{ serialized });
expect_sys_seconds_eq(actual, Expected);
EXPECT_EQ(actual, Expected);
actual = to_value<std::chrono::sys_seconds>(tr_variant{ "2024-02-03T04:05:06Z"sv });
expect_sys_seconds_eq(actual, Expected);
EXPECT_EQ(actual, Expected);
actual = to_value<std::chrono::sys_seconds>(tr_variant{ "2024-02-03T04:05:06+00:00"sv });
expect_sys_seconds_eq(actual, Expected);
EXPECT_EQ(actual, Expected);
actual = to_value<std::chrono::sys_seconds>(tr_variant{ "2024-02-03T04:05:06+02:30"sv });
expect_sys_seconds_eq(actual, Expected - (hours{ 2 } + minutes{ 30 }));
EXPECT_EQ(actual, Expected - (hours{ 2 } + minutes{ 30 }));
auto constexpr Epoch = int64_t{ 1700000000 };
auto const epoch_seconds = time_point_cast<seconds>(system_clock::from_time_t(static_cast<time_t>(Epoch)));
actual = to_value<std::chrono::sys_seconds>(tr_variant{ Epoch });
expect_sys_seconds_eq(actual, epoch_seconds);
EXPECT_EQ(actual, epoch_seconds);
}