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

Function BOOST_AUTO_TEST_CASE

tests/pstl/allocation_map.cpp:40–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38}
39
40BOOST_AUTO_TEST_CASE(insert) {
41 std::unordered_set<uint64_t> addresses;
42 for_each_test_allocation(50000, [&](uint64_t x){
43 addresses.insert(x);
44 });
45 if(addresses.find(0) == addresses.end())
46 addresses.insert(0);
47 // ~0 is unsupported, due to overflow for non-zero allocation ranges.
48 if(addresses.find(~0ull - 1 ) == addresses.end())
49 addresses.insert(~0ull - 1);
50
51 amap_t amap;
52 for(const auto& x : addresses) {
53 amap_t::value_type v;
54 v.allocation_size = 1;
55 BOOST_CHECK(amap.insert(x, v));
56 }
57
58 for(const auto& x : addresses) {
59 uint64_t root_address = 0;
60 auto* ret = amap.get_entry(x, root_address);
61 BOOST_CHECK(ret != nullptr);
62 if(ret) {
63 BOOST_CHECK(root_address == x);
64 BOOST_CHECK(ret->allocation_size == 1);
65 }
66 }
67
68 std::mt19937 gen(222);
69 std::uniform_int_distribution<uint64_t> dist;
70
71 for(int num_foreign_addresses_found = 0; num_foreign_addresses_found < 10000;) {
72 uint64_t addr = dist(gen);
73 if(addresses.find(addr) == addresses.end()) {
74 uint64_t root_address = 0;
75 auto* ret = amap.get_entry(addr, root_address);
76 BOOST_CHECK(!ret);
77 ++num_foreign_addresses_found;
78 }
79 }
80}
81
82BOOST_AUTO_TEST_CASE(get_entry) {
83 amap_t amap;

Callers

nothing calls this directly

Calls 8

for_each_test_allocationFunction · 0.85
get_entryMethod · 0.80
push_backMethod · 0.80
joinMethod · 0.80
insertMethod · 0.45
findMethod · 0.45
endMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected