Commit f7297265 by Abseil Team Committed by Andy Getz

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
parent 17c954d9
...@@ -21,9 +21,9 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") ...@@ -21,9 +21,9 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive( http_archive(
name = "com_google_googletest", name = "com_google_googletest",
# Keep this URL in sync with ABSL_GOOGLETEST_COMMIT in ci/cmake_common.sh. # Keep this URL in sync with ABSL_GOOGLETEST_COMMIT in ci/cmake_common.sh.
urls = ["https://github.com/google/googletest/archive/f5e592d8ee5ffb1d9af5be7f715ce3576b8bf9c4.zip"], # 2021-04-29T14:40:44Z urls = ["https://github.com/google/googletest/archive/5bcd8e3bb929714e031a542d303f818e5a5af45d.zip"], # 2021-06-08T22:36:38Z
strip_prefix = "googletest-f5e592d8ee5ffb1d9af5be7f715ce3576b8bf9c4", strip_prefix = "googletest-5bcd8e3bb929714e031a542d303f818e5a5af45d",
sha256 = "e61e3889bd5cc3e6bc1084d2108ecda2f110c0387ba88b394ffd16043a1d5709", sha256 = "3adecb6686ac7367452561dca518fad5a990fb09c5a961bfa1836f15eb774348",
) )
# Google benchmark. # Google benchmark.
......
...@@ -1553,7 +1553,7 @@ class raw_hash_set { ...@@ -1553,7 +1553,7 @@ class raw_hash_set {
auto layout = MakeLayout(capacity_); auto layout = MakeLayout(capacity_);
char* mem = static_cast<char*>( char* mem = static_cast<char*>(
Allocate<Layout::Alignment()>(&alloc_ref(), layout.AllocSize())); Allocate<Layout::Alignment()>(&alloc_ref(), layout.AllocSize()));
ctrl_ = reinterpret_cast<ctrl_t*>(layout.template Pointer<0>(mem)); ctrl_ = layout.template Pointer<0>(mem);
slots_ = layout.template Pointer<1>(mem); slots_ = layout.template Pointer<1>(mem);
reset_ctrl(); reset_ctrl();
reset_growth_left(); reset_growth_left();
......
...@@ -810,6 +810,14 @@ inline bool operator>=(uint128 lhs, uint128 rhs) { return !(lhs < rhs); } ...@@ -810,6 +810,14 @@ inline bool operator>=(uint128 lhs, uint128 rhs) { return !(lhs < rhs); }
// Unary operators. // Unary operators.
constexpr inline uint128 operator+(uint128 val) {
return val;
}
constexpr inline int128 operator+(int128 val) {
return val;
}
inline uint128 operator-(uint128 val) { inline uint128 operator-(uint128 val) {
uint64_t hi = ~Uint128High64(val); uint64_t hi = ~Uint128High64(val);
uint64_t lo = ~Uint128Low64(val) + 1; uint64_t lo = ~Uint128Low64(val) + 1;
......
...@@ -226,6 +226,11 @@ TEST(Uint128, AllTests) { ...@@ -226,6 +226,11 @@ TEST(Uint128, AllTests) {
EXPECT_EQ(test >>= 1, one); EXPECT_EQ(test >>= 1, one);
EXPECT_EQ(test <<= 1, two); 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(big, -(-big));
EXPECT_EQ(two, -((-one) - 1)); EXPECT_EQ(two, -((-one) - 1));
EXPECT_EQ(absl::Uint128Max(), -one); EXPECT_EQ(absl::Uint128Max(), -one);
...@@ -769,6 +774,19 @@ TEST(Int128, ComparisonTest) { ...@@ -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) { TEST(Int128, UnaryNegationTest) {
int64_t values64[] = {0, 1, 12345, 0x4000000000000000, int64_t values64[] = {0, 1, 12345, 0x4000000000000000,
std::numeric_limits<int64_t>::max()}; std::numeric_limits<int64_t>::max()};
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
# The commit of GoogleTest to be used in the CMake tests in this directory. # The commit of GoogleTest to be used in the CMake tests in this directory.
# Keep this in sync with the commit in the WORKSPACE file. # Keep this in sync with the commit in the WORKSPACE file.
readonly ABSL_GOOGLETEST_COMMIT="f5e592d8ee5ffb1d9af5be7f715ce3576b8bf9c4" readonly ABSL_GOOGLETEST_COMMIT="5bcd8e3bb929714e031a542d303f818e5a5af45d"
# Avoid depending on GitHub by looking for a cached copy of the commit first. # Avoid depending on GitHub by looking for a cached copy of the commit first.
if [[ -r "${KOKORO_GFILE_DIR:-}/distdir/${ABSL_GOOGLETEST_COMMIT}.zip" ]]; then if [[ -r "${KOKORO_GFILE_DIR:-}/distdir/${ABSL_GOOGLETEST_COMMIT}.zip" ]]; then
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment