Browse Source

[trac1112] Add more unit tests and comments

Ocean Wang 13 years ago
parent
commit
4e12574323

+ 3 - 3
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

+ 6 - 0
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

+ 14 - 0
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));