From 392dd81098f4673e4d30896a5ac9f151330c0f67 Mon Sep 17 00:00:00 2001 From: James Coglan Date: Wed, 12 Jun 2024 16:32:10 +0100 Subject: [PATCH] resolved: tests for dns_resource_record_equal(); PTR records --- src/resolve/test-dns-rr.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/resolve/test-dns-rr.c b/src/resolve/test-dns-rr.c index a113ef8dde4..1058c4fe3f2 100644 --- a/src/resolve/test-dns-rr.c +++ b/src/resolve/test-dns-rr.c @@ -1160,4 +1160,34 @@ TEST(dns_resource_record_equal_soa_bad_minimum) { ASSERT_FALSE(dns_resource_record_equal(a, b)); } +/* ================================================================ + * dns_resource_record_equal() : PTR + * ================================================================ */ + +TEST(dns_resource_record_equal_ptr_copy) { + _cleanup_(dns_resource_record_unrefp) DnsResourceRecord *a = NULL, *b = NULL; + + a = dns_resource_record_new_full(DNS_CLASS_IN, DNS_TYPE_PTR, "127.1.168.192.in-addr-arpa"); + ASSERT_NOT_NULL(a); + a->ptr.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_ptr_fail) { + _cleanup_(dns_resource_record_unrefp) DnsResourceRecord *a = NULL, *b = NULL; + + a = dns_resource_record_new_full(DNS_CLASS_IN, DNS_TYPE_PTR, "127.1.168.192.in-addr-arpa"); + ASSERT_NOT_NULL(a); + a->ptr.name = strdup("example.com"); + + b = dns_resource_record_copy(a); + ASSERT_NOT_NULL(b); + free(b->ptr.name); + b->ptr.name = strdup("example.org"); + ASSERT_FALSE(dns_resource_record_equal(a, b)); +} + DEFINE_TEST_MAIN(LOG_DEBUG); -- 2.47.3