Index: webrtc/modules/remote_bitrate_estimator/test/bwe_unittest.cc |
diff --git a/webrtc/modules/remote_bitrate_estimator/test/bwe_unittest.cc b/webrtc/modules/remote_bitrate_estimator/test/bwe_unittest.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..a8c475daf68e446d132e569838b8c9448bd22a98 |
--- /dev/null |
+++ b/webrtc/modules/remote_bitrate_estimator/test/bwe_unittest.cc |
@@ -0,0 +1,90 @@ |
+/* |
+ * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
+ * |
+ * Use of this source code is governed by a BSD-style license |
+ * that can be found in the LICENSE file in the root of the source |
+ * tree. An additional intellectual property rights grant can be found |
+ * in the file PATENTS. All contributing project authors may |
+ * be found in the AUTHORS file in the root of the source tree. |
+ */ |
+ |
+#include "webrtc/modules/remote_bitrate_estimator/test/bwe.h" |
+ |
+#include <vector> |
+ |
+#include "testing/gtest/include/gtest/gtest.h" |
+ |
+namespace webrtc { |
+namespace testing { |
+namespace bwe { |
+ |
+const int kSetCapacity = 10000; |
+ |
+class LinkedSetTest : public ::testing::Test { |
+ public: |
+ LinkedSetTest() : linked_set_(kSetCapacity) {} |
+ ~LinkedSetTest() {} |
+ |
+ protected: |
+ LinkedSet linked_set_; |
+}; |
+ |
+TEST_F(LinkedSetTest, EmptySet) { |
+ EXPECT_EQ(linked_set_.Max(), 0); |
+ EXPECT_EQ(linked_set_.Min(), 0); |
+ EXPECT_EQ(linked_set_.OldestSeqNumber(), 0); |
+ EXPECT_EQ(linked_set_.NewestSeqNumber(), 0); |
+} |
+ |
+TEST_F(LinkedSetTest, SinglePacket) { |
+ const uint16_t kSeqNumber = 1; // Arbitrary. |
+ // Other parameters don't matter here. |
+ linked_set_.Insert(kSeqNumber, 0, 0, 0); |
+ EXPECT_EQ(linked_set_.Max(), kSeqNumber); |
+ EXPECT_EQ(linked_set_.Min(), kSeqNumber); |
+ EXPECT_EQ(linked_set_.OldestSeqNumber(), kSeqNumber); |
+ EXPECT_EQ(linked_set_.NewestSeqNumber(), kSeqNumber); |
+} |
+ |
+TEST_F(LinkedSetTest, MultiplePackets) { |
+ const uint16_t kNumberPackets = 100; |
+ |
+ std::vector<uint16_t> sequence_numbers; |
+ for (size_t i = 0; i < kNumberPackets; ++i) { |
+ sequence_numbers.push_back(static_cast<uint16_t>(i + 1)); |
+ } |
+ random_shuffle(sequence_numbers.begin(), sequence_numbers.end()); |
+ |
+ for (size_t i = 0; i < kNumberPackets; ++i) { |
+ // Other parameters don't matter here. |
+ linked_set_.Insert(static_cast<uint16_t>(i), 0, 0, 0); |
+ } |
+ |
+ // Packets arriving out of order should not affect the following values: |
+ EXPECT_EQ(linked_set_.Max(), kNumberPackets - 1); |
+ EXPECT_EQ(linked_set_.Min(), 0); |
+ EXPECT_EQ(linked_set_.OldestSeqNumber(), 0); |
+ EXPECT_EQ(linked_set_.NewestSeqNumber(), kNumberPackets - 1); |
+} |
+ |
+TEST_F(LinkedSetTest, Overflow) { |
+ const int kFirstSeqNumber = -100; |
+ const int kLastSeqNumber = 100; |
+ |
+ for (int i = kFirstSeqNumber; i <= kLastSeqNumber; ++i) { |
+ // Other parameters don't matter here. |
+ linked_set_.Insert(static_cast<uint16_t>(i), 0, 0, 0); |
+ } |
+ |
+ // Packets arriving out of order should not affect the following values: |
+ EXPECT_EQ(linked_set_.Max(), 0xFFFF); |
+ EXPECT_EQ(linked_set_.Min(), 0); |
+ EXPECT_EQ(linked_set_.OldestSeqNumber(), |
+ static_cast<uint16_t>(kFirstSeqNumber)); |
+ EXPECT_EQ(linked_set_.NewestSeqNumber(), |
+ static_cast<uint16_t>(kLastSeqNumber)); |
+} |
+ |
+} // namespace bwe |
+} // namespace testing |
+} // namespace webrtc |