File: test-dnsrecordcontent.cc

package info (click to toggle)
pdns-recursor 5.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,108 kB
  • sloc: cpp: 109,513; javascript: 20,651; python: 5,657; sh: 5,069; makefile: 780; ansic: 582; xml: 37
file content (47 lines) | stat: -rw-r--r-- 1,394 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#ifndef BOOST_TEST_DYN_LINK
#define BOOST_TEST_DYN_LINK
#endif

#define BOOST_TEST_NO_MAIN
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <boost/test/unit_test.hpp>
#include "dnsrecords.hh"
#include "iputils.hh"

BOOST_AUTO_TEST_SUITE(test_dnsrecordcontent)

BOOST_AUTO_TEST_CASE(test_equality) {
  ComboAddress ip("1.2.3.4"), ip2("10.0.0.1"), ip6("::1");
  ARecordContent a1(ip), a2(ip), a3(ip2);
  AAAARecordContent aaaa(ip6), aaaa1(ip6);
  
  BOOST_CHECK(a1==a2);
  BOOST_CHECK(!(a1==a3));

  BOOST_CHECK(aaaa == aaaa1);

  auto rec1 = DNSRecordContent::make(QType::A, 1, "192.168.0.1");
  auto rec2 = DNSRecordContent::make(QType::A, 1, "192.168.222.222");
  auto rec3 = DNSRecordContent::make(QType::AAAA, 1, "::1");
  auto recMX = DNSRecordContent::make(QType::MX, 1, "25 smtp.powerdns.com");
  auto recMX2 = DNSRecordContent::make(QType::MX, 1, "26 smtp.powerdns.com");
  auto recMX3 = DNSRecordContent::make(QType::MX, 1, "26 SMTP.powerdns.com");
  BOOST_CHECK(!(*rec1==*rec2));
  BOOST_CHECK(*rec1==*rec1);
  BOOST_CHECK(*rec3==*rec3);

  BOOST_CHECK(*recMX==*recMX);
  BOOST_CHECK(*recMX2==*recMX3);
  BOOST_CHECK(!(*recMX==*recMX3));
  
  
  BOOST_CHECK(!(*rec1==*rec3));

  NSRecordContent ns1(DNSName("ns1.powerdns.com")), ns2(DNSName("NS1.powerdns.COM")), ns3(DNSName("powerdns.net"));
  BOOST_CHECK(ns1==ns2);
  BOOST_CHECK(!(ns1==ns3));
}

BOOST_AUTO_TEST_SUITE_END()