MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / BOOST_AUTO_TEST_CASE

Function BOOST_AUTO_TEST_CASE

src/test/coinscachepair_tests.cpp:36–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34}
35
36BOOST_AUTO_TEST_CASE(linked_list_iteration)
37{
38 CoinsCachePair sentinel;
39 sentinel.second.SelfRef(sentinel);
40 auto nodes{CreatePairs(sentinel)};
41
42 // Check iterating through pairs is identical to iterating through a list
43 auto node{sentinel.second.Next()};
44 for (const auto& expected : nodes) {
45 BOOST_CHECK_EQUAL(&expected, node);
46 node = node->second.Next();
47 }
48 BOOST_CHECK_EQUAL(node, &sentinel);
49
50 // Check iterating through pairs is identical to iterating through a list
51 // Clear the state during iteration
52 node = sentinel.second.Next();
53 for (const auto& expected : nodes) {
54 BOOST_CHECK_EQUAL(&expected, node);
55 auto next = node->second.Next();
56 node->second.SetClean();
57 node = next;
58 }
59 BOOST_CHECK_EQUAL(node, &sentinel);
60 // Check that sentinel's next and prev are itself
61 BOOST_CHECK_EQUAL(sentinel.second.Next(), &sentinel);
62 BOOST_CHECK_EQUAL(sentinel.second.Prev(), &sentinel);
63
64 // Delete the nodes from the list to make sure there are no dangling pointers
65 for (auto it{nodes.begin()}; it != nodes.end(); it = nodes.erase(it)) {
66 BOOST_CHECK(!it->second.IsDirty() && !it->second.IsFresh());
67 }
68}
69
70BOOST_AUTO_TEST_CASE(linked_list_iterate_erase)
71{

Callers

nothing calls this directly

Calls 10

CreatePairsFunction · 0.85
SelfRefMethod · 0.80
SetCleanMethod · 0.80
NextMethod · 0.45
PrevMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
eraseMethod · 0.45
IsDirtyMethod · 0.45
IsFreshMethod · 0.45

Tested by

no test coverage detected