From: bert hubert Date: Fri, 26 Aug 2016 10:51:05 +0000 (+0200) Subject: add a test that checks we compress all the things in packetwriter X-Git-Tag: dnsdist-1.1.0-beta2~166^2~12 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7448abde898f83171e85e3a15866e8fb849ed7fa;p=pdns add a test that checks we compress all the things in packetwriter --- diff --git a/pdns/test-dnsname_cc.cc b/pdns/test-dnsname_cc.cc index 11997bf56..26f232ea8 100644 --- a/pdns/test-dnsname_cc.cc +++ b/pdns/test-dnsname_cc.cc @@ -249,6 +249,39 @@ BOOST_AUTO_TEST_CASE(test_Append) { BOOST_CHECK(dn == DNSName("www.powerdns.com.")); } +BOOST_AUTO_TEST_CASE(test_packetCompress) { + reportBasicTypes(); + vector packet; + DNSPacketWriter dpw(packet, DNSName("www.ds9a.nl."), QType::AAAA); + dpw.startRecord(DNSName("ds9a.nl"), QType::SOA); + SOARecordContent src("ns1.ds9a.nl admin.ds9a.nl 1 2 3 4 5"); + src.toPacket(dpw); + AAAARecordContent aaaa("::1"); + dpw.startRecord(DNSName("www.dS9A.nl"), QType::AAAA); + aaaa.toPacket(dpw); + dpw.startRecord(DNSName("www.ds9A.nl"), QType::AAAA); + aaaa.toPacket(dpw); + dpw.startRecord(DNSName("www.dS9a.nl"), QType::AAAA); + aaaa.toPacket(dpw); + dpw.startRecord(DNSName("www2.DS9a.nl"), QType::AAAA); + aaaa.toPacket(dpw); + dpw.startRecord(DNSName("www2.dS9a.nl"), QType::AAAA); + aaaa.toPacket(dpw); + dpw.commit(); + string str((const char*)&packet[0], (const char*)&packet[0] + packet.size()); + + size_t pos = 0; + int count=0; + while((pos = str.find("ds9a", pos)) != string::npos) { + ++pos; + ++count; + } + BOOST_CHECK_EQUAL(count, 1); +} + + + + BOOST_AUTO_TEST_CASE(test_PacketParse) { vector packet; reportBasicTypes();