]> git.ipfire.org Git - thirdparty/pdns.git/blame - pdns/test-zoneparser_tng_cc.cc
rec: ensure correct service user on debian
[thirdparty/pdns.git] / pdns / test-zoneparser_tng_cc.cc
CommitLineData
108a4c3c
AT
1#define BOOST_TEST_DYN_LINK
2#define BOOST_TEST_NO_MAIN
870a0fe4
AT
3#ifdef HAVE_CONFIG_H
4#include "config.h"
5#endif
108a4c3c
AT
6#include <boost/test/unit_test.hpp>
7#include <boost/assign/list_of.hpp>
fa8fd4d2 8
108a4c3c 9#include <boost/tuple/tuple.hpp>
108a4c3c 10#include <boost/iostreams/device/file.hpp>
108a4c3c
AT
11#include "dns.hh"
12#include "zoneparser-tng.hh"
c14af8a9 13#include "dnsrecords.hh"
a61e8e59 14#include "dnsname.hh"
108a4c3c 15#include <fstream>
a245e51c 16#include <cstdlib>
108a4c3c
AT
17
18BOOST_AUTO_TEST_SUITE(test_zoneparser_tng_cc)
19
20BOOST_AUTO_TEST_CASE(test_tng_record_types) {
c14af8a9 21 reportAllTypes();
c14af8a9 22
a245e51c 23 std::ostringstream pathbuf;
0d73f0ab 24 const char* p = std::getenv("SRCDIR");
25 if(!p)
26 p = ".";
27 pathbuf << p << "/../regression-tests/zones/unit.test";
eaedd091 28 ZoneParserTNG zp(pathbuf.str(), DNSName("unit.test"));
108a4c3c
AT
29 DNSResourceRecord rr;
30
e59c5996 31 ifstream ifs(pathbuf.str());
108a4c3c
AT
32
33 while(zp.get(rr)) {
34 // make sure these concur.
35 std::string host, type, data;
335da0ba 36 unsigned int ttl;
108a4c3c
AT
37 std::getline(ifs, host, ' ');
38 std::getline(ifs, type, ' ');
335da0ba 39 ttl = pdns_stou(type);
108a4c3c
AT
40 std::getline(ifs, type, ' ');
41 std::getline(ifs, type, ' ');
42 std::getline(ifs, data, '\n');
43 // see if these agree
d66269ef 44 BOOST_CHECK_EQUAL(rr.qname.toString(), host);
108a4c3c
AT
45 BOOST_CHECK_EQUAL(rr.ttl, ttl);
46 BOOST_CHECK_EQUAL(rr.qtype.getName(), type);
77e0833b 47 if (rr.qtype == QType::SOA)
3343ad1f 48 continue; // FIXME400 remove trailing dots from data
4c22f7c5
AT
49 if (*(rr.content.rbegin()) != '.' && *(data.rbegin()) == '.')
50 BOOST_CHECK_EQUAL(rr.content, std::string(data.begin(),data.end()-1));
51 else
52 BOOST_CHECK_EQUAL(rr.content, data);
108a4c3c
AT
53 }
54
55}
56
57BOOST_AUTO_TEST_SUITE_END();