and add tests

This commit is contained in:
bert hubert 2018-04-13 11:03:07 +02:00
parent 619f8ed981
commit 80f162e635

30
tdns/tests.cc Normal file
View File

@ -0,0 +1,30 @@
#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file
#include "catch.hpp"
#include "dns-storage.hh"
using namespace std;
TEST_CASE("DNSLabel equality", "[dnslabel]") {
DNSLabel a("www"), b("WWW");
REQUIRE(a==b);
REQUIRE(!(a<b));
REQUIRE(!(b<a));
}
TEST_CASE( "DNSName escaping", "[escapes]" ) {
DNSName test({"powerdns", "com."});
ostringstream str;
str<<test;
REQUIRE(str.str() == "powerdns.com\\..");
str=ostringstream();
const char zero[]="p\x0werdns";
DNSName test2({std::string(zero, sizeof(zero)-1), "com"});
str<<test2;
REQUIRE(str.str() == "p\\000werdns.com.");
};