| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 return v.size() == length_; | 35 return v.size() == length_; |
| 36 } | 36 } |
| 37 | 37 |
| 38 private: | 38 private: |
| 39 size_t length_; | 39 size_t length_; |
| 40 }; | 40 }; |
| 41 | 41 |
| 42 } // anonymous namespace | 42 } // anonymous namespace |
| 43 | 43 |
| 44 TEST(SwapQueueTest, BasicOperation) { | 44 TEST(SwapQueueTest, BasicOperation) { |
| 45 const size_t kCapacity = 2; |
| 45 std::vector<int> i(kChunkSize, 0); | 46 std::vector<int> i(kChunkSize, 0); |
| 46 SwapQueue<std::vector<int>> queue(2, i); | 47 SwapQueue<std::vector<int>> queue(kCapacity, i); |
| 47 | 48 |
| 49 EXPECT_EQ(queue.Capacity(), kCapacity); |
| 50 EXPECT_EQ(queue.Size(), 0u); |
| 48 EXPECT_TRUE(queue.Insert(&i)); | 51 EXPECT_TRUE(queue.Insert(&i)); |
| 49 EXPECT_EQ(i.size(), kChunkSize); | 52 EXPECT_EQ(i.size(), kChunkSize); |
| 53 EXPECT_EQ(queue.Size(), 1u); |
| 50 EXPECT_TRUE(queue.Insert(&i)); | 54 EXPECT_TRUE(queue.Insert(&i)); |
| 51 EXPECT_EQ(i.size(), kChunkSize); | 55 EXPECT_EQ(i.size(), kChunkSize); |
| 56 EXPECT_EQ(queue.Size(), 2u); |
| 52 EXPECT_TRUE(queue.Remove(&i)); | 57 EXPECT_TRUE(queue.Remove(&i)); |
| 53 EXPECT_EQ(i.size(), kChunkSize); | 58 EXPECT_EQ(i.size(), kChunkSize); |
| 59 EXPECT_EQ(queue.Size(), 1u); |
| 54 EXPECT_TRUE(queue.Remove(&i)); | 60 EXPECT_TRUE(queue.Remove(&i)); |
| 55 EXPECT_EQ(i.size(), kChunkSize); | 61 EXPECT_EQ(i.size(), kChunkSize); |
| 62 EXPECT_EQ(queue.Size(), 0u); |
| 56 } | 63 } |
| 57 | 64 |
| 58 TEST(SwapQueueTest, FullQueue) { | 65 TEST(SwapQueueTest, FullQueue) { |
| 59 SwapQueue<int> queue(2); | 66 SwapQueue<int> queue(2); |
| 60 | 67 |
| 61 // Fill the queue. | 68 // Fill the queue. |
| 62 int i = 0; | 69 int i = 0; |
| 63 EXPECT_TRUE(queue.Insert(&i)); | 70 EXPECT_TRUE(queue.Insert(&i)); |
| 64 i = 1; | 71 i = 1; |
| 65 EXPECT_TRUE(queue.Insert(&i)); | 72 EXPECT_TRUE(queue.Insert(&i)); |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 EXPECT_TRUE(queue.Insert(&i)); | 223 EXPECT_TRUE(queue.Insert(&i)); |
| 217 i = 43; | 224 i = 43; |
| 218 EXPECT_FALSE(queue.Insert(&i)); | 225 EXPECT_FALSE(queue.Insert(&i)); |
| 219 EXPECT_EQ(i, 43); | 226 EXPECT_EQ(i, 43); |
| 220 EXPECT_TRUE(queue.Remove(&i)); | 227 EXPECT_TRUE(queue.Remove(&i)); |
| 221 EXPECT_EQ(i, 42); | 228 EXPECT_EQ(i, 42); |
| 222 EXPECT_FALSE(queue.Remove(&i)); | 229 EXPECT_FALSE(queue.Remove(&i)); |
| 223 } | 230 } |
| 224 | 231 |
| 225 } // namespace webrtc | 232 } // namespace webrtc |
| OLD | NEW |