MCPcopy Create free account
hub / github.com/HelenOS/helenos / test_push_pop

Method test_push_pop

uspace/lib/cpp/src/__bits/test/deque.cpp:188–227  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

186 }
187
188 void deque_test::test_push_pop()
189 {
190 std::deque<int> d1{};
191
192 d1.push_back(42);
193 test_eq("push_back to empty equivalence", d1[0], 42);
194 test_eq("push_back to empty size", d1.size(), 1U);
195
196 d1.push_front(21);
197 test_eq("push_front after push_back equivalence", d1[0], 21);
198 test_eq("push_front after push_back size", d1.size(), 2U);
199
200 for (int i = 0; i <= 100; ++i)
201 d1.push_back(i);
202 test_eq("back after bucket test", d1.back(), 100);
203
204 d1.pop_back();
205 test_eq("back after pop_back", d1.back(), 99);
206 d1.pop_front();
207 test_eq("front after pop_front", d1.back(), 99);
208
209
210 for (int i = 0; i <= 100; ++i)
211 d1.push_front(i);
212 test_eq("front after bucket test", d1.front(), 100);
213
214 std::deque<int> d2{};
215
216 d2.push_front(42);
217 test_eq("push_front to empty equivalence", d2[0], 42);
218 test_eq("push_front to empty size", d2.size(), 1U);
219
220 d2.push_back(21);
221 test_eq("push_back after push_front equivalence", d2[1], 21);
222 test_eq("push_back after push_front size", d2.size(), 2U);
223
224 d2.clear();
225 test_eq("clear() - empty()", d2.empty(), true);
226 test_eq("clear() - iterators", d2.begin(), d2.end());
227 }
228
229 void deque_test::test_operations()
230 {

Callers

nothing calls this directly

Calls 11

push_backMethod · 0.45
sizeMethod · 0.45
push_frontMethod · 0.45
backMethod · 0.45
pop_backMethod · 0.45
pop_frontMethod · 0.45
frontMethod · 0.45
clearMethod · 0.45
emptyMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected