Mon 29 May 2006 03:20:47 PM UTC, original submission:
rite a memory_usage function for PokerApplication* matching
the description below. The implementation of the function must return
a predefined constant.
Write a unittest based unit test that creates and destroys a PokerApplication*
Ensure it is memory clean (no corruption, no leak).
Implement the validation described below, based on the unit test but
ensure that the unit test can still be run without it.
----------------------------------------------------------------------
Generic prototype of the memory usage function:
unsigned int memory_usage(ostream& out, void* pointer, std::string prefix);
Semantics:
memory_usage knows the type of pointer, explores it and returns the
total memory it uses, in bytes. In addition, the returned value must
be >> to out, immediately after prefix followed by newline.
If memory_usage calls other functions with the same semantics and prototype,
it is expected to provide each of these functions with a concatenation of
the prefix and a unique string.
Validation:
The heap size difference (HeapDelta) (size after the allocation of
pointer minus size before the allocation of pointer) must be greater
or equal to the number returned by memory usage (MemoryUsage). In
additon, MemoryUsage - HeapDelta must not exceed 10% of the heap size.
This must be true for every unit test of the pointer type.
|