64 auto& log = Tracker::log;
68 auto randomAlpha = toString(alpha.val);
70 log.
event(
"ID",alpha.val);
75 log.
event (
"ID",alpha.val);
80 log.
event (
"ID",delta.val);
81 CHECK (delta.val == 55);
83 log.
event(
"ID",alpha.val);
84 CHECK (alpha.val == Tracker::DEFUNCT);
87 cout <<
"____Tracker-Log_______________\n" 88 << util::join(Tracker::log,
"\n")
89 <<
"\n───╼━━━━━━━━━━━╾──────────────"<<endl;
91 CHECK (log.
verify(
"EventLogHeader").
on(
"TestTracking_test")
114 CHECK (Dummy::checksum() == 0);
117 CHECK (0 < dum1.getVal() and dum1.getVal() <= 100
'000'000);
118 CHECK (Dummy::checksum() == dum1.getVal());
121 CHECK (55 == dum2.getVal());
122 CHECK (Dummy::checksum() == dum1.getVal() + 55);
124 Dummy dum3{move (dum2)};
125 CHECK (55 == dum3.getVal());
126 CHECK (0 == dum2.getVal());
129 CHECK (23 == dum3.getVal());
132 CHECK (23 == dum1.getVal());
133 CHECK (0 == dum2.getVal());
134 CHECK (0 == dum3.getVal());
135 CHECK (Dummy::checksum() == 23);
137 Dummy::activateCtorFailure (
true);
143 CHECK (0 < v and v <= 100
'000'000);
144 CHECK (Dummy::checksum() == 23 + v);
145 Dummy::checksum() -= v;
147 Dummy::activateCtorFailure (
false);
148 CHECK (23 == dum1.getVal());
149 CHECK (0 == dum2.getVal());
150 CHECK (0 == dum3.getVal());
151 CHECK (Dummy::checksum() == 23);
153 CHECK (Dummy::checksum() == 0);
170 auto& log = TrackingAllocator::log;
171 Tracker::log.
clear(
"Tracking-Allocator-Test");
190 CHECK (allo.
getSize (mem) == 55);
196 CHECK (not allo.
manages (mem));
197 CHECK (allo.
getSize (mem) == 0);
198 CHECK (allo.
getID (mem) == 0);
203 CHECK (log.
verify(
"EventLogHeader").
on(
"Tracking-Allocator-Test")
219 CHECK (not allo::is_Stateless_v<decltype(uniFab)>);
225 log.
event(
"fabricate unique");
227 CHECK (uniqueHandle);
228 CHECK (uniqueHandle->val == 77);
235 void* mem = uniqueHandle.get();
260 using TrackVec = std::vector<Tracker, TrackAlloc<Tracker>>;
263 Tracker *t1, *t2, *t3, *t4, *t5, *t6;
269 log.
event(
"fill with 3 default instances");
272 int v3 = vec1.back().val;
275 log.
event(
"move last instance over into other vector");
276 vec2.emplace_back (move (vec1[2]));
277 CHECK (vec2.back().val == v3);
278 CHECK (vec1.back().val == Tracker::DEFUNCT);
285 log.
event(
"leave scope");
293 .
beforeEvent(
"move last instance over into other vector")
312 CHECK (allo1 != allo2);
320 TrackVec vec1{allo1};
321 TrackVec vec2{allo2};
325 log.
event(
"reserve space in vectors");
334 log.
event(
"create elements in vec1");
336 vec1.back().val = 11;
337 log.
event(
"add element to vec2");
348 log.
event (
"swap vectors");
349 std::swap (vec1, vec2);
351 CHECK (vec1.back().val == 22);
352 CHECK (vec2.back().val == 11);
353 CHECK (vec1.size() == 1);
354 CHECK (vec2.size() == 5);
359 log.
event (
"clear the elements migrated to vec2");
361 vec2.shrink_to_fit();
362 CHECK (vec2.capacity() == 0);
365 CHECK (vec1.size() == 1);
366 CHECK (vec1.capacity() == 2);
368 log.
event (
"leave scope");
389 .
beforeEvent(
"clear the elements migrated to vec2")
410 cout <<
"____Tracking-Allo-Log_________\n" 411 << util::join(TrackingAllocator::log,
"\n")
412 <<
"\n───╼━━━━━━━━━━━━━━━━━╾────────"<<endl;
Location allocate(size_t n)
Allot a memory block of given size bytes.
Adapter to use a generic factory FAC for creating managed object instances with unique ownership...
EventLog & event(string text)
log some text as event
void demonstrate_logObject()
static HashVal checksum(Literal pool=GLOBAL)
get Checksum for specific mem-pool
C++ standard compliant custom allocator adapter backed by the TrackingAllocator and the MemoryPool de...
size_t getSize(Location) const
retrieve the registered size of this allocation, if known.
EventMatch & beforeCall(string match)
find a match for some function invocation after the current point of reference
A front-end/concept to allow access to custom memory management.
Generic low-level allocator attached to tracking MemoryPool.
static size_t numBytes(Literal pool=GLOBAL)
calculate currently allotted Bytes for mem-pool
EventMatch & arg(ARGS const &...args)
refine filter to additionally require specific arguments
bool manages(Location) const
probe if this allocator pool did allocate the given memory location
EventMatch verifyEvent(string match) const
start a query to match for some event.
Implementation namespace for support and library code.
Generic object factory backed by TrackingAllocator.
void deallocate(Location, size_t=0) noexcept
Discard and forget an allocation created through this allocator.
void demonstrate_checkObject()
A tracking Dummy object for tests.
EventMatch & beforeEvent(string match)
find a match for an "event" after the current point of reference
EventLog & clear()
purge log contents while retaining just the original Header-ID
Simplistic test class runner.
unittest helper code: test dummy objects to track instances.
Unittest helper code: a custom allocator to track memory usage.
EventLog & joinInto(EventLog &otherLog)
Merge this log into another log, forming a combined log.
EventMatch & argPos(size_t idx, ARG const &arg)
refine filter to additionally require match on a specific positional argument
A collection of frequently used helper functions to support unit testing.
HashVal getID(Location) const
retrieve the internal registration ID for this allocation.
A Dummy object for tests.
size_t HashVal
a STL compatible hash value
static size_t numAlloc(Literal pool=GLOBAL)
get active allocation count for mem-pool
auto make_unique(ARGS &&...args)
Factory function: generate object with scoped ownership and automated clean-up.
void demonstrate_checkAllocator()
static size_t use_count(Literal pool=GLOBAL)
determine number of active front-end handles
EventMatch verify(string match) const
start a query to match for some substring.
EventMatch & on(string targetID)
refine filter to additionally match the 'this' attribute
EventMatch & before(string match)
find a match (substring match) of the given text in an EventLog entry after the current position ...