Commit bdf19add authored by Mukund Sivaraman's avatar Mukund Sivaraman
Browse files

[2432] Return status in removeRRset()

parent cfbb9ead
......@@ -115,12 +115,19 @@ RRsetCollection::find(const Name& name, const RRClass& rrclass,
return (ConstRRsetPtr());
}
void
bool
RRsetCollection::removeRRset(const Name& name, const RRClass& rrclass,
const RRType& rrtype)
{
const CollectionKey key(rrclass, rrtype, name);
rrsets_.erase(key);
CollectionMap::iterator it = rrsets_.find(key);
if (it == rrsets_.end()) {
return (false);
}
rrsets_.erase(it);
return (true);
}
RRsetCollectionBase::IterPtr
......
......@@ -87,7 +87,10 @@ public:
///
/// RRset(s) matching the \c name, \c rrclass and \c rrtype are
/// removed from the collection.
void removeRRset(const isc::dns::Name& name,
///
/// \returns \c true if a matching RRset was deleted, \c false if no
/// such RRset exists.
bool removeRRset(const isc::dns::Name& name,
const isc::dns::RRClass& rrclass,
const isc::dns::RRType& rrtype);
......
......@@ -152,13 +152,20 @@ doAddAndRemove(RRsetCollection& collection, const RRClass& rrclass) {
collection.addRRset(rrset);
}, isc::InvalidParameter);
// Remove foo.example.org/A
collection.removeRRset(Name("foo.example.org"), rrclass, RRType::A());
// Remove foo.example.org/A, which should pass
bool exists = collection.removeRRset(Name("foo.example.org"),
rrclass, RRType::A());
EXPECT_TRUE(exists);
// foo.example.org/A should not exist now
rrset_found = collection.find(Name("foo.example.org"), rrclass,
RRType::A());
EXPECT_FALSE(rrset_found);
// Removing foo.example.org/A should fail now
exists = collection.removeRRset(Name("foo.example.org"),
rrclass, RRType::A());
EXPECT_FALSE(exists);
}
TEST_F(RRsetCollectionTest, addAndRemove) {
......
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