diff options
author | Abseil Team <absl-team@google.com> | 2021-06-08 18:40:58 -0700 |
---|---|---|
committer | Andy Getz <durandal@google.com> | 2021-06-08 21:47:46 -0400 |
commit | f72972654b69085b1d58fde04c618b77d3ac6935 (patch) | |
tree | c2bdbd49465093e5035c5cdb695cda4b86854710 /absl/numeric/int128_test.cc | |
parent | 17c954d90d5661e27db8fc5f086085690a8372d9 (diff) |
Export of internal Abseil changes
--
72ce5b636488f17753d110ec18f57132d6180db3 by Derek Mauro <dmauro@google.com>:
Update GoogleTest version used by Abseil
PiperOrigin-RevId: 378296419
--
1eaa36f65315a1cb95c95dfee0bc31307d280d18 by Abseil Team <absl-team@google.com>:
Define unary + operators for absl::int128 and absl::uint128.
These are rarely used but apparently missing.
PiperOrigin-RevId: 377975179
--
1a029d6ff8f9e21ddf0b89949be04c0a56661359 by Abseil Team <absl-team@google.com>:
Remove gratuitous reinterpret_cast.
PiperOrigin-RevId: 377894806
GitOrigin-RevId: 72ce5b636488f17753d110ec18f57132d6180db3
Change-Id: I8a06f69b3489c9aef8260fd271bde2a55f01807f
Diffstat (limited to 'absl/numeric/int128_test.cc')
-rw-r--r-- | absl/numeric/int128_test.cc | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/absl/numeric/int128_test.cc b/absl/numeric/int128_test.cc index bc86c714..c445d89a 100644 --- a/absl/numeric/int128_test.cc +++ b/absl/numeric/int128_test.cc @@ -226,6 +226,11 @@ TEST(Uint128, AllTests) { EXPECT_EQ(test >>= 1, one); EXPECT_EQ(test <<= 1, two); + EXPECT_EQ(big, +big); + EXPECT_EQ(two, +two); + EXPECT_EQ(absl::Uint128Max(), +absl::Uint128Max()); + EXPECT_EQ(zero, +zero); + EXPECT_EQ(big, -(-big)); EXPECT_EQ(two, -((-one) - 1)); EXPECT_EQ(absl::Uint128Max(), -one); @@ -769,6 +774,19 @@ TEST(Int128, ComparisonTest) { } } +TEST(Int128, UnaryPlusTest) { + int64_t values64[] = {0, 1, 12345, 0x4000000000000000, + std::numeric_limits<int64_t>::max()}; + for (int64_t value : values64) { + SCOPED_TRACE(::testing::Message() << "value = " << value); + + EXPECT_EQ(absl::int128(value), +absl::int128(value)); + EXPECT_EQ(absl::int128(-value), +absl::int128(-value)); + EXPECT_EQ(absl::MakeInt128(value, 0), +absl::MakeInt128(value, 0)); + EXPECT_EQ(absl::MakeInt128(-value, 0), +absl::MakeInt128(-value, 0)); + } +} + TEST(Int128, UnaryNegationTest) { int64_t values64[] = {0, 1, 12345, 0x4000000000000000, std::numeric_limits<int64_t>::max()}; |