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") {
"test-global-handles.cc",
"test-global-object.cc",
"test-hashcode.cc",
"test-hashmap.cc",
"test-heap-profiler.cc",
"test-icache.cc",
"test-identity-map.cc",
......
......@@ -234,6 +234,7 @@ v8_source_set("unittests_sources") {
"base/fixed-dtoa-unittest.cc",
"base/flags-unittest.cc",
"base/functional-unittest.cc",
"base/hashmap-unittest.cc",
"base/ieee754-unittest.cc",
"base/iterator-unittest.cc",
"base/logging-unittest.cc",
......
......@@ -25,17 +25,19 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "src/base/hashmap.h"
#include <stdlib.h>
#include "src/base/overflowing-math.h"
#include "src/init/v8.h"
#include "test/cctest/cctest.h"
#include "src/base/hashmap.h"
#include "test/unittests/test-utils.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace v8 {
namespace internal {
namespace test_hashmap {
using HashmapTest = ::testing::Test;
using IntKeyHash = uint32_t (*)(uint32_t key);
......@@ -66,9 +68,7 @@ class IntSet {
return p != nullptr;
}
void Clear() {
map_.Clear();
}
void Clear() { map_.Clear(); }
uint32_t occupancy() const {
uint32_t count = 0;
......@@ -85,10 +85,8 @@ class IntSet {
v8::base::HashMap map_;
};
static uint32_t Hash(uint32_t key) { return 23; }
static uint32_t CollisionHash(uint32_t key) { return key & 0x3; }
static uint32_t Hash(uint32_t key) { return 23; }
static uint32_t CollisionHash(uint32_t key) { return key & 0x3; }
void TestSet(IntKeyHash hash, int size) {
IntSet set(hash);
......@@ -169,12 +167,10 @@ void TestSet(IntKeyHash hash, int size) {
CHECK_EQ(0u, set.occupancy());
}
TEST(HashSet) {
TEST_F(HashmapTest, HashSet) {
TestSet(Hash, 100);
TestSet(CollisionHash, 50);
}
} // namespace test_hashmap
} // namespace internal
} // 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