aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/cpp/util/time_test.cc15
1 files changed, 14 insertions, 1 deletions
diff --git a/test/cpp/util/time_test.cc b/test/cpp/util/time_test.cc
index 2e17add67f..4641fdb4da 100644
--- a/test/cpp/util/time_test.cc
+++ b/test/cpp/util/time_test.cc
@@ -61,11 +61,24 @@ TEST_F(TimeTest, AbsolutePointTest) {
EXPECT_TRUE(tp == tp_converted_2);
}
-// gpr_inf_future is treated specially and mapped to time_point::max()
+// gpr_inf_future is treated specially and mapped to/from time_point::max()
TEST_F(TimeTest, InfFuture) {
EXPECT_EQ(system_clock::time_point::max(),
Timespec2Timepoint(gpr_inf_future));
+ gpr_timespec from_time_point_max;
+ Timepoint2Timespec(system_clock::time_point::max(), &from_time_point_max);
+ EXPECT_EQ(0, gpr_time_cmp(gpr_inf_future, from_time_point_max));
+ // This will cause an overflow
+ Timepoint2Timespec(
+ std::chrono::time_point<system_clock, std::chrono::seconds>::max(),
+ &from_time_point_max);
+ EXPECT_EQ(0, gpr_time_cmp(gpr_inf_future, from_time_point_max));
}
} // namespace
} // namespace grpc
+
+int main(int argc, char** argv) {
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}