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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2011 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 11 matching lines...) Expand all
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE. 23 * THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #include "wtf/Deque.h" 26 #include "wtf/Deque.h"
27 27
28 #include "testing/gtest/include/gtest/gtest.h" 28 #include "testing/gtest/include/gtest/gtest.h"
29 #include "wtf/HashSet.h" 29 #include "wtf/HashSet.h"
30 #include "wtf/PtrUtil.h" 30 #include "wtf/PtrUtil.h"
31 #include <memory> 31 #include <memory>
32 #include <deque>
32 33
33 namespace WTF { 34 namespace WTF {
34 35
35 namespace { 36 namespace {
36 37
37 TEST(DequeTest, Basic) { 38 TEST(DequeTest, Basic) {
38 Deque<int> intDeque; 39 Deque<int> intDeque;
39 EXPECT_TRUE(intDeque.isEmpty()); 40 EXPECT_TRUE(intDeque.isEmpty());
40 EXPECT_EQ(0ul, intDeque.size()); 41 EXPECT_EQ(0ul, intDeque.size());
41 } 42 }
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 } 597 }
597 598
598 // Only odd numbers left. 599 // Only odd numbers left.
599 { 600 {
600 int i = 1; 601 int i = 1;
601 for (int v : deque) 602 for (int v : deque)
602 EXPECT_EQ(i + 2, v); 603 EXPECT_EQ(i + 2, v);
603 } 604 }
604 } 605 }
605 606
607 // This fails.
608 TEST(DequeTest, WTFDequePointersStability) {
609 Deque<int> deque;
610 deque.append(42);
611 int* ptr = &deque.first();
612 ASSERT_EQ(42, *ptr);
613 for (int i = 1; i < 10000; i++) {
614 deque.append(i);
615 ASSERT_EQ(42, *ptr) << " @ iteration " << i;
616 // ASSERT_EQ(ptr, &deque.first()) << "iteration " << i;
617 }
618 }
619
620 // This fails.
621 TEST(DequeTest, WTFDequeNoInlineCapacityPointersStability) {
622 Deque<int, 2 /*inline capacity*/> deque;
623
624 // Fill up the inline capacity.
625 for (int i = 0; i < 128; ++i)
626 deque.append(-1);
627
628 deque.append(42);
629 int* ptr = &deque.last();
630 ASSERT_EQ(42, *ptr);
631 for (int i = 1; i < 10000; i++) {
632 deque.append(1);
633 ASSERT_EQ(42, *ptr) << " @ iteration " << i;
634 }
635 }
636
637 // This passes.
638 TEST(DequeTest, StdDequePointersStability) {
639 std::deque<int> deque;
640 deque.push_back(42);
641 int* ptr = &deque.front();
642 ASSERT_EQ(42, *ptr);
643 for (int i = 1; i < 10000; i++) {
644 deque.push_back(i);
645 ASSERT_EQ(ptr, &deque.front()) << "iteration " << i;
646 ASSERT_EQ(42, *ptr);
647 }
648 }
649
606 } // anonymous namespace 650 } // anonymous namespace
607 651
608 } // namespace WTF 652 } // namespace WTF
OLDNEW
« 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