Commit 69aae7b1 authored by JINMEI Tatuya's avatar JINMEI Tatuya

[master] Merge branch 'master' of ssh://git.bind10.isc.org/var/bind10/git/bind10

parents 28ec5cff 06d963e3
......@@ -127,6 +127,20 @@ public:
virtual std::string toText() const;
virtual bool isSameKind(const AbstractRRset& other) const {
// This code is an optimisation for comparing
// RBNodeRRsets. However, in doing this optimisation,
// semantically the code is not "is same kind" but is instead
// "is identical object" in the case where RBNodeRRsets are compared.
const RBNodeRRset* rb = dynamic_cast<const RBNodeRRset*>(&other);
if (rb != NULL) {
return (this == rb);
} else {
return (AbstractRRset::isSameKind(other));
}
}
virtual unsigned int toWire(
isc::dns::AbstractMessageRenderer& renderer) const;
......
......@@ -138,6 +138,23 @@ TEST_F(RBNodeRRsetTest, toText) {
EXPECT_THROW(rrset_a_empty.toText(), EmptyRRset);
}
TEST_F(RBNodeRRsetTest, isSameKind) {
RBNodeRRset rrset_p(ConstRRsetPtr(new RRset(test_name, RRClass::IN(), RRType::A(), RRTTL(3600))));
RBNodeRRset rrset_q(ConstRRsetPtr(new RRset(test_name, RRClass::IN(), RRType::A(), RRTTL(3600))));
RRset rrset_w(test_name, RRClass::IN(), RRType::A(), RRTTL(3600));
RRset rrset_x(test_nsname, RRClass::IN(), RRType::A(), RRTTL(3600));
RRset rrset_y(test_name, RRClass::IN(), RRType::NS(), RRTTL(3600));
RRset rrset_z(test_name, RRClass::CH(), RRType::A(), RRTTL(3600));
EXPECT_TRUE(rrset_p.isSameKind(rrset_p));
EXPECT_FALSE(rrset_p.isSameKind(rrset_q));
EXPECT_TRUE(rrset_p.isSameKind(rrset_w));
EXPECT_FALSE(rrset_p.isSameKind(rrset_x));
EXPECT_FALSE(rrset_p.isSameKind(rrset_y));
EXPECT_FALSE(rrset_p.isSameKind(rrset_z));
}
// Note: although the next two tests are essentially the same and used common
// test code, they use different test data: the MessageRenderer produces
// compressed wire data whereas the OutputBuffer does not.
......
/message_renderer_bench
/rdatarender_bench
......@@ -113,6 +113,16 @@ AbstractRRset::toWire(AbstractMessageRenderer& renderer) const {
return (rrs_written);
}
bool
AbstractRRset::isSameKind(const AbstractRRset& other) const {
// Compare classes last as they're likely to be identical. Compare
// names late in the list too, as these are expensive. So we compare
// types first, names second and classes last.
return (getType() == other.getType() &&
getName() == other.getName() &&
getClass() == other.getClass());
}
ostream&
operator<<(ostream& os, const AbstractRRset& rrset) {
os << rrset.toText();
......
......@@ -475,6 +475,14 @@ public:
/// \brief Clear the RRSIGs for this RRset
virtual void removeRRsig() = 0;
/// \brief Check whether two RRsets are of the same kind
///
/// Checks if two RRsets have the same name, RR type, and RR class.
///
/// \param other Pointer to another AbstractRRset to compare
/// against.
virtual bool isSameKind(const AbstractRRset& other) const;
//@}
};
......
......@@ -112,6 +112,20 @@ TEST_F(RRsetTest, setName) {
EXPECT_EQ(test_nsname, rrset_a.getName());
}
TEST_F(RRsetTest, isSameKind) {
RRset rrset_w(test_name, RRClass::IN(), RRType::A(), RRTTL(3600));
RRset rrset_x(test_name, RRClass::IN(), RRType::A(), RRTTL(3600));
RRset rrset_y(test_name, RRClass::IN(), RRType::NS(), RRTTL(3600));
RRset rrset_z(test_name, RRClass::CH(), RRType::A(), RRTTL(3600));
RRset rrset_p(test_nsname, RRClass::IN(), RRType::A(), RRTTL(3600));
EXPECT_TRUE(rrset_w.isSameKind(rrset_w));
EXPECT_TRUE(rrset_w.isSameKind(rrset_x));
EXPECT_FALSE(rrset_w.isSameKind(rrset_y));
EXPECT_FALSE(rrset_w.isSameKind(rrset_z));
EXPECT_FALSE(rrset_w.isSameKind(rrset_p));
}
void
addRdataTestCommon(const RRset& rrset) {
EXPECT_EQ(2, rrset.getRdataCount());
......
......@@ -2,6 +2,8 @@
/destination_test.sh
/init_logger_test
/init_logger_test.sh
/initializer_unittests_1
/initializer_unittests_2
/local_file_test.sh
/logger_example
/run_unittests
......
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