Skip to content

Commit

Permalink
Add corner cases to time.mojom unit tests
Browse files Browse the repository at this point in the history
Change-Id: Ie6a54f1d172642f27e9ec4f829341e07ccb7beab
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5675449
Reviewed-by: Alex Gough <[email protected]>
Commit-Queue: Alex Gough <[email protected]>
Auto-Submit: Joe Mason <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1322974}
  • Loading branch information
JoeNotCharlesGoogle authored and Chromium LUCI CQ committed Jul 3, 2024
1 parent 9f39229 commit bc73d40
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions mojo/public/cpp/base/time_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@ TEST(TimeTest, Time) {

ASSERT_TRUE(mojo::test::SerializeAndDeserialize<mojom::Time>(in, out));
EXPECT_EQ(in, out);

// Test corner cases.
in = base::Time();
ASSERT_TRUE(mojo::test::SerializeAndDeserialize<mojom::Time>(in, out));
EXPECT_EQ(in, out);

in = base::Time::Max();
ASSERT_TRUE(mojo::test::SerializeAndDeserialize<mojom::Time>(in, out));
EXPECT_EQ(in, out);

in = base::Time::Min();
ASSERT_TRUE(mojo::test::SerializeAndDeserialize<mojom::Time>(in, out));
EXPECT_EQ(in, out);
}

TEST(TimeTest, TimeDelta) {
Expand All @@ -25,6 +38,27 @@ TEST(TimeTest, TimeDelta) {

ASSERT_TRUE(mojo::test::SerializeAndDeserialize<mojom::TimeDelta>(in, out));
EXPECT_EQ(in, out);

// Test corner cases.
in = base::TimeDelta();
ASSERT_TRUE(mojo::test::SerializeAndDeserialize<mojom::TimeDelta>(in, out));
EXPECT_EQ(in, out);

in = base::TimeDelta::Max();
ASSERT_TRUE(mojo::test::SerializeAndDeserialize<mojom::TimeDelta>(in, out));
EXPECT_EQ(in, out);

in = base::TimeDelta::Min();
ASSERT_TRUE(mojo::test::SerializeAndDeserialize<mojom::TimeDelta>(in, out));
EXPECT_EQ(in, out);

in = base::TimeDelta::FiniteMax();
ASSERT_TRUE(mojo::test::SerializeAndDeserialize<mojom::TimeDelta>(in, out));
EXPECT_EQ(in, out);

in = base::TimeDelta::FiniteMin();
ASSERT_TRUE(mojo::test::SerializeAndDeserialize<mojom::TimeDelta>(in, out));
EXPECT_EQ(in, out);
}

TEST(TimeTest, TimeTicks) {
Expand All @@ -33,6 +67,19 @@ TEST(TimeTest, TimeTicks) {

ASSERT_TRUE(mojo::test::SerializeAndDeserialize<mojom::TimeTicks>(in, out));
EXPECT_EQ(in, out);

// Test corner cases.
in = base::TimeTicks();
ASSERT_TRUE(mojo::test::SerializeAndDeserialize<mojom::TimeTicks>(in, out));
EXPECT_EQ(in, out);

in = base::TimeTicks::Max();
ASSERT_TRUE(mojo::test::SerializeAndDeserialize<mojom::TimeTicks>(in, out));
EXPECT_EQ(in, out);

in = base::TimeTicks::Min();
ASSERT_TRUE(mojo::test::SerializeAndDeserialize<mojom::TimeTicks>(in, out));
EXPECT_EQ(in, out);
}

} // namespace time_unittest
Expand Down

0 comments on commit bc73d40

Please sign in to comment.