Parcourir la source

[2498] Add a few quoting tests for toText() in HINFO and NAPTR

Jelte Jansen il y a 12 ans
Parent
commit
7cbed6378d

+ 5 - 0
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) {

+ 8 - 0
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) {