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

Side by Side Diff: third_party/WebKit/Source/platform/scheduler/base/intrusive_heap_unittest.cc

Issue 2453013004: Fix use-after-scope bug in IntrusiveHeapTest.HeapIndex. (Closed)
Patch Set: Created 4 years, 1 month 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 // 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/scheduler/base/intrusive_heap.h" 5 #include "platform/scheduler/base/intrusive_heap.h"
6 #include "testing/gmock/include/gmock/gmock.h" 6 #include "testing/gmock/include/gmock/gmock.h"
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 8
9 namespace blink { 9 namespace blink {
10 namespace scheduler { 10 namespace scheduler {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 IntrusiveHeap<TestElement> heap; 97 IntrusiveHeap<TestElement> heap;
98 98
99 for (int i = 0; i < 50; i++) 99 for (int i = 0; i < 50; i++)
100 heap.insert({50 - i, nullptr}); 100 heap.insert({50 - i, nullptr});
101 101
102 EXPECT_EQ(1, heap.min().key); 102 EXPECT_EQ(1, heap.min().key);
103 EXPECT_EQ(50u, heap.size()); 103 EXPECT_EQ(50u, heap.size());
104 } 104 }
105 105
106 TEST(IntrusiveHeapTest, HeapIndex) { 106 TEST(IntrusiveHeapTest, HeapIndex) {
107 IntrusiveHeap<TestElement> heap;
108 HeapHandle index5; 107 HeapHandle index5;
109 HeapHandle index4; 108 HeapHandle index4;
110 HeapHandle index3; 109 HeapHandle index3;
111 HeapHandle index2; 110 HeapHandle index2;
112 HeapHandle index1; 111 HeapHandle index1;
112 IntrusiveHeap<TestElement> heap;
113 113
114 EXPECT_FALSE(index1.IsValid()); 114 EXPECT_FALSE(index1.IsValid());
115 EXPECT_FALSE(index2.IsValid()); 115 EXPECT_FALSE(index2.IsValid());
116 EXPECT_FALSE(index3.IsValid()); 116 EXPECT_FALSE(index3.IsValid());
117 EXPECT_FALSE(index4.IsValid()); 117 EXPECT_FALSE(index4.IsValid());
118 EXPECT_FALSE(index5.IsValid()); 118 EXPECT_FALSE(index5.IsValid());
119 119
120 heap.insert({15, &index5}); 120 heap.insert({15, &index5});
121 heap.insert({14, &index4}); 121 heap.insert({14, &index4});
122 heap.insert({13, &index3}); 122 heap.insert({13, &index3});
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 DCHECK(heap.min().key == j || (heap.min().key % 2) == 0); 350 DCHECK(heap.min().key == j || (heap.min().key % 2) == 0);
351 DCHECK_NE(heap.min().key, 80); 351 DCHECK_NE(heap.min().key, 80);
352 prev = heap.min().key; 352 prev = heap.min().key;
353 heap.pop(); 353 heap.pop();
354 } 354 }
355 } 355 }
356 } 356 }
357 357
358 } // namespace scheduler 358 } // namespace scheduler
359 } // namespace blink 359 } // namespace blink
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