]> git.ipfire.org Git - thirdparty/pdns.git/blob - pdns/test-dnsrecordcontent.cc
Merge pull request #14195 from rgacogne/ddist-no-assertions
[thirdparty/pdns.git] / pdns / test-dnsrecordcontent.cc
1 #ifndef BOOST_TEST_DYN_LINK
2 #define BOOST_TEST_DYN_LINK
3 #endif
4
5 #define BOOST_TEST_NO_MAIN
6 #ifdef HAVE_CONFIG_H
7 #include "config.h"
8 #endif
9 #include <boost/test/unit_test.hpp>
10 #include "dnsrecords.hh"
11 #include "iputils.hh"
12
13 BOOST_AUTO_TEST_SUITE(test_dnsrecordcontent)
14
15 BOOST_AUTO_TEST_CASE(test_equality) {
16 ComboAddress ip("1.2.3.4"), ip2("10.0.0.1"), ip6("::1");
17 ARecordContent a1(ip), a2(ip), a3(ip2);
18 AAAARecordContent aaaa(ip6), aaaa1(ip6);
19
20 BOOST_CHECK(a1==a2);
21 BOOST_CHECK(!(a1==a3));
22
23 BOOST_CHECK(aaaa == aaaa1);
24
25 auto rec1 = DNSRecordContent::make(QType::A, 1, "192.168.0.1");
26 auto rec2 = DNSRecordContent::make(QType::A, 1, "192.168.222.222");
27 auto rec3 = DNSRecordContent::make(QType::AAAA, 1, "::1");
28 auto recMX = DNSRecordContent::make(QType::MX, 1, "25 smtp.powerdns.com");
29 auto recMX2 = DNSRecordContent::make(QType::MX, 1, "26 smtp.powerdns.com");
30 auto recMX3 = DNSRecordContent::make(QType::MX, 1, "26 SMTP.powerdns.com");
31 BOOST_CHECK(!(*rec1==*rec2));
32 BOOST_CHECK(*rec1==*rec1);
33 BOOST_CHECK(*rec3==*rec3);
34
35 BOOST_CHECK(*recMX==*recMX);
36 BOOST_CHECK(*recMX2==*recMX3);
37 BOOST_CHECK(!(*recMX==*recMX3));
38
39
40 BOOST_CHECK(!(*rec1==*rec3));
41
42 NSRecordContent ns1(DNSName("ns1.powerdns.com")), ns2(DNSName("NS1.powerdns.COM")), ns3(DNSName("powerdns.net"));
43 BOOST_CHECK(ns1==ns2);
44 BOOST_CHECK(!(ns1==ns3));
45 }
46
47 BOOST_AUTO_TEST_SUITE_END()