summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOcean Wang <wanghaidong@cnnic.cn>2011-09-02 05:47:17 +0200
committerOcean Wang <wanghaidong@cnnic.cn>2011-09-02 05:47:17 +0200
commit4e12574323ca3db3e985acee0540c603b2b33124 (patch)
tree66bcc723cbbb9a9032ab4064b0d47f2deb1fe8b0
parent[trac1112] Finish the basic function of HINFO rrdata support. (diff)
downloadkea-4e12574323ca3db3e985acee0540c603b2b33124.tar.xz
kea-4e12574323ca3db3e985acee0540c603b2b33124.zip
[trac1112] Add more unit tests and comments
-rw-r--r--src/lib/dns/rdata/generic/hinfo_13.cc6
-rw-r--r--src/lib/dns/rdata/generic/hinfo_13.h6
-rw-r--r--src/lib/dns/tests/rdata_hinfo_unittest.cc14
3 files changed, 23 insertions, 3 deletions
diff --git a/src/lib/dns/rdata/generic/hinfo_13.cc b/src/lib/dns/rdata/generic/hinfo_13.cc
index cb22107a67..d18584e096 100644
--- a/src/lib/dns/rdata/generic/hinfo_13.cc
+++ b/src/lib/dns/rdata/generic/hinfo_13.cc
@@ -60,7 +60,7 @@ HINFO::toText() const {
result += "\" \"";
result += os_;
result += "\"";
- return result;
+ return (result);
}
void
@@ -102,12 +102,12 @@ HINFO::compare(const Rdata& other) const {
const std::string&
HINFO::getCPU() const {
- return cpu_;
+ return (cpu_);
}
const std::string&
HINFO::getOS() const {
- return os_;
+ return (os_);
}
void
diff --git a/src/lib/dns/rdata/generic/hinfo_13.h b/src/lib/dns/rdata/generic/hinfo_13.h
index 6b39c9b82f..78fee675e9 100644
--- a/src/lib/dns/rdata/generic/hinfo_13.h
+++ b/src/lib/dns/rdata/generic/hinfo_13.h
@@ -28,6 +28,12 @@
// BEGIN_RDATA_NAMESPACE
+/// \brief \c HINFO class represents the HINFO rdata defined in
+/// RFC1034, RFC1035
+///
+/// This class implements the basic interfaces inherited from the
+/// \c rdata::Rdata class, and provides accessors specific to the
+/// HINFO rdata.
class HINFO : public Rdata {
public:
// BEGIN_COMMON_MEMBERS
diff --git a/src/lib/dns/tests/rdata_hinfo_unittest.cc b/src/lib/dns/tests/rdata_hinfo_unittest.cc
index f80952fa16..c9340717c2 100644
--- a/src/lib/dns/tests/rdata_hinfo_unittest.cc
+++ b/src/lib/dns/tests/rdata_hinfo_unittest.cc
@@ -51,6 +51,20 @@ TEST_F(Rdata_HINFO_Test, createFromText) {
EXPECT_EQ(string("Linux"), hinfo.getOS());
}
+TEST_F(Rdata_HINFO_Test, badText) {
+ // Fields must be seperated by spaces
+ EXPECT_THROW(const HINFO hinfo("\"Pentium\"\"Linux\""), InvalidRdataText);
+ // Field cannot be missing
+ EXPECT_THROW(const HINFO hinfo("Pentium"), InvalidRdataText);
+ // The <character-string> cannot exceed 255 characters
+ string hinfo_str;
+ for (int i = 0; i < 257; ++i) {
+ hinfo_str += 'A';
+ }
+ hinfo_str += " Linux";
+ EXPECT_THROW(const HINFO hinfo(hinfo_str), CharStringTooLong);
+}
+
TEST_F(Rdata_HINFO_Test, createFromWire) {
InputBuffer input_buffer(hinfo_rdata, sizeof(hinfo_rdata));
HINFO hinfo(input_buffer, sizeof(hinfo_rdata));