From: JINMEI Tatuya Date: Mon, 27 Aug 2012 21:46:13 +0000 (-0700) Subject: [2107] clearly separated mutable and immutable versions of getNext(). X-Git-Tag: trac2351_base~109^2~1^2~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6e2de8ba7a4a1582802ba3a03b02e286ecaf50d1;p=thirdparty%2Fkea.git [2107] clearly separated mutable and immutable versions of getNext(). and tested for both versions. --- diff --git a/src/lib/datasrc/memory/rdataset.h b/src/lib/datasrc/memory/rdataset.h index e7c15f6c73..69fb17d090 100644 --- a/src/lib/datasrc/memory/rdataset.h +++ b/src/lib/datasrc/memory/rdataset.h @@ -237,7 +237,11 @@ public: /// get the same result by directly calling get() on \c next, it would /// help encourage the use of more efficient usage if we provide an /// explicit accessor. - RdataSet* getNext() const { return (next.get()); } + //const RdataSet* getNext() const { return (next.get()); } + const RdataSet* getNext() const { return (next.get()); } + + /// \brief Return the bare pointer to the next node, mutable version. + RdataSet* getNext() { return (next.get()); } /// \brief Return the number of RDATAs stored in the \c RdataSet. size_t getRdataCount() const { return (rdata_count_); } diff --git a/src/lib/datasrc/memory/tests/rdataset_unittest.cc b/src/lib/datasrc/memory/tests/rdataset_unittest.cc index 02f8128576..07a240cb55 100644 --- a/src/lib/datasrc/memory/tests/rdataset_unittest.cc +++ b/src/lib/datasrc/memory/tests/rdataset_unittest.cc @@ -121,13 +121,16 @@ TEST_F(RdataSetTest, getNext) { ConstRRsetPtr()); // By default, the next pointer should be NULL (already tested in other - // test cases), which should be the case with getNext() + // test cases), which should be the case with getNext(). We test both + // mutable and immutable versions of getNext(). EXPECT_EQ(static_cast(NULL), rdataset->getNext()); + EXPECT_EQ(static_cast(NULL), + static_cast(rdataset)->getNext()); // making a link (it would form an infinite loop, but it doesn't matter // in this test), and check the pointer returned by getNext(). rdataset->next = rdataset; - EXPECT_EQ(rdataset, rdataset->getNext()); + EXPECT_EQ(rdataset, static_cast(rdataset)->getNext()); RdataSet::destroy(mem_sgmt_, RRClass::IN(), rdataset); }