MCPcopy Create free account
hub / github.com/Tessil/ordered-map / BOOST_AUTO_TEST_CASE

Function BOOST_AUTO_TEST_CASE

tests/ordered_map_tests.cpp:114–141  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

112}
113
114BOOST_AUTO_TEST_CASE(test_range_insert) {
115 // insert x values in vector, range insert x-15 values from vector to map,
116 // check values
117 const int nb_values = 1000;
118 std::vector<std::pair<int, int>> values;
119 for (int i = 0; i < nb_values; i++) {
120 values.push_back(std::make_pair(i, i + 1));
121 }
122
123 tsl::ordered_map<int, int> map = {{-1, 0}, {-2, 0}};
124 map.insert(values.begin() + 10, values.end() - 5);
125
126 BOOST_CHECK_EQUAL(map.size(), 987u);
127
128 BOOST_CHECK_EQUAL(map.values_container()[0].first, -1);
129 BOOST_CHECK_EQUAL(map.values_container()[0].second, 0);
130 BOOST_CHECK_EQUAL(map.at(-1), 0);
131
132 BOOST_CHECK_EQUAL(map.values_container()[1].first, -2);
133 BOOST_CHECK_EQUAL(map.values_container()[1].second, 0);
134 BOOST_CHECK_EQUAL(map.at(-2), 0);
135
136 for (int i = 10, j = 2; i < nb_values - 5; i++, j++) {
137 BOOST_CHECK_EQUAL(map.values_container()[j].first, i);
138 BOOST_CHECK_EQUAL(map.values_container()[j].second, i + 1);
139 BOOST_CHECK_EQUAL(map.at(i), i + 1);
140 }
141}
142
143BOOST_AUTO_TEST_CASE(test_insert_with_hint) {
144 tsl::ordered_map<int, int> map{{1, 0}, {2, 1}, {3, 2}};

Callers

nothing calls this directly

Calls 15

move_only_testClass · 0.85
strMethod · 0.80
insertMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45
findMethod · 0.45
emplace_hintMethod · 0.45
emplaceMethod · 0.45
try_emplaceMethod · 0.45
insert_or_assignMethod · 0.45

Tested by

no test coverage detected