| 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 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
| 7 | 7 |
| 8 namespace net { | 8 namespace net { |
| 9 | 9 |
| 10 namespace { | 10 namespace { |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 EXPECT_EQ(kLastMaxOrder[i], queue_.LastMax().value()); | 84 EXPECT_EQ(kLastMaxOrder[i], queue_.LastMax().value()); |
| 85 queue_.Erase(queue_.LastMax()); | 85 queue_.Erase(queue_.LastMax()); |
| 86 } | 86 } |
| 87 CheckEmpty(); | 87 CheckEmpty(); |
| 88 } | 88 } |
| 89 | 89 |
| 90 TEST_F(PriorityQueueTest, EraseFromMiddle) { | 90 TEST_F(PriorityQueueTest, EraseFromMiddle) { |
| 91 queue_.Erase(pointers_[2]); | 91 queue_.Erase(pointers_[2]); |
| 92 queue_.Erase(pointers_[3]); | 92 queue_.Erase(pointers_[3]); |
| 93 | 93 |
| 94 int expected_order[] = { 8, 1, 6, 0, 5, 4, 7 }; | 94 const int expected_order[] = { 8, 1, 6, 0, 5, 4, 7 }; |
| 95 | 95 |
| 96 for (size_t i = 0; i < arraysize(expected_order); ++i) { | 96 for (size_t i = 0; i < arraysize(expected_order); ++i) { |
| 97 EXPECT_EQ(expected_order[i], queue_.FirstMin().value()); | 97 EXPECT_EQ(expected_order[i], queue_.FirstMin().value()); |
| 98 queue_.Erase(queue_.FirstMin()); | 98 queue_.Erase(queue_.FirstMin()); |
| 99 } | 99 } |
| 100 CheckEmpty(); | 100 CheckEmpty(); |
| 101 } | 101 } |
| 102 | 102 |
| 103 TEST_F(PriorityQueueTest, InsertAtFront) { |
| 104 queue_.InsertAtFront(9, 2); |
| 105 queue_.InsertAtFront(10, 0); |
| 106 queue_.InsertAtFront(11, 1); |
| 107 queue_.InsertAtFront(12, 1); |
| 108 |
| 109 const int expected_order[] = { 10, 3, 8, 12, 11, 1, 6, 9, 0, 2, 5, 4, 7 }; |
| 110 |
| 111 for (size_t i = 0; i < arraysize(expected_order); ++i) { |
| 112 EXPECT_EQ(expected_order[i], queue_.FirstMin().value()); |
| 113 queue_.Erase(queue_.FirstMin()); |
| 114 } |
| 115 CheckEmpty(); |
| 116 } |
| 117 |
| 103 } // namespace | 118 } // namespace |
| 104 | 119 |
| 105 } // namespace net | 120 } // namespace net |
| OLD | NEW |