Add explicit |forceOnlineSignin| to user pod status
[chromium-blink-merge.git] / net / quic / congestion_control / quic_max_sized_map_test.cc
blob89c05cccbaf7cfc24e6c96e365d2605b5c61d144
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/logging.h"
6 #include "net/quic/congestion_control/quic_max_sized_map.h"
7 #include "testing/gtest/include/gtest/gtest.h"
9 namespace net {
10 namespace test {
12 class QuicMaxSizedMapTest : public ::testing::Test {
15 TEST_F(QuicMaxSizedMapTest, Basic) {
16 QuicMaxSizedMap<int, int> test_map(100);
17 EXPECT_EQ(100u, test_map.MaxSize());
18 EXPECT_EQ(0u, test_map.Size());
19 test_map.Insert(1, 2);
20 test_map.Insert(1, 3);
21 EXPECT_EQ(100u, test_map.MaxSize());
22 EXPECT_EQ(2u, test_map.Size());
23 test_map.RemoveAll();
24 EXPECT_EQ(100u, test_map.MaxSize());
25 EXPECT_EQ(0u, test_map.Size());
28 TEST_F(QuicMaxSizedMapTest, Find) {
29 QuicMaxSizedMap<int, int> test_map(100);
30 test_map.Insert(1, 2);
31 test_map.Insert(1, 3);
32 test_map.Insert(2, 4);
33 test_map.Insert(3, 5);
34 QuicMaxSizedMap<int, int>::ConstIterator it = test_map.Find(2);
35 EXPECT_TRUE(it != test_map.End());
36 EXPECT_EQ(4, it->second);
37 it = test_map.Find(1);
38 EXPECT_TRUE(it != test_map.End());
39 EXPECT_EQ(2, it->second);
40 ++it;
41 EXPECT_TRUE(it != test_map.End());
42 EXPECT_EQ(3, it->second);
45 TEST_F(QuicMaxSizedMapTest, Sort) {
46 QuicMaxSizedMap<int, int> test_map(100);
47 test_map.Insert(9, 9);
48 test_map.Insert(8, 8);
49 test_map.Insert(7, 7);
50 test_map.Insert(6, 6);
51 test_map.Insert(2, 2);
52 test_map.Insert(4, 4);
53 test_map.Insert(5, 5);
54 test_map.Insert(3, 3);
55 test_map.Insert(0, 0);
56 test_map.Insert(1, 1);
57 QuicMaxSizedMap<int, int>::ConstIterator it = test_map.Begin();
58 for (int i = 0; i < 10; ++i, ++it) {
59 EXPECT_TRUE(it != test_map.End());
60 EXPECT_EQ(i, it->first);
61 EXPECT_EQ(i, it->second);
65 } // namespace test
66 } // namespace net