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

Unified Diff: third_party/WebKit/Source/wtf/DequeTest.cpp

Issue 2581673002: NOT FOR REVIEW: Repro test of WTF::Deque for crbug.com/674287
Patch Set: . Created 4 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/wtf/DequeTest.cpp
diff --git a/third_party/WebKit/Source/wtf/DequeTest.cpp b/third_party/WebKit/Source/wtf/DequeTest.cpp
index 4305cf25da20673940ff030db475a82d2e42e84a..54939aa7a0d9870eb5fa6fe7b4e5161ad34c515b 100644
--- a/third_party/WebKit/Source/wtf/DequeTest.cpp
+++ b/third_party/WebKit/Source/wtf/DequeTest.cpp
@@ -29,6 +29,7 @@
#include "wtf/HashSet.h"
#include "wtf/PtrUtil.h"
#include <memory>
+#include <deque>
namespace WTF {
@@ -603,6 +604,49 @@ TEST(DequeTest, RemoveWhileIterating) {
}
}
+// This fails.
+TEST(DequeTest, WTFDequePointersStability) {
+ Deque<int> deque;
+ deque.append(42);
+ int* ptr = &deque.first();
+ ASSERT_EQ(42, *ptr);
+ for (int i = 1; i < 10000; i++) {
+ deque.append(i);
+ ASSERT_EQ(42, *ptr) << " @ iteration " << i;
+ // ASSERT_EQ(ptr, &deque.first()) << "iteration " << i;
+ }
+}
+
+// This fails.
+TEST(DequeTest, WTFDequeNoInlineCapacityPointersStability) {
+ Deque<int, 2 /*inline capacity*/> deque;
+
+ // Fill up the inline capacity.
+ for (int i = 0; i < 128; ++i)
+ deque.append(-1);
+
+ deque.append(42);
+ int* ptr = &deque.last();
+ ASSERT_EQ(42, *ptr);
+ for (int i = 1; i < 10000; i++) {
+ deque.append(1);
+ ASSERT_EQ(42, *ptr) << " @ iteration " << i;
+ }
+}
+
+// This passes.
+TEST(DequeTest, StdDequePointersStability) {
+ std::deque<int> deque;
+ deque.push_back(42);
+ int* ptr = &deque.front();
+ ASSERT_EQ(42, *ptr);
+ for (int i = 1; i < 10000; i++) {
+ deque.push_back(i);
+ ASSERT_EQ(ptr, &deque.front()) << "iteration " << i;
+ ASSERT_EQ(42, *ptr);
+ }
+}
+
} // anonymous namespace
} // namespace WTF
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698