Chromium Code Reviews| Index: Source/platform/heap/HeapTest.cpp |
| diff --git a/Source/platform/heap/HeapTest.cpp b/Source/platform/heap/HeapTest.cpp |
| index 6c7f071a9fb7bab7a3fbc34f9f1ed2b223d3277d..46b50d355b540799cc096fc675f28c59fe10f614 100644 |
| --- a/Source/platform/heap/HeapTest.cpp |
| +++ b/Source/platform/heap/HeapTest.cpp |
| @@ -5347,4 +5347,48 @@ TEST(HeapTest, TraceDeepEagerly) |
| #endif |
| } |
| +TEST(HeapTest, DequeExpand) |
| +{ |
| + // Test expansion of a HeapDeque<>'s buffer. |
| + |
| + typedef HeapDeque<Member<IntWrapper>> IntDeque; |
| + |
| + Persistent<IntDeque> deque = new IntDeque(); |
| + |
| + // Append a sequence, bringing about expansion of the |
|
Nico
2014/12/31 01:21:38
of the…?
|
| + int i = 0; |
| + for (; i < 60; ++i) |
| + deque->append(IntWrapper::create(i)); |
| + |
| + EXPECT_EQ(60u, deque->size()); |
| + i = 0; |
| + for (const auto& intWrapper : *deque) { |
| + EXPECT_EQ(i, intWrapper->value()); |
| + i++; |
| + } |
| + |
| + // Remove most of the queued objects.. |
| + for (i = 0; i < 50; ++i) |
| + deque->takeFirst(); |
| + |
| + EXPECT_EQ(10u, deque->size()); |
| + i = 0; |
| + for (const auto& intWrapper : *deque) { |
| + EXPECT_EQ(50 + i, intWrapper->value()); |
| + i++; |
| + } |
| + |
| + // Append even more, eventually causing an expansion of the |
| + // underlying buffer. |
| + for (i = 0; i < 70; ++i) |
| + deque->append(IntWrapper::create(60 + i)); |
| + |
| + EXPECT_EQ(80u, deque->size()); |
| + i = 0; |
| + for (const auto& intWrapper : *deque) { |
| + EXPECT_EQ(i + 50, intWrapper->value()); |
| + i++; |
| + } |
| +} |
| + |
| } // namespace blink |