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
///
/// 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);
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) {