memory leak unit test c++
Boost.Test will automatically tell you at the end of a test run if any of your unit tests leaked memory.
I don't know if any of the other C++ unit testing frameworks provide this kind of functionality.
I really like ValGrind for this sort of thing. These tools already exist; you don't need to write your own unit tests to detect memory leaks.
For Linux or other systems that use GLibC there are functions to get memory allocation statistics. Assuming no lazy allocations, you should have the same memory committed to malloc before and after you perform your test.