Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2520)

Unified Diff: Source/platform/heap/HeapTest.cpp

Issue 835453002: Add missing buffer reorg on Deque buffer expansion. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/wtf/Deque.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « no previous file | Source/wtf/Deque.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698