OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "net/base/priority_queue.h" | 5 #include "net/base/priority_queue.h" |
6 | 6 |
7 #include <cstddef> | 7 #include <cstddef> |
8 | 8 |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
82 for (; !p.is_null() && i < kNumElements; | 82 for (; !p.is_null() && i < kNumElements; |
83 p = queue_.GetNextTowardsLastMin(p), ++i) { | 83 p = queue_.GetNextTowardsLastMin(p), ++i) { |
84 EXPECT_EQ(kFirstMaxOrder[i], p.value()); | 84 EXPECT_EQ(kFirstMaxOrder[i], p.value()); |
85 } | 85 } |
86 EXPECT_TRUE(p.is_null()); | 86 EXPECT_TRUE(p.is_null()); |
87 EXPECT_EQ(kNumElements, i); | 87 EXPECT_EQ(kNumElements, i); |
88 queue_.Clear(); | 88 queue_.Clear(); |
89 CheckEmpty(); | 89 CheckEmpty(); |
90 } | 90 } |
91 | 91 |
92 TEST_F(PriorityQueueTest, FirstMaxOrderWithDeletion) { | |
szym
2013/11/15 19:48:52
The name suggests this is the same as FirstMaxOrde
oystein (OOO til 10th of July)
2013/11/15 19:52:20
Done.
| |
93 PriorityQueue<int>::Pointer current = queue_.FirstMax(); | |
94 for (size_t i = 0; i < kNumElements; ++i) { | |
95 EXPECT_FALSE(current.is_null()); | |
96 EXPECT_EQ(kFirstMaxOrder[i], current.value()); | |
97 PriorityQueue<int>::Pointer next = queue_.GetNextTowardsLastMin(current); | |
98 queue_.Erase(current); | |
99 current = next; | |
100 } | |
101 EXPECT_TRUE(current.is_null()); | |
102 CheckEmpty(); | |
103 } | |
104 | |
92 TEST_F(PriorityQueueTest, FirstMaxOrderErase) { | 105 TEST_F(PriorityQueueTest, FirstMaxOrderErase) { |
93 for (size_t i = 0; i < kNumElements; ++i) { | 106 for (size_t i = 0; i < kNumElements; ++i) { |
94 EXPECT_EQ(kFirstMaxOrder[i], queue_.FirstMax().value()); | 107 EXPECT_EQ(kFirstMaxOrder[i], queue_.FirstMax().value()); |
95 queue_.Erase(queue_.FirstMax()); | 108 queue_.Erase(queue_.FirstMax()); |
96 } | 109 } |
97 CheckEmpty(); | 110 CheckEmpty(); |
98 } | 111 } |
99 | 112 |
100 TEST_F(PriorityQueueTest, LastMaxOrderErase) { | 113 TEST_F(PriorityQueueTest, LastMaxOrderErase) { |
101 for (size_t i = 0; i < kNumElements; ++i) { | 114 for (size_t i = 0; i < kNumElements; ++i) { |
(...skipping 27 matching lines...) Expand all Loading... | |
129 for (size_t i = 0; i < arraysize(expected_order); ++i) { | 142 for (size_t i = 0; i < arraysize(expected_order); ++i) { |
130 EXPECT_EQ(expected_order[i], queue_.FirstMin().value()); | 143 EXPECT_EQ(expected_order[i], queue_.FirstMin().value()); |
131 queue_.Erase(queue_.FirstMin()); | 144 queue_.Erase(queue_.FirstMin()); |
132 } | 145 } |
133 CheckEmpty(); | 146 CheckEmpty(); |
134 } | 147 } |
135 | 148 |
136 } // namespace | 149 } // namespace |
137 | 150 |
138 } // namespace net | 151 } // namespace net |
OLD | NEW |