Commit 41b26fc4 authored by JINMEI Tatuya's avatar JINMEI Tatuya
Browse files

[2420] unify destroying zone data and leak check in the test dtor

parent bb38dbf0
...@@ -45,12 +45,16 @@ protected: ...@@ -45,12 +45,16 @@ protected:
zone_data_(ZoneData::create(mem_sgmt_, zname_)), zone_data_(ZoneData::create(mem_sgmt_, zname_)),
updater_(new ZoneDataUpdater(mem_sgmt_, zclass_, zname_, *zone_data_)) updater_(new ZoneDataUpdater(mem_sgmt_, zclass_, zname_, *zone_data_))
{} {}
~ZoneDataUpdaterTest() { ~ZoneDataUpdaterTest() {
// Make sure zone data is destroyed even if a test results in exception
if (zone_data_ != NULL) { if (zone_data_ != NULL) {
ZoneData::destroy(mem_sgmt_, zone_data_, zclass_); ZoneData::destroy(mem_sgmt_, zone_data_, zclass_);
} }
if (!mem_sgmt_.allMemoryDeallocated()) {
ADD_FAILURE() << "Memory leak detected";
}
} }
void clearZoneData() { void clearZoneData() {
assert(zone_data_ != NULL); assert(zone_data_ != NULL);
ZoneData::destroy(mem_sgmt_, zone_data_, zclass_); ZoneData::destroy(mem_sgmt_, zone_data_, zclass_);
...@@ -59,13 +63,6 @@ protected: ...@@ -59,13 +63,6 @@ protected:
*zone_data_)); *zone_data_));
} }
void TearDown() {
if (zone_data_ != NULL) {
ZoneData::destroy(mem_sgmt_, zone_data_, zclass_);
zone_data_ = NULL;
}
EXPECT_TRUE(mem_sgmt_.allMemoryDeallocated()); // catch any leak here.
}
const Name zname_; const Name zname_;
const RRClass zclass_; const RRClass zclass_;
test::MemorySegmentTest mem_sgmt_; test::MemorySegmentTest mem_sgmt_;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment