#pragma once #include #include #include #include #include #include #include #include #include #include #include #include struct TObjectCountCheck { bool Enabled; template struct TReset { TObjectCountCheck* const Thiz; TReset(TObjectCountCheck* thiz) : Thiz(thiz) { } void operator()() { long oldValue = TObjectCounter::ResetObjectCount(); if (oldValue != 0) { Cerr << "warning: previous counter: " << oldValue << " for " << TypeName() << Endl; Cerr << "won't check in this test" << Endl; Thiz->Enabled = false; } } }; TObjectCountCheck() { Enabled = true; DoForAllCounters(); } template struct TCheckZero { TCheckZero(TObjectCountCheck*) { } void operator()() { UNIT_ASSERT_VALUES_EQUAL_C(0L, TObjectCounter::ObjectCount(), TypeName()); } }; ~TObjectCountCheck() { if (Enabled) { DoForAllCounters(); } } template