From 522606b7fae37836c138e83f6eec0eabb9947dc0 Mon Sep 17 00:00:00 2001 From: Evan Brown Date: Thu, 8 Dec 2022 14:15:12 -0800 Subject: Fix some ClangTidy warnings in raw_hash_set code. PiperOrigin-RevId: 493993005 Change-Id: I0705be8678022a9e08a1af9972687b7955593994 --- absl/container/internal/raw_hash_set_test.cc | 29 ++++++++-------------------- 1 file changed, 8 insertions(+), 21 deletions(-) (limited to 'absl/container/internal/raw_hash_set_test.cc') diff --git a/absl/container/internal/raw_hash_set_test.cc b/absl/container/internal/raw_hash_set_test.cc index 74351c09..eb0757b2 100644 --- a/absl/container/internal/raw_hash_set_test.cc +++ b/absl/container/internal/raw_hash_set_test.cc @@ -399,7 +399,7 @@ struct StringEq : std::equal_to { struct StringTable : raw_hash_set> { using Base = typename StringTable::raw_hash_set; - StringTable() {} + StringTable() = default; using Base::Base; }; @@ -419,7 +419,7 @@ struct Uint8Table template struct CustomAlloc : std::allocator { - CustomAlloc() {} + CustomAlloc() = default; template explicit CustomAlloc(const CustomAlloc& /*other*/) {} @@ -446,7 +446,7 @@ struct BadFastHash { struct BadTable : raw_hash_set, std::allocator> { using Base = typename BadTable::raw_hash_set; - BadTable() {} + BadTable() = default; using Base::Base; }; @@ -1003,7 +1003,7 @@ TEST(Table, ClearBug) { // We are checking that original and second are close enough to each other // that they are probably still in the same group. This is not strictly // guaranteed. - EXPECT_LT(std::abs(original - second), + EXPECT_LT(static_cast(std::abs(original - second)), capacity * sizeof(IntTable::value_type)); } @@ -1080,19 +1080,6 @@ struct ProbeStats { // Ratios total_probe_length/size for every tested table. std::vector single_table_ratios; - friend ProbeStats operator+(const ProbeStats& a, const ProbeStats& b) { - ProbeStats res = a; - res.all_probes_histogram.resize(std::max(res.all_probes_histogram.size(), - b.all_probes_histogram.size())); - std::transform(b.all_probes_histogram.begin(), b.all_probes_histogram.end(), - res.all_probes_histogram.begin(), - res.all_probes_histogram.begin(), std::plus()); - res.single_table_ratios.insert(res.single_table_ratios.end(), - b.single_table_ratios.begin(), - b.single_table_ratios.end()); - return res; - } - // Average ratio total_probe_length/size over tables. double AvgRatio() const { return std::accumulate(single_table_ratios.begin(), @@ -1555,7 +1542,7 @@ TEST(Table, CopyConstructWithAlloc) { struct ExplicitAllocIntTable : raw_hash_set, std::equal_to, Alloc> { - ExplicitAllocIntTable() {} + ExplicitAllocIntTable() = default; }; TEST(Table, AllocWithExplicitCtor) { @@ -1943,7 +1930,7 @@ TEST(Nodes, ExtractInsert) { EXPECT_FALSE(res.inserted); EXPECT_THAT(*res.position, Pair(k0, "")); EXPECT_TRUE(res.node); - EXPECT_FALSE(node); + EXPECT_FALSE(node); // NOLINT(bugprone-use-after-move) } TEST(Nodes, HintInsert) { @@ -1953,7 +1940,7 @@ TEST(Nodes, HintInsert) { auto it = t.insert(t.begin(), std::move(node)); EXPECT_THAT(t, UnorderedElementsAre(1, 2, 3)); EXPECT_EQ(*it, 1); - EXPECT_FALSE(node); + EXPECT_FALSE(node); // NOLINT(bugprone-use-after-move) node = t.extract(2); EXPECT_THAT(t, UnorderedElementsAre(1, 3)); @@ -1963,7 +1950,7 @@ TEST(Nodes, HintInsert) { it = t.insert(t.begin(), std::move(node)); EXPECT_EQ(*it, 2); // The node was not emptied by the insert call. - EXPECT_TRUE(node); + EXPECT_TRUE(node); // NOLINT(bugprone-use-after-move) } IntTable MakeSimpleTable(size_t size) { -- cgit v1.2.3