MCPcopy Create free account
hub / github.com/catboost/catboost / DoTestMap1

Function DoTestMap1

util/generic/map_ut.cpp:39–67  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37
38 template <typename TAlloc>
39 void DoTestMap1(TMap<char, int, TLess<char>, TAlloc>& m) {
40 using maptype = TMap<char, int, TLess<char>, TAlloc>;
41 // Store mappings between roman numerals and decimals.
42 m['l'] = 50;
43 m['x'] = 20; // Deliberate mistake.
44 m['v'] = 5;
45 m['i'] = 1;
46
47 UNIT_ASSERT(m['x'] == 20);
48 m['x'] = 10; // Correct mistake.
49 UNIT_ASSERT(m['x'] == 10);
50 UNIT_ASSERT(m['z'] == 0);
51
52 UNIT_ASSERT(m.count('z') == 1);
53
54 std::pair<typename maptype::iterator, bool> p = m.insert(std::pair<const char, int>('c', 100));
55
56 UNIT_ASSERT(p.second);
57 UNIT_ASSERT(p.first != m.end());
58 UNIT_ASSERT((*p.first).first == 'c');
59 UNIT_ASSERT((*p.first).second == 100);
60
61 p = m.insert(std::pair<const char, int>('c', 100));
62
63 UNIT_ASSERT(!p.second); // already existing pair
64 UNIT_ASSERT(p.first != m.end());
65 UNIT_ASSERT((*p.first).first == 'c');
66 UNIT_ASSERT((*p.first).second == 100);
67 }
68
69 template <typename TAlloc>
70 void DoTestMMap1(TMultiMap<char, int, TLess<char>, TAlloc>& m) {

Callers 1

Y_UNIT_TESTFunction · 0.85

Calls 3

countMethod · 0.45
insertMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected