Browse Source

[2500] added some more doc and more tests

JINMEI Tatuya 12 years ago
parent
commit
79007cc52b
2 changed files with 46 additions and 0 deletions
  1. 34 0
      src/lib/dns/rdata/generic/soa_6.cc
  2. 12 0
      src/lib/dns/tests/rdata_soa_unittest.cc

+ 34 - 0
src/lib/dns/rdata/generic/soa_6.cc

@@ -68,6 +68,21 @@ fillParameters(MasterLexer& lexer, uint8_t numdata[20]) {
 }
 }
 
+/// \brief Constructor from string.
+///
+/// The given string must represent a valid SOA RDATA.  There can be extra
+/// space characters at the beginning or end of the text (which are simply
+/// ignored), but other extra text, including a new line, will make the
+/// construction fail with an exception.
+///
+/// The MNAME and RNAME must be absolute since there's no parameter that
+/// specifies the origin name; if these are not absolute, \c MissingNameOrigin
+/// exception will be thrown.
+///
+/// See the construction that takes \c MasterLexer for other fields.
+///
+/// \throw Others Exception from the Name and RRTTL constructors.
+/// \throw InvalidRdataText Other general syntax errors.
 SOA::SOA(const std::string& soastr) :
     mname_(Name::ROOT_NAME()), rname_(Name::ROOT_NAME())
 {
@@ -90,6 +105,25 @@ SOA::SOA(const std::string& soastr) :
     }
 }
 
+/// \brief Constructor with a context of MasterLexer.
+///
+/// The \c lexer should point to the beginning of valid textual representation
+/// of an SOA RDATA.  The MNAME and RNAME fields can be non absolute if
+/// \c origin is non NULL, in which case \c origin is used to make them
+/// absolute.
+///
+/// The REFRESH, RETRY, EXPIRE, and MINIMUM fields can be either a valid
+/// decimal representation of an unsigned 32-bit integer or other
+/// valid textual representation of \c RRTTL such as "1H" (which means 3600).
+///
+/// \throw MasterLexer::LexerError General parsing error such as missing field.
+/// \throw Other Exceptions from the Name and RRTTL constructors if
+/// construction of textual fields as these objects fail.
+///
+/// \param lexer A \c MasterLexer object parsing a master file for the
+/// RDATA to be created
+/// \param origin If non NULL, specifies the origin of MNAME and RNAME when
+/// they are non absolute.
 SOA::SOA(MasterLexer& lexer, const Name* origin,
          MasterLoader::Options, MasterLoaderCallbacks&) :
     mname_(createName(lexer, origin)), rname_(createName(lexer, origin))

+ 12 - 0
src/lib/dns/tests/rdata_soa_unittest.cc

@@ -117,12 +117,24 @@ TEST_F(Rdata_SOA_Test, createFromText) {
     checkFromBadTexxt<InvalidRdataText, MasterLexer::LexerError>(
         ". . bad 0 0 0 0");
 
+    // bad serial; exceeding the uint32_t range (4294967296 = 2^32)
+    checkFromBadTexxt<InvalidRdataText, MasterLexer::LexerError>(
+        ". . 4294967296 0 0 0 0");
+
     // Bad format for other numeric parameters.  These will be tried as a TTL,
     // and result in an exception there.
     checkFromBadTexxt<InvalidRRTTL, InvalidRRTTL>(". . 2010012601 bad 0 0 0");
+    checkFromBadTexxt<InvalidRRTTL, InvalidRRTTL>(
+        ". . 2010012601 4294967296 0 0 0");
     checkFromBadTexxt<InvalidRRTTL, InvalidRRTTL>(". . 2010012601 0 bad 0 0");
+    checkFromBadTexxt<InvalidRRTTL, InvalidRRTTL>(
+        ". . 2010012601 0 4294967296 0 0");
     checkFromBadTexxt<InvalidRRTTL, InvalidRRTTL>(". . 2010012601 0 0 bad 0");
+    checkFromBadTexxt<InvalidRRTTL, InvalidRRTTL>(
+        ". . 2010012601 0 0 4294967296 0");
     checkFromBadTexxt<InvalidRRTTL, InvalidRRTTL>(". . 2010012601 0 0 0 bad");
+    checkFromBadTexxt<InvalidRRTTL, InvalidRRTTL>(
+        ". . 2010012601 0 0 0 4294967296");
 
     // No space between RNAME and serial.  This case is the same as missing
     // M/RNAME.