bool testEvictionError() { bool testPassed = false; Cache CC; CC.Register(nullID, createProductNull); CC.setMaxCreation(1); AbstractProduct *pProduct1 = NULL, *pProduct2 = NULL; try{ pProduct1 = CC.CreateObject(nullID); // should be OK pProduct2 = CC.CreateObject(nullID); // should cast an exception } catch(std::exception &e){ if(strcmp(e.what(), EvictionException().what())==0) testPassed = true; } if(pProduct1!=NULL) CC.ReleaseObject(pProduct1); if(pProduct2!=NULL) CC.ReleaseObject(pProduct2); return testPassed; }