From: Stefan Bühler Date: Thu, 28 Dec 2017 22:05:27 +0000 (+0100) Subject: test-dnsrecords: use enum class for case_type_enum_t, fix compile error testing wrong... X-Git-Tag: dnsdist-1.3.0~172^2~5 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b7991a649a326c4f865fd45c559d514d30e5f06b;p=pdns test-dnsrecords: use enum class for case_type_enum_t, fix compile error testing wrong tuple entry --- diff --git a/pdns/test-dnsrecords_cc.cc b/pdns/test-dnsrecords_cc.cc index 72d400fb1..c8250f502 100644 --- a/pdns/test-dnsrecords_cc.cc +++ b/pdns/test-dnsrecords_cc.cc @@ -17,9 +17,11 @@ BOOST_AUTO_TEST_SUITE(test_dnsrecords_cc) #define REC_CHECK_EQUAL(a,b) { if (val.get<4>()) { BOOST_WARN_EQUAL(a,b); } else { BOOST_CHECK_EQUAL(a,b); } } #define REC_CHECK_MESSAGE(cond,msg) { if (val.get<4>()) { BOOST_WARN_MESSAGE(cond,msg); } else { BOOST_CHECK_MESSAGE(cond,msg); } } #define REC_FAIL_XSUCCESS(msg) { if (val.get<4>()) { BOOST_CHECK_MESSAGE(false, std::string("Test has unexpectedly passed: ") + msg); } } // fail if test succeeds -#define REC_FAIL_XSUCCESS2(msg) { if (val.get<2>()) { BOOST_CHECK_MESSAGE(false, std::string("Test has unexpectedly passed: ") + msg); } } // fail if test succeeds (for the bad records test case) +#define REC_FAIL_XSUCCESS2(msg) { if (val.get<3>()) { BOOST_CHECK_MESSAGE(false, std::string("Test has unexpectedly passed: ") + msg); } } // fail if test succeeds (for the bad records test case) -typedef enum { zone, wire } case_type_enum_t; +enum class case_type_enum_t { zone, wire }; +static const auto zone = case_type_enum_t::zone; +static const auto wire = case_type_enum_t::wire; BOOST_AUTO_TEST_CASE(test_record_types) { // tuple contains @@ -269,7 +271,7 @@ BOOST_AUTO_TEST_CASE(test_record_types_bad_values) { vector packet; DNSPacketWriter pw(packet, DNSName("unit.test"), q.getCode()); - if (val.get<2>()) { + if (val.get<3>()) { bool success=true; BOOST_WARN_EXCEPTION( { auto drc = DNSRecordContent::mastermake(q.getCode(), 1, val.get<1>()); pw.startRecord(DNSName("unit.test"), q.getCode()); drc->toPacket(pw); success=false; }, std::exception, test_dnsrecords_cc_predicate ); if (success==false) REC_FAIL_XSUCCESS2(q.getName() << " test #" << n << " has unexpectedly passed"); // a bad record was detected when it was supposed not to be detected