68 auto randomAlpha = toString(alpha.
val);
81 CHECK (delta.
val == 55);
87 cout <<
"____Tracker-Log_______________\n"
89 <<
"\n───╼━━━━━━━━━━━╾──────────────"<<endl;
91 CHECK (log.
verify(
"EventLogHeader").
on(
"TestTracking_test")
117 CHECK (0 < dum1.
getVal() and dum1.
getVal() <= 100'000'000);
121 CHECK (dum2.getVal() == 55);
124 Dummy dum3{move (dum2)};
125 CHECK (dum3.getVal() == 55);
129 CHECK (dum3.getVal() == 23);
132 CHECK (dum1.
getVal() == 23 );
143 CHECK (0 < v and v <= 100'000'000);
148 CHECK (dum1.
getVal() == 23 );
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")
218 CHECK (
sizeof(uniFab) ==
sizeof(std::shared_ptr<byte>));
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);
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"
412 <<
"\n───╼━━━━━━━━━━━━━━━━━╾────────"<<endl;
A front-end/concept to allow access to custom memory management.
Adapter to use a generic factory FAC for creating managed object instances with unique ownership.
auto make_unique(ARGS &&...args)
Factory function: generate object with scoped ownership and automated clean-up.
A Dummy object for tests.
static void activateCtorFailure(bool indeed=true)
static constexpr int DEFUNCT
EventLog & event(string text)
log some text as event
EventMatch verify(string match) const
start a query to match for some substring.
EventLog & clear()
purge log contents while retaining just the original Header-ID
EventMatch verifyEvent(string match) const
start a query to match for some event.
EventLog & joinInto(EventLog &otherLog)
Merge this log into another log, forming a combined log.
EventMatch & arg(ARGS const &...args)
refine filter to additionally require specific arguments
EventMatch & before(string match)
find a match (substring match) of the given text in an EventLog entry after the current position
EventMatch & beforeEvent(string match)
find a match for an "event" after the current point of reference
EventMatch & argPos(size_t idx, ARG const &arg)
refine filter to additionally require match on a specific positional argument
EventMatch & on(string targetID)
refine filter to additionally match the ‘'this’` attribute
EventMatch & beforeCall(string match)
find a match for some function invocation after the current point of reference
C++ standard compliant custom allocator adapter backed by the TrackingAllocator and the MemoryPool de...
Generic low-level allocator attached to tracking MemoryPool.
void deallocate(Location, size_t=0) noexcept
Discard and forget an allocation created through this allocator.
static size_t numAlloc(Literal pool=GLOBAL)
get active allocation count for mem-pool
Location allocate(size_t n)
Allot a memory block of given size bytes.
bool manages(Location) const
probe if this allocator pool did allocate the given memory location
HashVal getID(Location) const
retrieve the internal registration ID for this allocation.
static size_t numBytes(Literal pool=GLOBAL)
calculate currently allotted Bytes for mem-pool
static size_t use_count(Literal pool=GLOBAL)
determine number of active front-end handles
size_t getSize(Location) const
retrieve the registered size of this allocation, if known.
static HashVal checksum(Literal pool=GLOBAL)
get Checksum for specific mem-pool
Generic object factory backed by TrackingAllocator.
void demonstrate_checkObject()
void demonstrate_logObject()
void demonstrate_checkAllocator()
Implementation namespace for support and library code.
size_t HashVal
a STL compatible hash value
Test runner and basic definitions for tests.
std::string toString(TY const &val) noexcept
get some string representation of any object, reliably.
string join(COLL &&coll, string const &delim=", ")
enumerate a collection's contents, separated by delimiter.
Simplistic test class runner.
#define LAUNCHER(_TEST_CLASS_, _GROUPS_)
A tracking Dummy object for tests.
static lib::test::EventLog log
static constexpr int DEFUNCT
A collection of frequently used helper functions to support unit testing.
Unittest helper code: a custom allocator to track memory usage.
unittest helper code: test dummy objects to track instances.