From d5ef463e5069283279ad7d90cdcc0be540283f11 Mon Sep 17 00:00:00 2001 From: Fred Morcos Date: Thu, 23 Nov 2023 10:55:35 +0100 Subject: [PATCH] Whitespace cleanup in tests --- pdns/test-dnsname_cc.cc | 50 ++++++++++++++++++------------------ pdns/test-dnsparser_cc.cc | 2 +- pdns/test-nameserver_cc.cc | 8 +++--- pdns/test-rcpgenerator_cc.cc | 2 +- pdns/test-sha_hh.cc | 32 +++++++++++------------ pdns/test-statbag_cc.cc | 7 +++-- 6 files changed, 50 insertions(+), 51 deletions(-) diff --git a/pdns/test-dnsname_cc.cc b/pdns/test-dnsname_cc.cc index 6498e3dfa99d..03ee6da0f1a9 100644 --- a/pdns/test-dnsname_cc.cc +++ b/pdns/test-dnsname_cc.cc @@ -23,10 +23,10 @@ BOOST_AUTO_TEST_SUITE(test_dnsname_cc) BOOST_AUTO_TEST_CASE(test_basic) { DNSName aroot("a.root-servers.net"), broot("b.root-servers.net"); BOOST_CHECK(aroot < broot); - BOOST_CHECK(!(broot < aroot)); + BOOST_CHECK(!(broot < aroot)); BOOST_CHECK(aroot.canonCompare(broot)); - BOOST_CHECK(!broot.canonCompare(aroot)); - + BOOST_CHECK(!broot.canonCompare(aroot)); + string before("www.ds9a.nl."); DNSName b(before); @@ -112,14 +112,14 @@ BOOST_AUTO_TEST_CASE(test_basic) { DNSName name; BOOST_CHECK(name.empty()); } - + { // empty() root DNSName name("."); BOOST_CHECK(!name.empty()); - + DNSName rootnodot(""); BOOST_CHECK_EQUAL(name, rootnodot); - + string empty; DNSName rootnodot2(empty); BOOST_CHECK_EQUAL(rootnodot2, name); @@ -132,7 +132,7 @@ BOOST_AUTO_TEST_CASE(test_basic) { left.appendRawLabel("com"); BOOST_CHECK( left == DNSName("WwW.Ds9A.Nl.com.")); - + DNSName unset; unset.appendRawLabel("www"); @@ -212,7 +212,7 @@ BOOST_AUTO_TEST_CASE(test_empty) { BOOST_CHECK(!empty.isWildcard()); BOOST_CHECK_EQUAL(empty, empty); BOOST_CHECK(!(empty < empty)); - + DNSName root("."); BOOST_CHECK(empty < root); @@ -222,7 +222,7 @@ BOOST_AUTO_TEST_CASE(test_empty) { BOOST_AUTO_TEST_CASE(test_specials) { DNSName root("."); - + BOOST_CHECK(root.isRoot()); BOOST_CHECK(root != DNSName()); @@ -255,7 +255,7 @@ BOOST_AUTO_TEST_CASE(test_chopping) { BOOST_AUTO_TEST_CASE(test_Append) { DNSName dn("www."), powerdns("powerdns.com."); DNSName tot=dn+powerdns; - + BOOST_CHECK_EQUAL(tot.toString(), "www.powerdns.com."); BOOST_CHECK(tot == DNSName("www.powerdns.com.")); @@ -284,14 +284,14 @@ BOOST_AUTO_TEST_CASE(test_packetCompress) { aaaa.toPacket(dpw); dpw.commit(); string str((const char*)&packet[0], (const char*)&packet[0] + packet.size()); - size_t pos = 0; + size_t pos = 0; int count=0; while((pos = str.find("ds9a", pos)) != string::npos) { ++pos; ++count; } BOOST_CHECK_EQUAL(count, 1); - pos = 0; + pos = 0; count=0; while((pos = str.find("powerdns", pos)) != string::npos) { ++pos; @@ -313,7 +313,7 @@ BOOST_AUTO_TEST_CASE(test_packetCompressLong) { dpw.commit(); DNSName roundtrip((char*)&packet[0], packet.size(), 12, false); BOOST_CHECK_EQUAL(loopback,roundtrip); - + packet.clear(); DNSName longer("1.2.3.4.5.6.7.8.1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa"); DNSPacketWriter dpw2(packet, longer, QType::PTR); @@ -350,26 +350,26 @@ BOOST_AUTO_TEST_CASE(test_PacketParse) { BOOST_AUTO_TEST_CASE(test_hash) { DNSName a("wwW.Ds9A.Nl"), b("www.ds9a.nl"); BOOST_CHECK_EQUAL(a.hash(), b.hash()); - + vector counts(1500); - + for(unsigned int n=0; n < 100000; ++n) { DNSName dn(std::to_string(n)+"."+std::to_string(n*2)+"ds9a.nl"); DNSName dn2(std::to_string(n)+"."+std::to_string(n*2)+"Ds9a.nL"); BOOST_CHECK_EQUAL(dn.hash(), dn2.hash()); counts[dn.hash() % counts.size()]++; } - + double sum = std::accumulate(std::begin(counts), std::end(counts), 0.0); double m = sum / counts.size(); - + double accum = 0.0; std::for_each (std::begin(counts), std::end(counts), [&](const double d) { accum += (d - m) * (d - m); }); - + double stdev = sqrt(accum / (counts.size()-1)); - BOOST_CHECK(stdev < 10); + BOOST_CHECK(stdev < 10); } BOOST_AUTO_TEST_CASE(test_hashContainer) { @@ -455,7 +455,7 @@ BOOST_AUTO_TEST_CASE(test_packetParse) { vector packet; reportBasicTypes(); DNSPacketWriter dpw(packet, DNSName("www.ds9a.nl."), QType::AAAA); - + uint16_t qtype, qclass; DNSName dn((char*)&packet[0], packet.size(), 12, false, &qtype, &qclass); BOOST_CHECK_EQUAL(dn.toString(), "www.ds9a.nl."); @@ -479,15 +479,15 @@ BOOST_AUTO_TEST_CASE(test_packetParse) { content name */ DNSName dn2((char*)&packet[0], packet.size(), 12+13+4, true, &qtype, &qclass); - BOOST_CHECK_EQUAL(dn2.toString(), "ds9a.nl."); + BOOST_CHECK_EQUAL(dn2.toString(), "ds9a.nl."); BOOST_CHECK(qtype == QType::NS); BOOST_CHECK_EQUAL(qclass, 1); DNSName dn3((char*)&packet[0], packet.size(), 12+13+4+2 + 4 + 4 + 2, true); - BOOST_CHECK_EQUAL(dn3.toString(), "ns1.powerdns.com."); + BOOST_CHECK_EQUAL(dn3.toString(), "ns1.powerdns.com."); try { DNSName dn4((char*)&packet[0], packet.size(), 12+13+4, false); // compressed, should fail - BOOST_CHECK(0); + BOOST_CHECK(0); } catch(...){} } @@ -720,7 +720,7 @@ BOOST_AUTO_TEST_CASE(test_compare_canonical) { vector vec; for(const char* b : {"bert.com.", "alpha.nl.", "articles.xxx.", - "Aleph1.powerdns.com.", "ZOMG.powerdns.com.", "aaa.XXX.", "yyy.XXX.", + "Aleph1.powerdns.com.", "ZOMG.powerdns.com.", "aaa.XXX.", "yyy.XXX.", "test.powerdns.com.", "\\128.com"}) { vec.push_back(DNSName(b)); } @@ -739,7 +739,7 @@ BOOST_AUTO_TEST_CASE(test_compare_canonical) { "yyy.XXX."}) right.push_back(DNSName(b)); - + BOOST_CHECK(vec==right); } diff --git a/pdns/test-dnsparser_cc.cc b/pdns/test-dnsparser_cc.cc index 79da18a27cbe..bfcc66842c0f 100644 --- a/pdns/test-dnsparser_cc.cc +++ b/pdns/test-dnsparser_cc.cc @@ -610,7 +610,7 @@ BOOST_AUTO_TEST_CASE(test_clearDNSPacketUnsafeRecordTypes) { // MX is unsafe, but we asked to remove it BOOST_CHECK_EQUAL(getRecordsOfTypeCount(reinterpret_cast(packet.data()), packet.size(), 1, QType::A), 1); BOOST_CHECK_EQUAL(getRecordsOfTypeCount(reinterpret_cast(packet.data()), packet.size(), 1, QType::AAAA), 0); - BOOST_CHECK_EQUAL(getRecordsOfTypeCount(reinterpret_cast(packet.data()), packet.size(), 3, QType::A), 1); + BOOST_CHECK_EQUAL(getRecordsOfTypeCount(reinterpret_cast(packet.data()), packet.size(), 3, QType::A), 1); BOOST_CHECK_EQUAL(getRecordsOfTypeCount(reinterpret_cast(packet.data()), packet.size(), 3, QType::MX), 0); } diff --git a/pdns/test-nameserver_cc.cc b/pdns/test-nameserver_cc.cc index 0dccf727731d..a82ba235f1fe 100644 --- a/pdns/test-nameserver_cc.cc +++ b/pdns/test-nameserver_cc.cc @@ -25,11 +25,11 @@ BOOST_AUTO_TEST_CASE(test_AddressIsUs4) { ComboAddress Remote("192.168.255.255", 53); g_localaddresses.push_back(ComboAddress("0.0.0.0", 53)); - + BOOST_CHECK_EQUAL(AddressIsUs(local1), true); // BOOST_CHECK_EQUAL(AddressIsUs(local2), false); BOOST_CHECK_EQUAL(AddressIsUs(Remote), false); - + g_localaddresses.clear(); g_localaddresses.push_back(ComboAddress("192.168.255.255", 53)); BOOST_CHECK_EQUAL(AddressIsUs(Remote), true); @@ -42,10 +42,10 @@ BOOST_AUTO_TEST_CASE(test_AddressIsUs6) { ComboAddress local2("127.0.0.2", 53); ComboAddress local3("::1", 53); ComboAddress Remote("192.168.255.255", 53); - + g_localaddresses.clear(); g_localaddresses.push_back(ComboAddress("::", 53)); - + BOOST_CHECK_EQUAL(AddressIsUs(local1), true); // BOOST_CHECK_EQUAL(AddressIsUs(local2), false); if(!getenv("PDNS_TEST_NO_IPV6")) BOOST_CHECK_EQUAL(AddressIsUs(local3), true); diff --git a/pdns/test-rcpgenerator_cc.cc b/pdns/test-rcpgenerator_cc.cc index c78495bcd64e..ba8357d6ad36 100644 --- a/pdns/test-rcpgenerator_cc.cc +++ b/pdns/test-rcpgenerator_cc.cc @@ -24,7 +24,7 @@ BOOST_AUTO_TEST_CASE(test_xfrIP6) { loopback6.append(15, 0); loopback6.append(1,1); BOOST_CHECK_EQUAL(makeHexDump(rawIPv6), makeHexDump(loopback6)); - + RecordTextReader rtr2("2a01:4f8:d12:1880::5"); rtr2.xfrIP6(rawIPv6); string ip6("\x2a\x01\x04\xf8\x0d\x12\x18\x80\x00\x00\x00\x00\x00\x00\x00\x05", 16); diff --git a/pdns/test-sha_hh.cc b/pdns/test-sha_hh.cc index 8eebf5f943c5..296e40a7e582 100644 --- a/pdns/test-sha_hh.cc +++ b/pdns/test-sha_hh.cc @@ -28,40 +28,40 @@ BOOST_AUTO_TEST_CASE(test_sha1) { cases_t cases = list_of (case_t("abc", "a9 99 3e 36 47 06 81 6a ba 3e 25 71 78 50 c2 6c 9c d0 d8 9d ")) (case_t("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", "84 98 3e 44 1c 3b d2 6e ba ae 4a a1 f9 51 29 e5 e5 46 70 f1 ")); - + for(case_t& val : cases) { BOOST_CHECK_EQUAL(makeHexDump(pdns_sha1sum(val.get<0>())), val.get<1>()); } } BOOST_AUTO_TEST_CASE(test_sha256) { - cases_t cases = list_of - (case_t("abc", "ba 78 16 bf 8f 01 cf ea 41 41 40 de 5d ae 22 23 b0 03 61 a3 96 17 7a 9c b4 10 ff 61 f2 00 15 ad ")) - (case_t("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", "24 8d 6a 61 d2 06 38 b8 e5 c0 26 93 0c 3e 60 39 a3 3c e4 59 64 ff 21 67 f6 ec ed d4 19 db 06 c1 ")); + cases_t cases = list_of + (case_t("abc", "ba 78 16 bf 8f 01 cf ea 41 41 40 de 5d ae 22 23 b0 03 61 a3 96 17 7a 9c b4 10 ff 61 f2 00 15 ad ")) + (case_t("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", "24 8d 6a 61 d2 06 38 b8 e5 c0 26 93 0c 3e 60 39 a3 3c e4 59 64 ff 21 67 f6 ec ed d4 19 db 06 c1 ")); - for(case_t& val : cases) { + for(case_t& val : cases) { BOOST_CHECK_EQUAL(makeHexDump(pdns_sha256sum(val.get<0>())), val.get<1>()); - } + } } BOOST_AUTO_TEST_CASE(test_sha384) { - cases_t cases = list_of - (case_t("abc", "cb 00 75 3f 45 a3 5e 8b b5 a0 3d 69 9a c6 50 07 27 2c 32 ab 0e de d1 63 1a 8b 60 5a 43 ff 5b ed 80 86 07 2b a1 e7 cc 23 58 ba ec a1 34 c8 25 a7 ")) - (case_t("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", "33 91 fd dd fc 8d c7 39 37 07 a6 5b 1b 47 09 39 7c f8 b1 d1 62 af 05 ab fe 8f 45 0d e5 f3 6b c6 b0 45 5a 85 20 bc 4e 6f 5f e9 5b 1f e3 c8 45 2b ")); + cases_t cases = list_of + (case_t("abc", "cb 00 75 3f 45 a3 5e 8b b5 a0 3d 69 9a c6 50 07 27 2c 32 ab 0e de d1 63 1a 8b 60 5a 43 ff 5b ed 80 86 07 2b a1 e7 cc 23 58 ba ec a1 34 c8 25 a7 ")) + (case_t("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", "33 91 fd dd fc 8d c7 39 37 07 a6 5b 1b 47 09 39 7c f8 b1 d1 62 af 05 ab fe 8f 45 0d e5 f3 6b c6 b0 45 5a 85 20 bc 4e 6f 5f e9 5b 1f e3 c8 45 2b ")); - for(case_t& val : cases) { + for(case_t& val : cases) { BOOST_CHECK_EQUAL(makeHexDump(pdns_sha384sum(val.get<0>())), val.get<1>()); - } + } } BOOST_AUTO_TEST_CASE(test_sha512) { - cases_t cases = list_of - (case_t("abc", "dd af 35 a1 93 61 7a ba cc 41 73 49 ae 20 41 31 12 e6 fa 4e 89 a9 7e a2 0a 9e ee e6 4b 55 d3 9a 21 92 99 2a 27 4f c1 a8 36 ba 3c 23 a3 fe eb bd 45 4d 44 23 64 3c e8 0e 2a 9a c9 4f a5 4c a4 9f ")) - (case_t("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", "20 4a 8f c6 dd a8 2f 0a 0c ed 7b eb 8e 08 a4 16 57 c1 6e f4 68 b2 28 a8 27 9b e3 31 a7 03 c3 35 96 fd 15 c1 3b 1b 07 f9 aa 1d 3b ea 57 78 9c a0 31 ad 85 c7 a7 1d d7 03 54 ec 63 12 38 ca 34 45 ")); + cases_t cases = list_of + (case_t("abc", "dd af 35 a1 93 61 7a ba cc 41 73 49 ae 20 41 31 12 e6 fa 4e 89 a9 7e a2 0a 9e ee e6 4b 55 d3 9a 21 92 99 2a 27 4f c1 a8 36 ba 3c 23 a3 fe eb bd 45 4d 44 23 64 3c e8 0e 2a 9a c9 4f a5 4c a4 9f ")) + (case_t("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", "20 4a 8f c6 dd a8 2f 0a 0c ed 7b eb 8e 08 a4 16 57 c1 6e f4 68 b2 28 a8 27 9b e3 31 a7 03 c3 35 96 fd 15 c1 3b 1b 07 f9 aa 1d 3b ea 57 78 9c a0 31 ad 85 c7 a7 1d d7 03 54 ec 63 12 38 ca 34 45 ")); - for(case_t& val : cases) { + for(case_t& val : cases) { BOOST_CHECK_EQUAL(makeHexDump(pdns_sha512sum(val.get<0>())), val.get<1>()); - } + } } BOOST_AUTO_TEST_SUITE_END() diff --git a/pdns/test-statbag_cc.cc b/pdns/test-statbag_cc.cc index bbde1705e2be..424cb1af942c 100644 --- a/pdns/test-statbag_cc.cc +++ b/pdns/test-statbag_cc.cc @@ -41,7 +41,7 @@ BOOST_AUTO_TEST_CASE(test_StatBagBasic) { s.declare("c", "description"); s.inc("a"); BOOST_CHECK_EQUAL(s.read("a"), 1UL); - + unsigned long n; for(n=0; n < 1000000; ++n) s.inc("b"); @@ -66,7 +66,7 @@ BOOST_AUTO_TEST_CASE(test_StatBagBasic) { manglers.clear(); BOOST_CHECK_EQUAL(s.read("c"), 4000000U); - + s.set("c", 0); for (int i=0; i < 4; ++i) { @@ -86,7 +86,7 @@ BOOST_AUTO_TEST_CASE(test_StatBagBasic) { s.inc("c"); BOOST_CHECK_EQUAL(s.read("c"), (1ULL<<31) +1 ); -#ifdef UINTPTR_MAX +#ifdef UINTPTR_MAX #if UINTPTR_MAX > 0xffffffffULL BOOST_CHECK_EQUAL(sizeof(AtomicCounterInner), 8U); s.set("c", 1ULL<<33); @@ -111,4 +111,3 @@ BOOST_AUTO_TEST_CASE(test_StatBagBasic) { BOOST_AUTO_TEST_SUITE_END() -