resolved: tests for dns_resource_record_equal(); CNAME records

This commit is contained in:
James Coglan
2024-07-23 12:44:35 +01:00
committed by Luca Boccassi
parent 3f4a63c6d3
commit 55b18acf51
+30
View File
@@ -973,4 +973,34 @@ TEST(dns_resource_record_equal_ns_fail) {
ASSERT_FALSE(dns_resource_record_equal(a, b));
}
/* ================================================================
* dns_resource_record_equal() : CNAME
* ================================================================ */
TEST(dns_resource_record_equal_cname_copy) {
_cleanup_(dns_resource_record_unrefp) DnsResourceRecord *a = NULL, *b = NULL;
a = dns_resource_record_new_full(DNS_CLASS_IN, DNS_TYPE_CNAME, "www.example.com");
ASSERT_NOT_NULL(a);
a->cname.name = strdup("example.com");
b = dns_resource_record_copy(a);
ASSERT_NOT_NULL(b);
ASSERT_TRUE(dns_resource_record_equal(a, b));
}
TEST(dns_resource_record_equal_cname_fail) {
_cleanup_(dns_resource_record_unrefp) DnsResourceRecord *a = NULL, *b = NULL;
a = dns_resource_record_new_full(DNS_CLASS_IN, DNS_TYPE_CNAME, "www.example.com");
ASSERT_NOT_NULL(a);
a->cname.name = strdup("example.com");
b = dns_resource_record_copy(a);
ASSERT_NOT_NULL(b);
free(b->cname.name);
b->cname.name = strdup("example.orb");
ASSERT_FALSE(dns_resource_record_equal(a, b));
}
DEFINE_TEST_MAIN(LOG_DEBUG);