Commit daee783c authored by jameslahm's avatar jameslahm Committed by V8 LUCI CQ

[test] Move cctest/test-hashmap to unittests/base/

... hashmap-unittest.

Bug: v8:12781
Change-Id: Id2d4c1d41540791e4c32919d4da4648565ac9faf
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3682880Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Commit-Queue: 王澳 <wangao.james@bytedance.com>
Cr-Commit-Position: refs/heads/main@{#80880}
parent 507e5743
...@@ -199,7 +199,6 @@ v8_source_set("cctest_sources") { ...@@ -199,7 +199,6 @@ v8_source_set("cctest_sources") {
"test-global-handles.cc", "test-global-handles.cc",
"test-global-object.cc", "test-global-object.cc",
"test-hashcode.cc", "test-hashcode.cc",
"test-hashmap.cc",
"test-heap-profiler.cc", "test-heap-profiler.cc",
"test-icache.cc", "test-icache.cc",
"test-identity-map.cc", "test-identity-map.cc",
......
...@@ -234,6 +234,7 @@ v8_source_set("unittests_sources") { ...@@ -234,6 +234,7 @@ v8_source_set("unittests_sources") {
"base/fixed-dtoa-unittest.cc", "base/fixed-dtoa-unittest.cc",
"base/flags-unittest.cc", "base/flags-unittest.cc",
"base/functional-unittest.cc", "base/functional-unittest.cc",
"base/hashmap-unittest.cc",
"base/ieee754-unittest.cc", "base/ieee754-unittest.cc",
"base/iterator-unittest.cc", "base/iterator-unittest.cc",
"base/logging-unittest.cc", "base/logging-unittest.cc",
......
...@@ -25,17 +25,19 @@ ...@@ -25,17 +25,19 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "src/base/hashmap.h"
#include <stdlib.h> #include <stdlib.h>
#include "src/base/overflowing-math.h" #include "src/base/overflowing-math.h"
#include "src/init/v8.h" #include "src/init/v8.h"
#include "test/cctest/cctest.h" #include "test/unittests/test-utils.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "src/base/hashmap.h"
namespace v8 { namespace v8 {
namespace internal { namespace internal {
namespace test_hashmap {
using HashmapTest = ::testing::Test;
using IntKeyHash = uint32_t (*)(uint32_t key); using IntKeyHash = uint32_t (*)(uint32_t key);
...@@ -66,9 +68,7 @@ class IntSet { ...@@ -66,9 +68,7 @@ class IntSet {
return p != nullptr; return p != nullptr;
} }
void Clear() { void Clear() { map_.Clear(); }
map_.Clear();
}
uint32_t occupancy() const { uint32_t occupancy() const {
uint32_t count = 0; uint32_t count = 0;
...@@ -85,10 +85,8 @@ class IntSet { ...@@ -85,10 +85,8 @@ class IntSet {
v8::base::HashMap map_; v8::base::HashMap map_;
}; };
static uint32_t Hash(uint32_t key) { return 23; }
static uint32_t Hash(uint32_t key) { return 23; } static uint32_t CollisionHash(uint32_t key) { return key & 0x3; }
static uint32_t CollisionHash(uint32_t key) { return key & 0x3; }
void TestSet(IntKeyHash hash, int size) { void TestSet(IntKeyHash hash, int size) {
IntSet set(hash); IntSet set(hash);
...@@ -169,12 +167,10 @@ void TestSet(IntKeyHash hash, int size) { ...@@ -169,12 +167,10 @@ void TestSet(IntKeyHash hash, int size) {
CHECK_EQ(0u, set.occupancy()); CHECK_EQ(0u, set.occupancy());
} }
TEST_F(HashmapTest, HashSet) {
TEST(HashSet) {
TestSet(Hash, 100); TestSet(Hash, 100);
TestSet(CollisionHash, 50); TestSet(CollisionHash, 50);
} }
} // namespace test_hashmap
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8
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