mirror of
https://github.com/transmission/transmission.git
synced 2026-02-14 23:19:34 +00:00
chore: remove unnecessary helper function
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user