From 321addf0511571e9910dc13a25221473656419d4 Mon Sep 17 00:00:00 2001 From: Vitaly Goldshteyn Date: Wed, 13 Mar 2024 05:34:23 -0700 Subject: Test that rehash(0) reduces capacity to minimum. PiperOrigin-RevId: 615380243 Change-Id: I5400b40a6bc5ac52ece5d4fa6da7df9e4ff50855 --- absl/container/internal/raw_hash_set_test.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (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 9180db59..66baeb64 100644 --- a/absl/container/internal/raw_hash_set_test.cc +++ b/absl/container/internal/raw_hash_set_test.cc @@ -885,12 +885,17 @@ TYPED_TEST_P(SmallTableResizeTest, ResizeReduceSmallTables) { for (size_t source_size = 0; source_size < 32; ++source_size) { for (size_t target_size = 0; target_size <= source_size; ++target_size) { TypeParam t; - t.reserve(source_size); size_t inserted_count = std::min(source_size, 5); for (size_t i = 0; i < inserted_count; ++i) { t.insert(static_cast(i)); } + const size_t minimum_capacity = t.capacity(); + t.reserve(source_size); t.rehash(target_size); + if (target_size == 0) { + EXPECT_EQ(t.capacity(), minimum_capacity) + << "rehash(0) must resize to the minimum capacity"; + } for (size_t i = 0; i < inserted_count; ++i) { EXPECT_TRUE(t.find(static_cast(i)) != t.end()); EXPECT_EQ(*t.find(static_cast(i)), static_cast(i)); -- cgit v1.2.3