]>
git.ipfire.org Git - thirdparty/pdns.git/blob - pdns/test-zoneparser_tng_cc.cc
1 #define BOOST_TEST_DYN_LINK
2 #define BOOST_TEST_NO_MAIN
6 #include <boost/test/unit_test.hpp>
7 #include <boost/assign/list_of.hpp>
9 #include <boost/tuple/tuple.hpp>
10 #include <boost/iostreams/device/file.hpp>
12 #include "zoneparser-tng.hh"
13 #include "dnsrecords.hh"
18 BOOST_AUTO_TEST_SUITE(test_zoneparser_tng_cc
)
20 BOOST_AUTO_TEST_CASE(test_tng_record_types
) {
23 std::ostringstream pathbuf
;
24 const char* p
= std::getenv("SRCDIR");
27 pathbuf
<< p
<< "/../regression-tests/zones/unit.test";
28 ZoneParserTNG
zp(pathbuf
.str(), DNSName("unit.test"));
31 ifstream
ifs(pathbuf
.str());
34 // make sure these concur.
35 std::string host
, type
, data
;
37 std::getline(ifs
, host
, ' ');
38 std::getline(ifs
, type
, ' ');
39 ttl
= pdns_stou(type
);
40 std::getline(ifs
, type
, ' ');
41 std::getline(ifs
, type
, ' ');
42 std::getline(ifs
, data
, '\n');
44 BOOST_CHECK_EQUAL(rr
.qname
.toString(), host
);
45 BOOST_CHECK_EQUAL(rr
.ttl
, ttl
);
46 BOOST_CHECK_EQUAL(rr
.qtype
.getName(), type
);
47 if (rr
.qtype
== QType::SOA
)
48 continue; // FIXME400 remove trailing dots from data
49 if (*(rr
.content
.rbegin()) != '.' && *(data
.rbegin()) == '.')
50 BOOST_CHECK_EQUAL(rr
.content
, std::string(data
.begin(),data
.end()-1));
52 BOOST_CHECK_EQUAL(rr
.content
, data
);
57 BOOST_AUTO_TEST_SUITE_END();