BIND 10 trac2498, updated. 7cbed6378d88f921cf33b12d18d78e56400b4702 [2498] Add a few quoting tests for toText() in HINFO and NAPTR
BIND 10 source code commits
bind10-changes at lists.isc.org
Mon Jan 14 11:04:52 UTC 2013
The branch, trac2498 has been updated
via 7cbed6378d88f921cf33b12d18d78e56400b4702 (commit)
via a3e0f04e9f735501a2ef08b7d3c0de3f22849fcc (commit)
from 360a5bb6cb72862edbbe9a4cb0074360f1385e21 (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 7cbed6378d88f921cf33b12d18d78e56400b4702
Author: Jelte Jansen <jelte at isc.org>
Date: Mon Jan 14 12:04:28 2013 +0100
[2498] Add a few quoting tests for toText() in HINFO and NAPTR
commit a3e0f04e9f735501a2ef08b7d3c0de3f22849fcc
Author: Jelte Jansen <jelte at isc.org>
Date: Mon Jan 14 11:08:31 2013 +0100
[2498] Add operator= and use scoped_ptr in HINFO and NAPTR
-----------------------------------------------------------------------
Summary of changes:
src/lib/dns/rdata/generic/hinfo_13.cc | 12 +++++++++++-
src/lib/dns/rdata/generic/hinfo_13.h | 8 +++++++-
src/lib/dns/rdata/generic/naptr_35.cc | 8 +++++++-
src/lib/dns/rdata/generic/naptr_35.h | 6 +++++-
src/lib/dns/tests/rdata_hinfo_unittest.cc | 18 ++++++++++++++++++
src/lib/dns/tests/rdata_naptr_unittest.cc | 19 +++++++++++++++++++
6 files changed, 67 insertions(+), 4 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/dns/rdata/generic/hinfo_13.cc b/src/lib/dns/rdata/generic/hinfo_13.cc
index f205497..0764951 100644
--- a/src/lib/dns/rdata/generic/hinfo_13.cc
+++ b/src/lib/dns/rdata/generic/hinfo_13.cc
@@ -96,8 +96,14 @@ HINFO::HINFO(MasterLexer& lexer, const Name*,
impl_(new HINFOImpl(lexer))
{}
+HINFO&
+HINFO::operator=(const HINFO& source)
+{
+ impl_.reset(new HINFOImpl(*source.impl_));
+ return (*this);
+}
+
HINFO::~HINFO() {
- delete impl_;
}
std::string
@@ -149,5 +155,9 @@ HINFO::toWireHelper(T& outputer) const {
outputer.writeData(&impl_->os[0], impl_->os.size());
}
+void HINFO::ptr() const {
+ std::cout << "[XX] PTR: " << impl_.get() << std::endl;
+}
+
// END_RDATA_NAMESPACE
// END_ISC_NAMESPACE
diff --git a/src/lib/dns/rdata/generic/hinfo_13.h b/src/lib/dns/rdata/generic/hinfo_13.h
index 045d7fe..a2018f5 100644
--- a/src/lib/dns/rdata/generic/hinfo_13.h
+++ b/src/lib/dns/rdata/generic/hinfo_13.h
@@ -17,6 +17,9 @@
#include <string>
+#include <boost/scoped_ptr.hpp>
+#include <boost/noncopyable.hpp>
+
#include <dns/name.h>
#include <dns/rdata.h>
#include <util/buffer.h>
@@ -44,9 +47,12 @@ public:
// HINFO specific methods
~HINFO();
+ HINFO& operator=(const HINFO&);
+
const std::string getCPU() const;
const std::string getOS() const;
+ void ptr() const;
private:
/// Helper template function for toWire()
///
@@ -54,7 +60,7 @@ private:
template <typename T>
void toWireHelper(T& outputer) const;
- HINFOImpl* impl_;
+ boost::scoped_ptr<HINFOImpl> impl_;
};
diff --git a/src/lib/dns/rdata/generic/naptr_35.cc b/src/lib/dns/rdata/generic/naptr_35.cc
index 352b887..78bf472 100644
--- a/src/lib/dns/rdata/generic/naptr_35.cc
+++ b/src/lib/dns/rdata/generic/naptr_35.cc
@@ -141,8 +141,14 @@ NAPTR::NAPTR(const NAPTR& naptr) : Rdata(),
impl_(new NAPTRImpl(*naptr.impl_))
{}
+NAPTR&
+NAPTR::operator=(const NAPTR& source)
+{
+ impl_.reset(new NAPTRImpl(*source.impl_));
+ return (*this);
+}
+
NAPTR::~NAPTR() {
- delete impl_;
}
void
diff --git a/src/lib/dns/rdata/generic/naptr_35.h b/src/lib/dns/rdata/generic/naptr_35.h
index 5676302..a2e2cae 100644
--- a/src/lib/dns/rdata/generic/naptr_35.h
+++ b/src/lib/dns/rdata/generic/naptr_35.h
@@ -16,6 +16,8 @@
#include <string>
+#include <boost/scoped_ptr.hpp>
+
#include <dns/name.h>
#include <dns/rdata.h>
#include <util/buffer.h>
@@ -43,6 +45,8 @@ public:
// NAPTR specific methods
~NAPTR();
+ NAPTR& operator=(const NAPTR& source);
+
uint16_t getOrder() const;
uint16_t getPreference() const;
const std::string getFlags() const;
@@ -56,7 +60,7 @@ private:
template <typename T>
void toWireHelper(T& outputer) const;
- NAPTRImpl* impl_;
+ boost::scoped_ptr<NAPTRImpl> impl_;
};
// END_RDATA_NAMESPACE
diff --git a/src/lib/dns/tests/rdata_hinfo_unittest.cc b/src/lib/dns/tests/rdata_hinfo_unittest.cc
index 8d1b797..0bea477 100644
--- a/src/lib/dns/tests/rdata_hinfo_unittest.cc
+++ b/src/lib/dns/tests/rdata_hinfo_unittest.cc
@@ -102,6 +102,11 @@ TEST_F(Rdata_HINFO_Test, createFromLexer) {
TEST_F(Rdata_HINFO_Test, toText) {
HINFO hinfo(hinfo_str);
EXPECT_EQ(hinfo_str, hinfo.toText());
+
+ // will add quotes even if they were not in the original input
+ EXPECT_EQ("\"a\" \"b\"", HINFO("a b").toText());
+ // will not add additional quotes
+ EXPECT_EQ("\"a\" \"b\"", HINFO("\"a\" \"b\"").toText());
}
TEST_F(Rdata_HINFO_Test, toWire) {
@@ -136,4 +141,17 @@ TEST_F(Rdata_HINFO_Test, compare) {
EXPECT_EQ(-1, hinfo.compare(HINFO(hinfo_str_large2)));
}
+// Copy/assign test
+TEST_F(Rdata_HINFO_Test, copy) {
+ HINFO hinfo(hinfo_str);
+ HINFO hinfo2(hinfo);
+ HINFO hinfo3 = hinfo;
+
+ EXPECT_EQ(0, hinfo.compare(hinfo2));
+ EXPECT_EQ(0, hinfo.compare(hinfo3));
+
+ hinfo3 = hinfo;
+ EXPECT_EQ(0, hinfo.compare(hinfo3));
+}
+
}
diff --git a/src/lib/dns/tests/rdata_naptr_unittest.cc b/src/lib/dns/tests/rdata_naptr_unittest.cc
index 159a7b1..d828e73 100644
--- a/src/lib/dns/tests/rdata_naptr_unittest.cc
+++ b/src/lib/dns/tests/rdata_naptr_unittest.cc
@@ -183,6 +183,14 @@ TEST_F(Rdata_NAPTR_Test, toWireRenderer) {
TEST_F(Rdata_NAPTR_Test, toText) {
NAPTR naptr(naptr_str);
EXPECT_EQ(naptr_str, naptr.toText());
+
+ // will add quotes even if they were not in the original input
+ EXPECT_EQ("10 100 \"S\" \"SIP+D2U\" \".*\" _sip._udp.example.com.",
+ NAPTR("10 100 S SIP+D2U .* _sip._udp.example.com.").toText());
+ // will not add additional quotes
+ EXPECT_EQ("10 100 \"S\" \"SIP+D2U\" \".*\" _sip._udp.example.com.",
+ NAPTR("10 100 \"S\" \"SIP+D2U\" \".*\" _sip._udp.example.com.")
+ .toText());
}
TEST_F(Rdata_NAPTR_Test, compare) {
@@ -219,7 +227,18 @@ TEST_F(Rdata_NAPTR_Test, compare) {
EXPECT_EQ(1, naptr_large3.compare(naptr));
EXPECT_EQ(1, naptr_large4.compare(naptr));
EXPECT_EQ(1, naptr_large5.compare(naptr));
+}
+
+TEST_F(Rdata_NAPTR_Test, copy) {
+ NAPTR naptr(naptr_str);
+ NAPTR naptr2(naptr);
+ NAPTR naptr3 = naptr;
+
+ EXPECT_EQ(0, naptr.compare(naptr2));
+ EXPECT_EQ(0, naptr.compare(naptr3));
+ naptr3 = naptr;
+ EXPECT_EQ(0, naptr.compare(naptr3));
}
}
More information about the bind10-changes
mailing list