MCPcopy Create free account
hub / github.com/apache/brpc / TEST

Function TEST

test/small_map_unittest.cc:19–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17namespace butil {
18
19TEST(SmallMap, General) {
20 SmallMap<hash_map<int, int> > m;
21
22 EXPECT_TRUE(m.empty());
23
24 m[0] = 5;
25
26 EXPECT_FALSE(m.empty());
27 EXPECT_EQ(m.size(), 1u);
28
29 m[9] = 2;
30
31 EXPECT_FALSE(m.empty());
32 EXPECT_EQ(m.size(), 2u);
33
34 EXPECT_EQ(m[9], 2);
35 EXPECT_EQ(m[0], 5);
36 EXPECT_FALSE(m.UsingFullMap());
37
38 SmallMap<hash_map<int, int> >::iterator iter(m.begin());
39 ASSERT_TRUE(iter != m.end());
40 EXPECT_EQ(iter->first, 0);
41 EXPECT_EQ(iter->second, 5);
42 ++iter;
43 ASSERT_TRUE(iter != m.end());
44 EXPECT_EQ((*iter).first, 9);
45 EXPECT_EQ((*iter).second, 2);
46 ++iter;
47 EXPECT_TRUE(iter == m.end());
48
49 m[8] = 23;
50 m[1234] = 90;
51 m[-5] = 6;
52
53 EXPECT_EQ(m[ 9], 2);
54 EXPECT_EQ(m[ 0], 5);
55 EXPECT_EQ(m[1234], 90);
56 EXPECT_EQ(m[ 8], 23);
57 EXPECT_EQ(m[ -5], 6);
58 EXPECT_EQ(m.size(), 5u);
59 EXPECT_FALSE(m.empty());
60 EXPECT_TRUE(m.UsingFullMap());
61
62 iter = m.begin();
63 for (int i = 0; i < 5; i++) {
64 EXPECT_TRUE(iter != m.end());
65 ++iter;
66 }
67 EXPECT_TRUE(iter == m.end());
68
69 const SmallMap<hash_map<int, int> >& ref = m;
70 EXPECT_TRUE(ref.find(1234) != m.end());
71 EXPECT_TRUE(ref.find(5678) == m.end());
72}
73
74TEST(SmallMap, PostFixIteratorIncrement) {
75 SmallMap<hash_map<int, int> > m;

Callers

nothing calls this directly

Calls 12

SmallMapEqualFunction · 0.85
UsingFullMapMethod · 0.80
emptyMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
findMethod · 0.45
insertMethod · 0.45
countMethod · 0.45
eraseMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected