summaryrefslogtreecommitdiff
path: root/chromium/net/quic/congestion_control/quic_max_sized_map_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/net/quic/congestion_control/quic_max_sized_map_test.cc')
-rw-r--r--chromium/net/quic/congestion_control/quic_max_sized_map_test.cc66
1 files changed, 66 insertions, 0 deletions
diff --git a/chromium/net/quic/congestion_control/quic_max_sized_map_test.cc b/chromium/net/quic/congestion_control/quic_max_sized_map_test.cc
new file mode 100644
index 00000000000..89c05cccbaf
--- /dev/null
+++ b/chromium/net/quic/congestion_control/quic_max_sized_map_test.cc
@@ -0,0 +1,66 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/logging.h"
+#include "net/quic/congestion_control/quic_max_sized_map.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace net {
+namespace test {
+
+class QuicMaxSizedMapTest : public ::testing::Test {
+};
+
+TEST_F(QuicMaxSizedMapTest, Basic) {
+ QuicMaxSizedMap<int, int> test_map(100);
+ EXPECT_EQ(100u, test_map.MaxSize());
+ EXPECT_EQ(0u, test_map.Size());
+ test_map.Insert(1, 2);
+ test_map.Insert(1, 3);
+ EXPECT_EQ(100u, test_map.MaxSize());
+ EXPECT_EQ(2u, test_map.Size());
+ test_map.RemoveAll();
+ EXPECT_EQ(100u, test_map.MaxSize());
+ EXPECT_EQ(0u, test_map.Size());
+}
+
+TEST_F(QuicMaxSizedMapTest, Find) {
+ QuicMaxSizedMap<int, int> test_map(100);
+ test_map.Insert(1, 2);
+ test_map.Insert(1, 3);
+ test_map.Insert(2, 4);
+ test_map.Insert(3, 5);
+ QuicMaxSizedMap<int, int>::ConstIterator it = test_map.Find(2);
+ EXPECT_TRUE(it != test_map.End());
+ EXPECT_EQ(4, it->second);
+ it = test_map.Find(1);
+ EXPECT_TRUE(it != test_map.End());
+ EXPECT_EQ(2, it->second);
+ ++it;
+ EXPECT_TRUE(it != test_map.End());
+ EXPECT_EQ(3, it->second);
+}
+
+TEST_F(QuicMaxSizedMapTest, Sort) {
+ QuicMaxSizedMap<int, int> test_map(100);
+ test_map.Insert(9, 9);
+ test_map.Insert(8, 8);
+ test_map.Insert(7, 7);
+ test_map.Insert(6, 6);
+ test_map.Insert(2, 2);
+ test_map.Insert(4, 4);
+ test_map.Insert(5, 5);
+ test_map.Insert(3, 3);
+ test_map.Insert(0, 0);
+ test_map.Insert(1, 1);
+ QuicMaxSizedMap<int, int>::ConstIterator it = test_map.Begin();
+ for (int i = 0; i < 10; ++i, ++it) {
+ EXPECT_TRUE(it != test_map.End());
+ EXPECT_EQ(i, it->first);
+ EXPECT_EQ(i, it->second);
+ }
+}
+
+} // namespace test
+} // namespace net