Skip to content

Commit

Permalink
Automated Code Change
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 720778162
  • Loading branch information
Pandemic-Sim Team authored and copybara-github committed Jan 30, 2025
1 parent f62389c commit eed8ab8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
6 changes: 3 additions & 3 deletions agent_based_epidemic_sim/port/deps/time_proto_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,16 @@ absl::Status Validate(const google::protobuf::Timestamp& t) {
absl::Status EncodeGoogleApiProto(absl::Duration d,
google::protobuf::Duration* proto) {
// s and n may both be negative, per the Duration proto spec.
const int64 s = absl::IDivDuration(d, absl::Seconds(1), &d);
const int64 n = absl::IDivDuration(d, absl::Nanoseconds(1), &d);
const int64_t s = absl::IDivDuration(d, absl::Seconds(1), &d);
const int64_t n = absl::IDivDuration(d, absl::Nanoseconds(1), &d);
proto->set_seconds(s);
proto->set_nanos(n);
return Validate(*proto);
}

absl::Status EncodeGoogleApiProto(absl::Time t,
google::protobuf::Timestamp* proto) {
const int64 s = absl::ToUnixSeconds(t);
const int64_t s = absl::ToUnixSeconds(t);
proto->set_seconds(s);
proto->set_nanos((t - absl::FromUnixSeconds(s)) / absl::Nanoseconds(1));
return Validate(*proto);
Expand Down
42 changes: 21 additions & 21 deletions agent_based_epidemic_sim/port/deps/time_proto_util_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

namespace abesim {

google::protobuf::Duration MakeGoogleApiDuration(int64 s, int32 ns) {
google::protobuf::Duration MakeGoogleApiDuration(int64_t s, int32_t ns) {
google::protobuf::Duration proto;
proto.set_seconds(s);
proto.set_nanos(ns);
Expand Down Expand Up @@ -77,7 +77,7 @@ inline absl::Time MakeGoogleApiTimeMin() {
return absl::UnixEpoch() + absl::Seconds(-62135596800);
}

google::protobuf::Timestamp MakeGoogleApiTimestamp(int64 s, int32 ns) {
google::protobuf::Timestamp MakeGoogleApiTimestamp(int64_t s, int32_t ns) {
google::protobuf::Timestamp proto;
proto.set_seconds(s);
proto.set_nanos(ns);
Expand All @@ -90,7 +90,7 @@ google::protobuf::Timestamp MakeGoogleApiTimestamp(int64 s, int32 ns) {
// argument may be either a absl::Duration or a absl::Time. The template P
// represents a google::protobuf::Duration or google::protobuf::Timestamp.
template <typename T, typename P>
void RoundTripGoogleApi(T v, int64 expected_sec, int32 expected_nsec) {
void RoundTripGoogleApi(T v, int64_t expected_sec, int32_t expected_nsec) {
// auto status = EncodeGoogleApiProto(v,
// const auto sor_proto = EncodeGoogleApiProto(v);
// ASSERT_OK(sor_proto);
Expand Down Expand Up @@ -133,13 +133,13 @@ void RoundTripGoogleApi(T v, int64 expected_sec, int32 expected_nsec) {

TEST(ProtoUtilGoogleApi, RoundTripDuration) {
// Shorthand to make the test cases readable.
const auto& s = [](int64 n) { return absl::Seconds(n); };
const auto& ns = [](int64 n) { return absl::Nanoseconds(n); };
const auto& s = [](int64_t n) { return absl::Seconds(n); };
const auto& ns = [](int64_t n) { return absl::Nanoseconds(n); };
const struct {
absl::Duration d;
struct {
int64 sec;
int32 nsec;
int64_t sec;
int32_t nsec;
} expected;
} kTestCases[] = {
{s(0), {0, 0}},
Expand All @@ -161,13 +161,13 @@ TEST(ProtoUtilGoogleApi, RoundTripDuration) {
TEST(ProtoUtilGoogleApi, RoundTripTime) {
// Shorthand to make the test cases readable.
const absl::Time epoch = absl::UnixEpoch(); // The protobuf epoch.
const auto& s = [](int64 n) { return absl::Seconds(n); };
const auto& ns = [](int64 n) { return absl::Nanoseconds(n); };
const auto& s = [](int64_t n) { return absl::Seconds(n); };
const auto& ns = [](int64_t n) { return absl::Nanoseconds(n); };
const struct {
absl::Time t;
struct {
int64 sec;
int32 nsec;
int64_t sec;
int32_t nsec;
} expected;
} kTestCases[] = {
{epoch, {0, 0}},
Expand All @@ -194,8 +194,8 @@ TEST(ProtoUtilGoogleApi, TimeTruncTowardInfPast) {
const struct {
absl::Time t;
struct {
int64 sec;
int32 nsec;
int64_t sec;
int32_t nsec;
} expected;
} kTestCases[] = {
{before_epoch + tick, {-1234567890, 0}},
Expand Down Expand Up @@ -235,14 +235,14 @@ TEST(ProtoUtilGoogleApi, DecodeTimeError) {
const google::protobuf::Timestamp kTestCases[] = {
MakeGoogleApiTimestamp(1, -1), //
MakeGoogleApiTimestamp(1, 999999999 + 1), //
MakeGoogleApiTimestamp(std::numeric_limits<int64>::lowest(), 0),
MakeGoogleApiTimestamp(std::numeric_limits<int64>::max(), 0),
MakeGoogleApiTimestamp(0, std::numeric_limits<int32>::lowest()),
MakeGoogleApiTimestamp(0, std::numeric_limits<int32>::max()),
MakeGoogleApiTimestamp(std::numeric_limits<int64>::lowest(),
std::numeric_limits<int32>::lowest()),
MakeGoogleApiTimestamp(std::numeric_limits<int64>::max(),
std::numeric_limits<int32>::max()),
MakeGoogleApiTimestamp(std::numeric_limits<int64_t>::lowest(), 0),
MakeGoogleApiTimestamp(std::numeric_limits<int64_t>::max(), 0),
MakeGoogleApiTimestamp(0, std::numeric_limits<int32_t>::lowest()),
MakeGoogleApiTimestamp(0, std::numeric_limits<int32_t>::max()),
MakeGoogleApiTimestamp(std::numeric_limits<int64_t>::lowest(),
std::numeric_limits<int32_t>::lowest()),
MakeGoogleApiTimestamp(std::numeric_limits<int64_t>::max(),
std::numeric_limits<int32_t>::max()),
MakeGoogleApiTimestamp(
ToUnixSeconds(MakeGoogleApiTimeMin() - absl::Seconds(1)), 0),
MakeGoogleApiTimestamp(
Expand Down

0 comments on commit eed8ab8

Please sign in to comment.