]>
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
3 #include <boost/test/unit_test.hpp>
4 #include <boost/assign/list_of.hpp>
5 #include <boost/foreach.hpp>
6 #include <boost/tuple/tuple.hpp>
7 #include <boost/iostreams/stream.hpp>
8 #include <boost/iostreams/device/file.hpp>
9 #include <boost/lexical_cast.hpp>
11 #include "zoneparser-tng.hh"
12 #include "dnsrecords.hh"
16 BOOST_AUTO_TEST_SUITE(test_zoneparser_tng_cc
)
18 BOOST_AUTO_TEST_CASE(test_tng_record_types
) {
22 std::ostringstream pathbuf
;
23 const char* p
= std::getenv("SRCDIR");
26 pathbuf
<< p
<< "/../regression-tests/zones/unit.test";
27 ZoneParserTNG
zp(pathbuf
.str(), "unit.test");
30 boost::iostreams::stream
<boost::iostreams::file_source
> ifs(pathbuf
.str());
33 // make sure these concur.
34 std::string host
, type
, data
;
36 std::getline(ifs
, host
, ' ');
37 std::getline(ifs
, type
, ' ');
38 ttl
= boost::lexical_cast
<int>(type
);
39 std::getline(ifs
, type
, ' ');
40 std::getline(ifs
, type
, ' ');
41 std::getline(ifs
, data
, '\n');
43 BOOST_CHECK_EQUAL(rr
.qname
, host
);
44 BOOST_CHECK_EQUAL(rr
.ttl
, ttl
);
45 BOOST_CHECK_EQUAL(rr
.qtype
.getName(), type
);
46 if (*(rr
.content
.rbegin()) != '.' && *(data
.rbegin()) == '.')
47 BOOST_CHECK_EQUAL(rr
.content
, std::string(data
.begin(),data
.end()-1));
49 BOOST_CHECK_EQUAL(rr
.content
, data
);
54 BOOST_AUTO_TEST_SUITE_END();