]>
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>
8 #include <boost/foreach.hpp>
9 #include <boost/tuple/tuple.hpp>
10 #include <boost/iostreams/stream.hpp>
11 #include <boost/iostreams/device/file.hpp>
12 #include <boost/lexical_cast.hpp>
14 #include "zoneparser-tng.hh"
15 #include "dnsrecords.hh"
20 BOOST_AUTO_TEST_SUITE(test_zoneparser_tng_cc
)
22 BOOST_AUTO_TEST_CASE(test_tng_record_types
) {
25 std::ostringstream pathbuf
;
26 const char* p
= std::getenv("SRCDIR");
29 pathbuf
<< p
<< "/../regression-tests/zones/unit.test";
30 ZoneParserTNG
zp(pathbuf
.str(), "unit.test");
33 ifstream
ifs(pathbuf
.str());
36 // make sure these concur.
37 std::string host
, type
, data
;
39 std::getline(ifs
, host
, ' ');
40 std::getline(ifs
, type
, ' ');
41 ttl
= boost::lexical_cast
<int>(type
);
42 std::getline(ifs
, type
, ' ');
43 std::getline(ifs
, type
, ' ');
44 std::getline(ifs
, data
, '\n');
46 BOOST_CHECK_EQUAL(rr
.qname
.toString(), host
);
47 BOOST_CHECK_EQUAL(rr
.ttl
, ttl
);
48 BOOST_CHECK_EQUAL(rr
.qtype
.getName(), type
);
49 if (rr
.qtype
== QType::SOA
)
50 continue; // FIXME400 remove trailing dots from data
51 if (*(rr
.content
.rbegin()) != '.' && *(data
.rbegin()) == '.')
52 BOOST_CHECK_EQUAL(rr
.content
, std::string(data
.begin(),data
.end()-1));
54 BOOST_CHECK_EQUAL(rr
.content
, data
);
59 BOOST_AUTO_TEST_SUITE_END();