Re-add third-party/abseil-cpp

Bug: 261600888
Test: no build files yet
Change-Id: If35de46c822c629640fa888126290b98ee4dc41d
This commit is contained in:
Jorge E. Moreira
2022-12-06 16:44:51 -08:00
parent 16476ad1d2
commit 2c058104e3
646 changed files with 53674 additions and 8750 deletions

View File

@ -43,12 +43,14 @@ cc_test(
linkopts = ABSL_DEFAULT_LINKOPTS,
deps = [
":algorithm",
"//absl/base:config",
"@com_google_googletest//:gtest_main",
],
)
cc_test(
cc_binary(
name = "algorithm_benchmark",
testonly = 1,
srcs = ["equal_benchmark.cc"],
copts = ABSL_TEST_COPTS,
linkopts = ABSL_DEFAULT_LINKOPTS,

View File

@ -0,0 +1,38 @@
# Copyright 2018 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//third_party/abseil-cpp/absl.gni")
absl_source_set("algorithm") {
public = [ "algorithm.h" ]
deps = [ "//third_party/abseil-cpp/absl/base:config" ]
}
absl_source_set("container") {
public = [ "container.h" ]
deps = [
":algorithm",
"//third_party/abseil-cpp/absl/base:core_headers",
"//third_party/abseil-cpp/absl/meta:type_traits",
]
}
absl_test("algorithm_test") {
sources = [ "algorithm_test.cc" ]
deps = [
":algorithm",
"//third_party/abseil-cpp/absl/base:config",
]
}
absl_test("container_test") {
sources = [ "container_test.cc" ]
deps = [
":container",
"//third_party/abseil-cpp/absl/base",
"//third_party/abseil-cpp/absl/base:core_headers",
"//third_party/abseil-cpp/absl/memory",
"//third_party/abseil-cpp/absl/types:span",
]
}

View File

@ -35,6 +35,7 @@ absl_cc_test(
${ABSL_TEST_COPTS}
DEPS
absl::algorithm
absl::config
GTest::gmock_main
)

View File

@ -20,6 +20,7 @@
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "absl/base/config.h"
namespace {
@ -50,7 +51,15 @@ TEST(EqualTest, EmptyRange) {
std::vector<int> empty1;
std::vector<int> empty2;
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105705
#if ABSL_INTERNAL_HAVE_MIN_GNUC_VERSION(12, 0)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wnonnull"
#endif
EXPECT_FALSE(absl::equal(v1.begin(), v1.end(), empty1.begin(), empty1.end()));
#if ABSL_INTERNAL_HAVE_MIN_GNUC_VERSION(12, 0)
#pragma GCC diagnostic pop
#endif
EXPECT_FALSE(absl::equal(empty1.begin(), empty1.end(), v1.begin(), v1.end()));
EXPECT_TRUE(
absl::equal(empty1.begin(), empty1.end(), empty2.begin(), empty2.end()));

View File

@ -166,7 +166,7 @@ container_algorithm_internal::ContainerDifferenceType<const C> c_distance(
// c_all_of()
//
// Container-based version of the <algorithm> `std::all_of()` function to
// test a condition on all elements within a container.
// test if all elements within a container satisfy a condition.
template <typename C, typename Pred>
bool c_all_of(const C& c, Pred&& pred) {
return std::all_of(container_algorithm_internal::c_begin(c),

View File

@ -67,13 +67,16 @@ bool Equals(int v1, int v2) { return v1 == v2; }
bool IsOdd(int x) { return x % 2 != 0; }
TEST_F(NonMutatingTest, Distance) {
EXPECT_EQ(container_.size(), absl::c_distance(container_));
EXPECT_EQ(sequence_.size(), absl::c_distance(sequence_));
EXPECT_EQ(vector_.size(), absl::c_distance(vector_));
EXPECT_EQ(ABSL_ARRAYSIZE(array_), absl::c_distance(array_));
EXPECT_EQ(container_.size(),
static_cast<size_t>(absl::c_distance(container_)));
EXPECT_EQ(sequence_.size(), static_cast<size_t>(absl::c_distance(sequence_)));
EXPECT_EQ(vector_.size(), static_cast<size_t>(absl::c_distance(vector_)));
EXPECT_EQ(ABSL_ARRAYSIZE(array_),
static_cast<size_t>(absl::c_distance(array_)));
// Works with a temporary argument.
EXPECT_EQ(vector_.size(), absl::c_distance(std::vector<int>(vector_)));
EXPECT_EQ(vector_.size(),
static_cast<size_t>(absl::c_distance(std::vector<int>(vector_))));
}
TEST_F(NonMutatingTest, Distance_OverloadedBeginEnd) {

View File

@ -15,8 +15,8 @@
#include <cstdint>
#include <cstring>
#include "benchmark/benchmark.h"
#include "absl/algorithm/algorithm.h"
#include "benchmark/benchmark.h"
namespace {