]> granicus.if.org Git - pdns/commitdiff
Add a test for DNSName::getLastLabel()
authorPieter Lexis <pieter.lexis@powerdns.com>
Fri, 7 Apr 2017 10:48:57 +0000 (12:48 +0200)
committerPieter Lexis <pieter.lexis@powerdns.com>
Fri, 7 Apr 2017 10:49:06 +0000 (12:49 +0200)
pdns/test-dnsname_cc.cc

index bb829614e91660c7cf0886e22212199a3c2f2134..771bfb84bd448a320a5f8cb425ed5e1394bbd8e6 100644 (file)
@@ -858,4 +858,14 @@ BOOST_AUTO_TEST_CASE(test_getrawlabel) {
   BOOST_CHECK_THROW(name.getRawLabel(name.countLabels()), std::out_of_range);
 }
 
+BOOST_AUTO_TEST_CASE(test_getlastlabel) {
+  DNSName name("www.powerdns.com");
+  DNSName ans = name.getLastLabel();
+
+  // Check the const-ness
+  BOOST_CHECK_EQUAL(name, DNSName("www.powerdns.com"));
+
+  // Check if the last label is indeed returned
+  BOOST_CHECK_EQUAL(ans, DNSName("com"));
+}
 BOOST_AUTO_TEST_SUITE_END()