]> granicus.if.org Git - pdns/commitdiff
Add tests for DNSName::wirelength()
authorPieter Lexis <pieter.lexis@powerdns.com>
Mon, 26 Oct 2015 08:29:29 +0000 (09:29 +0100)
committerPieter Lexis <pieter.lexis@powerdns.com>
Mon, 26 Oct 2015 18:50:07 +0000 (19:50 +0100)
pdns/test-dnsname_cc.cc

index fdfa3016033c4705a60fc784bd449d75138f1487..b0a5948ddb9582895b6bea0338cc6937803cdc0b 100644 (file)
@@ -528,4 +528,17 @@ BOOST_AUTO_TEST_CASE(test_compression_loop2) { // Compression loop (deep recursi
   BOOST_CHECK_THROW(DNSName dn(name.c_str(), name.size(), name.size()-2, true), std::range_error);
 }
 
+BOOST_AUTO_TEST_CASE(test_wirelength) { // Testing if we get the correct value from the wirelength function
+  DNSName name("www.powerdns.com");
+  BOOST_CHECK_EQUAL(name.wirelength(), 18);
+
+  DNSName sname("powerdns.com");
+  sname.prependRawLabel(string("ww\x00""w", 4));
+  BOOST_CHECK_EQUAL(sname.wirelength(), 19);
+
+  sname = DNSName("powerdns.com");
+  sname.prependRawLabel(string("www\x00", 4));
+  BOOST_CHECK_EQUAL(sname.wirelength(), 19);
+}
+
 BOOST_AUTO_TEST_SUITE_END()