From: Pieter Lexis Date: Mon, 26 Oct 2015 08:29:29 +0000 (+0100) Subject: Add tests for DNSName::wirelength() X-Git-Tag: dnsdist-1.0.0-alpha1~230^2~33^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=68efe9eaf7b9cd4b34cd21926cdf6fd8821fa537;p=pdns Add tests for DNSName::wirelength() --- diff --git a/pdns/test-dnsname_cc.cc b/pdns/test-dnsname_cc.cc index fdfa30160..b0a5948dd 100644 --- a/pdns/test-dnsname_cc.cc +++ b/pdns/test-dnsname_cc.cc @@ -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()