improve tests
This commit is contained in:
@ -84,7 +84,10 @@ struct DNSName
|
||||
auto size() { return d_name.size(); }
|
||||
void clear() { d_name.clear(); }
|
||||
bool makeRelative(const DNSName& root);
|
||||
|
||||
bool operator==(const DNSName& rhs) const
|
||||
{
|
||||
return std::lexicographical_compare(begin(), end(), rhs.begin(), rhs.end())==0;
|
||||
}
|
||||
std::deque<DNSLabel> d_name;
|
||||
};
|
||||
|
||||
|
@ -28,3 +28,15 @@ TEST_CASE( "DNSName escaping", "[escapes]" ) {
|
||||
str<<test2;
|
||||
REQUIRE(str.str() == "p\\000werdns.com.");
|
||||
};
|
||||
|
||||
TEST_CASE("DNSName operations", "[dnsname]") {
|
||||
DNSName test({"www", "powerdns", "org"}), test2;
|
||||
test2 = test;
|
||||
|
||||
REQUIRE(test2 == test);
|
||||
test.pop_back();
|
||||
REQUIRE(test == DNSName({"www", "powerdns"}));
|
||||
|
||||
REQUIRE(test2.makeRelative({"org"}));
|
||||
REQUIRE(test2 == DNSName({"www", "powerdns"}));
|
||||
}
|
||||
|
Reference in New Issue
Block a user