| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/heap/HeapCompact.h" | 5 #include "platform/heap/HeapCompact.h" |
| 6 | 6 |
| 7 #include "platform/heap/Handle.h" | 7 #include "platform/heap/Handle.h" |
| 8 #include "platform/heap/SparseHeapBitmap.h" | 8 #include "platform/heap/SparseHeapBitmap.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "wtf/Deque.h" | 10 #include "wtf/Deque.h" |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 | 253 |
| 254 using IntMapVector = HeapVector<IntMap>; | 254 using IntMapVector = HeapVector<IntMap>; |
| 255 | 255 |
| 256 Persistent<IntMapVector> intMapVector = new IntMapVector(); | 256 Persistent<IntMapVector> intMapVector = new IntMapVector(); |
| 257 for (size_t i = 0; i < 10; ++i) { | 257 for (size_t i = 0; i < 10; ++i) { |
| 258 IntMap map; | 258 IntMap map; |
| 259 for (size_t j = 0; j < 10; ++j) { | 259 for (size_t j = 0; j < 10; ++j) { |
| 260 IntWrapper* val = IntWrapper::create(j); | 260 IntWrapper* val = IntWrapper::create(j); |
| 261 map.add(val, 10 - j); | 261 map.add(val, 10 - j); |
| 262 } | 262 } |
| 263 intMapVector->append(map); | 263 intMapVector->push_back(map); |
| 264 } | 264 } |
| 265 | 265 |
| 266 EXPECT_EQ(10u, intMapVector->size()); | 266 EXPECT_EQ(10u, intMapVector->size()); |
| 267 for (auto map : *intMapVector) { | 267 for (auto map : *intMapVector) { |
| 268 EXPECT_EQ(10u, map.size()); | 268 EXPECT_EQ(10u, map.size()); |
| 269 for (auto k : map) { | 269 for (auto k : map) { |
| 270 EXPECT_EQ(k.key->value(), 10 - k.value); | 270 EXPECT_EQ(k.key->value(), 10 - k.value); |
| 271 } | 271 } |
| 272 } | 272 } |
| 273 | 273 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 284 | 284 |
| 285 TEST(HeapCompactTest, CompactHashPartVector) { | 285 TEST(HeapCompactTest, CompactHashPartVector) { |
| 286 clearOutOldGarbage(); | 286 clearOutOldGarbage(); |
| 287 | 287 |
| 288 using IntVectorMap = HeapHashMap<int, IntVector>; | 288 using IntVectorMap = HeapHashMap<int, IntVector>; |
| 289 | 289 |
| 290 Persistent<IntVectorMap> intVectorMap = new IntVectorMap(); | 290 Persistent<IntVectorMap> intVectorMap = new IntVectorMap(); |
| 291 for (size_t i = 0; i < 10; ++i) { | 291 for (size_t i = 0; i < 10; ++i) { |
| 292 IntVector vector; | 292 IntVector vector; |
| 293 for (size_t j = 0; j < 10; ++j) { | 293 for (size_t j = 0; j < 10; ++j) { |
| 294 vector.append(IntWrapper::create(j)); | 294 vector.push_back(IntWrapper::create(j)); |
| 295 } | 295 } |
| 296 intVectorMap->add(1 + i, vector); | 296 intVectorMap->add(1 + i, vector); |
| 297 } | 297 } |
| 298 | 298 |
| 299 EXPECT_EQ(10u, intVectorMap->size()); | 299 EXPECT_EQ(10u, intVectorMap->size()); |
| 300 for (const IntVector& intVector : intVectorMap->values()) { | 300 for (const IntVector& intVector : intVectorMap->values()) { |
| 301 EXPECT_EQ(10u, intVector.size()); | 301 EXPECT_EQ(10u, intVector.size()); |
| 302 for (size_t i = 0; i < intVector.size(); ++i) { | 302 for (size_t i = 0; i < intVector.size(); ++i) { |
| 303 EXPECT_EQ(static_cast<int>(i), intVector[i]->value()); | 303 EXPECT_EQ(static_cast<int>(i), intVector[i]->value()); |
| 304 } | 304 } |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 | 452 |
| 453 expected = 0; | 453 expected = 0; |
| 454 for (const Inner* v : *set) { | 454 for (const Inner* v : *set) { |
| 455 EXPECT_EQ(1u, v->size()); | 455 EXPECT_EQ(1u, v->size()); |
| 456 EXPECT_EQ(expected, (*v->begin())->value()); | 456 EXPECT_EQ(expected, (*v->begin())->value()); |
| 457 expected++; | 457 expected++; |
| 458 } | 458 } |
| 459 } | 459 } |
| 460 | 460 |
| 461 } // namespace blink | 461 } // namespace blink |
| OLD | NEW |