Parcourir la source

[2497] Add tests for HINFO, MINFO and NAPTR rrtypes

Mukund Sivaraman il y a 12 ans
Parent
commit
25f65134a9

+ 13 - 0
src/lib/dns/tests/rdata_hinfo_unittest.cc

@@ -77,6 +77,19 @@ TEST_F(Rdata_HINFO_Test, createFromWire) {
     EXPECT_EQ(string("Linux"), hinfo.getOS());
     EXPECT_EQ(string("Linux"), hinfo.getOS());
 }
 }
 
 
+TEST_F(Rdata_HINFO_Test, createFromLexer) {
+    HINFO rdata_hinfo(hinfo_str);
+    EXPECT_EQ(0, rdata_hinfo.compare(
+        *test::createRdataUsingLexer(RRType::HINFO(), RRClass::IN(),
+                                     hinfo_str)));
+
+    // Check that bad input throws as usual
+    EXPECT_THROW({
+        *test::createRdataUsingLexer(RRType::HINFO(), RRClass::IN(),
+                                     "\"Pentium\"\"Linux\"");
+    }, InvalidRdataText);
+}
+
 TEST_F(Rdata_HINFO_Test, toText) {
 TEST_F(Rdata_HINFO_Test, toText) {
     HINFO hinfo(hinfo_str);
     HINFO hinfo(hinfo_str);
     EXPECT_EQ(hinfo_str, hinfo.toText());
     EXPECT_EQ(hinfo_str, hinfo.toText());

+ 6 - 0
src/lib/dns/tests/rdata_minfo_unittest.cc

@@ -103,6 +103,12 @@ TEST_F(Rdata_MINFO_Test, createFromWire) {
                  DNSMessageFORMERR);
                  DNSMessageFORMERR);
 }
 }
 
 
+TEST_F(Rdata_MINFO_Test, createFromLexer) {
+    EXPECT_EQ(0, rdata_minfo.compare(
+        *test::createRdataUsingLexer(RRType::MINFO(), RRClass::IN(),
+                                     minfo_txt)));
+}
+
 TEST_F(Rdata_MINFO_Test, assignment) {
 TEST_F(Rdata_MINFO_Test, assignment) {
     generic::MINFO copy((string(minfo_txt2)));
     generic::MINFO copy((string(minfo_txt2)));
     copy = rdata_minfo;
     copy = rdata_minfo;

+ 15 - 0
src/lib/dns/tests/rdata_naptr_unittest.cc

@@ -128,6 +128,21 @@ TEST_F(Rdata_NAPTR_Test, createFromWire) {
     EXPECT_EQ(Name("_sip._udp.example.com."), naptr.getReplacement());
     EXPECT_EQ(Name("_sip._udp.example.com."), naptr.getReplacement());
 }
 }
 
 
+TEST_F(Rdata_NAPTR_Test, createFromLexer) {
+    NAPTR rdata_naptr(naptr_str);
+
+    EXPECT_EQ(0, rdata_naptr.compare(
+        *test::createRdataUsingLexer(RRType::NAPTR(), RRClass::IN(),
+                                     naptr_str)));
+
+    // Check that bad input throws as usual (order > 65535)
+    EXPECT_THROW({
+        *test::createRdataUsingLexer(RRType::NAPTR(), RRClass::IN(),
+                                     "65536 10 S SIP \"\" "
+                                     "_sip._udp.example.com.");
+    }, InvalidRdataText);
+}
+
 TEST_F(Rdata_NAPTR_Test, toWire) {
 TEST_F(Rdata_NAPTR_Test, toWire) {
     NAPTR naptr(naptr_str);
     NAPTR naptr(naptr_str);
     naptr.toWire(obuffer);
     naptr.toWire(obuffer);