BIND 10 trac2432, updated. 12b24545cb9aeb86229694cda68c71577587f125 [2432] Don't throw when comparing iterators from different RRsetCollectionBase implementations
BIND 10 source code commits
bind10-changes at lists.isc.org
Wed Dec 26 05:50:03 UTC 2012
The branch, trac2432 has been updated
via 12b24545cb9aeb86229694cda68c71577587f125 (commit)
via 0a14dac0417402193dbcd50cb73360aeef9aabb2 (commit)
from 9cb41a2f06b35290e72eccc8246d8abf57f6e929 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 12b24545cb9aeb86229694cda68c71577587f125
Author: Mukund Sivaraman <muks at isc.org>
Date: Wed Dec 26 11:17:52 2012 +0530
[2432] Don't throw when comparing iterators from different RRsetCollectionBase implementations
commit 0a14dac0417402193dbcd50cb73360aeef9aabb2
Author: Mukund Sivaraman <muks at isc.org>
Date: Wed Dec 26 11:17:10 2012 +0530
[2432] Untabify
-----------------------------------------------------------------------
Summary of changes:
src/lib/dns/rrset_collection.h | 9 ++-
src/lib/dns/tests/rrset_collection_unittest.cc | 75 ++++++++++++++++++++++++
2 files changed, 81 insertions(+), 3 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/dns/rrset_collection.h b/src/lib/dns/rrset_collection.h
index b1998ae..9cbf98c 100644
--- a/src/lib/dns/rrset_collection.h
+++ b/src/lib/dns/rrset_collection.h
@@ -75,7 +75,7 @@ public:
/// \returns A pointer to the RRset if found, \c NULL otherwise.
virtual const isc::dns::AbstractRRset* find
(const isc::dns::Name& name, const isc::dns::RRType& rrtype,
- const isc::dns::RRClass& rrclass)
+ const isc::dns::RRClass& rrclass)
const;
isc::dns::RRsetPtr find(const isc::dns::Name& name,
@@ -117,8 +117,11 @@ protected:
}
virtual bool equals(Iter& other) {
- const DnsIter& other_real = dynamic_cast<DnsIter&>(other);
- return (iter_ == other_real.iter_);
+ const DnsIter* other_real = dynamic_cast<DnsIter*>(&other);
+ if (other_real == NULL) {
+ return (false);
+ }
+ return (iter_ == other_real->iter_);
}
private:
diff --git a/src/lib/dns/tests/rrset_collection_unittest.cc b/src/lib/dns/tests/rrset_collection_unittest.cc
index 29853e1..c7b6636 100644
--- a/src/lib/dns/tests/rrset_collection_unittest.cc
+++ b/src/lib/dns/tests/rrset_collection_unittest.cc
@@ -18,6 +18,8 @@
#include <gtest/gtest.h>
+#include <list>
+
using namespace isc::dns;
using namespace isc::dns::rdata;
using namespace std;
@@ -178,4 +180,77 @@ TEST_F(RRsetCollectionTest, iteratorTest) {
EXPECT_EQ(4, count);
}
+// This is a dummy class which is used in iteratorCompareDifferent test
+// to compare iterators from different RRsetCollectionBase
+// implementations.
+class MyRRsetCollection : public RRsetCollectionBase {
+public:
+ MyRRsetCollection()
+ {}
+
+ virtual const isc::dns::AbstractRRset* find
+ (const isc::dns::Name&, const isc::dns::RRType&,
+ const isc::dns::RRClass&)
+ const
+ {
+ return (NULL);
+ }
+
+ typedef std::list<isc::dns::RRset> MyCollection;
+
+protected:
+ class MyIter : public RRsetCollectionBase::Iter {
+ public:
+ MyIter(MyCollection::iterator& iter) :
+ iter_(iter)
+ {}
+
+ virtual const isc::dns::AbstractRRset& getValue() {
+ return (*iter_);
+ }
+
+ virtual IterPtr getNext() {
+ MyCollection::iterator it = iter_;
+ it++;
+ return (RRsetCollectionBase::IterPtr(new MyIter(it)));
+ }
+
+ virtual bool equals(Iter& other) {
+ const MyIter* other_real = dynamic_cast<MyIter*>(&other);
+ if (other_real == NULL) {
+ return (false);
+ }
+ return (iter_ == other_real->iter_);
+ }
+
+ private:
+ MyCollection::iterator iter_;
+ };
+
+ virtual RRsetCollectionBase::IterPtr getBeginning() {
+ MyCollection::iterator it = dummy_list_.begin();
+ return (RRsetCollectionBase::IterPtr(new MyIter(it)));
+ }
+
+ virtual RRsetCollectionBase::IterPtr getEnd() {
+ MyCollection::iterator it = dummy_list_.end();
+ return (RRsetCollectionBase::IterPtr(new MyIter(it)));
+ }
+
+private:
+ MyCollection dummy_list_;
+};
+
+TEST_F(RRsetCollectionTest, iteratorCompareDifferent) {
+ // Create objects of two different RRsetCollectionBase
+ // implementations.
+ RRsetCollection cln1;
+ MyRRsetCollection cln2;
+
+ // Comparing two iterators from different RRsetCollectionBase
+ // implementations must not throw.
+ EXPECT_NE(cln2.begin(), cln1.begin());
+ EXPECT_NE(cln1.end(), cln2.end());
+}
+
} // namespace
More information about the bind10-changes
mailing list