@@ -234,13 +234,15 @@ TEST(Timestamp, FromProto) {
234234 EXPECT_EQ (internal::TimestampFromCounts (1576030524 , 611422667 ).value (),
235235 internal::TimestampFromProto (proto));
236236
237- proto.set_seconds (std::numeric_limits<std:: int64_t >:: min () );
237+ proto.set_seconds (- 62135596800 );
238238 proto.set_nanos (0 );
239- EXPECT_EQ (Timestamp::Min (), internal::TimestampFromProto (proto));
239+ EXPECT_EQ (internal::TimestampFromCounts (-62135596800 , 0 ).value (),
240+ internal::TimestampFromProto (proto));
240241
241- proto.set_seconds (std::numeric_limits<std:: int64_t >:: max () );
242+ proto.set_seconds (253402300799 );
242243 proto.set_nanos (999999999 );
243- EXPECT_EQ (Timestamp::Max (), internal::TimestampFromProto (proto));
244+ EXPECT_EQ (internal::TimestampFromCounts (253402300799 , 999999999 ).value (),
245+ internal::TimestampFromProto (proto));
244246}
245247
246248TEST (Timestamp, ToProto) {
@@ -254,12 +256,14 @@ TEST(Timestamp, ToProto) {
254256 EXPECT_EQ (1576030524 , proto.seconds ());
255257 EXPECT_EQ (611422667 , proto.nanos ());
256258
257- proto = internal::TimestampToProto (Timestamp::Min ());
258- EXPECT_EQ (std::numeric_limits<std::int64_t >::min (), proto.seconds ());
259+ proto = internal::TimestampToProto (
260+ internal::TimestampFromCounts (-62135596800 , 0 ).value ());
261+ EXPECT_EQ (-62135596800 , proto.seconds ());
259262 EXPECT_EQ (0 , proto.nanos ());
260263
261- proto = internal::TimestampToProto (Timestamp::Max ());
262- EXPECT_EQ (std::numeric_limits<std::int64_t >::max (), proto.seconds ());
264+ proto = internal::TimestampToProto (
265+ internal::TimestampFromCounts (253402300799 , 999999999 ).value ());
266+ EXPECT_EQ (253402300799 , proto.seconds ());
263267 EXPECT_EQ (999999999 , proto.nanos ());
264268}
265269
@@ -354,8 +358,8 @@ TEST(Timestamp, ToChrono) {
354358 auto const tp5 = epoch + std::chrono::hours (2123456789 / 60 / 60 );
355359 EXPECT_EQ (tp5, ts_pos.get <sys_time<std::chrono::hours>>().value ());
356360
357- auto const ts_big_pos = Timestamp::Max ();
358- auto const tp_big_pos = ts_big_pos.get <sys_time<std::chrono::milliseconds >>();
361+ auto const ts_big_pos = internal::TimestampFromCounts ( 20000000000 , 0 ). value ();
362+ auto const tp_big_pos = ts_big_pos.get <sys_time<std::chrono::nanoseconds >>();
359363 EXPECT_FALSE (tp_big_pos.ok ());
360364 EXPECT_THAT (tp_big_pos.status ().message (), HasSubstr (" positive overflow" ));
361365
@@ -380,8 +384,9 @@ TEST(Timestamp, ToChrono) {
380384 auto const tp10 = epoch - std::chrono::hours (2123456789 / 60 / 60 );
381385 EXPECT_EQ (tp10, ts_neg.get <sys_time<std::chrono::hours>>().value ());
382386
383- auto const ts_big_neg = Timestamp::Min ();
384- auto const tp_big_neg = ts_big_neg.get <sys_time<std::chrono::milliseconds>>();
387+ auto const ts_big_neg =
388+ internal::TimestampFromCounts (-20000000000 , 0 ).value ();
389+ auto const tp_big_neg = ts_big_neg.get <sys_time<std::chrono::nanoseconds>>();
385390 EXPECT_FALSE (tp_big_neg.ok ());
386391 EXPECT_THAT (tp_big_neg.status ().message (), HasSubstr (" negative overflow" ));
387392}
0 commit comments