From: Michał Kępień Date: Thu, 26 Nov 2020 12:10:40 +0000 (+0100) Subject: Use proper cmocka macros for pointer checks X-Git-Tag: v9.17.8~24^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f44060012685213e4deedc1bce8be3868edd6af1;p=thirdparty%2Fbind9.git Use proper cmocka macros for pointer checks Make sure pointer checks in unit tests use cmocka assertion macros dedicated for use with pointers instead of those dedicated for use with integers or booleans. --- diff --git a/lib/dns/tests/dispatch_test.c b/lib/dns/tests/dispatch_test.c index 9770195da27..b8cc954c88b 100644 --- a/lib/dns/tests/dispatch_test.c +++ b/lib/dns/tests/dispatch_test.c @@ -132,10 +132,10 @@ dispatchset_get(void **state) { d4 = dns_dispatchset_get(dset); d5 = dns_dispatchset_get(dset); - assert_int_equal(d1, d2); - assert_int_equal(d2, d3); - assert_int_equal(d3, d4); - assert_int_equal(d4, d5); + assert_ptr_equal(d1, d2); + assert_ptr_equal(d2, d3); + assert_ptr_equal(d3, d4); + assert_ptr_equal(d4, d5); reset(); @@ -148,11 +148,11 @@ dispatchset_get(void **state) { d4 = dns_dispatchset_get(dset); d5 = dns_dispatchset_get(dset); - assert_int_equal(d1, d5); - assert_true(d1 != d2); - assert_true(d2 != d3); - assert_true(d3 != d4); - assert_true(d4 != d5); + assert_ptr_equal(d1, d5); + assert_ptr_not_equal(d1, d2); + assert_ptr_not_equal(d2, d3); + assert_ptr_not_equal(d3, d4); + assert_ptr_not_equal(d4, d5); reset(); } diff --git a/lib/dns/tests/keytable_test.c b/lib/dns/tests/keytable_test.c index a4dbee85730..e6a96350bdc 100644 --- a/lib/dns/tests/keytable_test.c +++ b/lib/dns/tests/keytable_test.c @@ -355,7 +355,7 @@ add_test(void **state) { assert_int_equal( dns_keytable_find(keytable, str2name("null.example"), &keynode), ISC_R_SUCCESS); - assert_int_equal(keynode, null_keynode); /* should be the same node */ + assert_ptr_equal(keynode, null_keynode); /* should be the same node */ dns_keytable_detachkeynode(keytable, &null_keynode); /* @@ -370,7 +370,7 @@ add_test(void **state) { assert_int_equal(dns_keytable_find(keytable, str2name("null.example"), &null_keynode), ISC_R_SUCCESS); - assert_int_equal(keynode, null_keynode); + assert_ptr_equal(keynode, null_keynode); dns_keytable_detachkeynode(keytable, &null_keynode); dns_keytable_detachkeynode(keytable, &keynode); diff --git a/lib/dns/tests/name_test.c b/lib/dns/tests/name_test.c index 8e7f86f3924..161d2c4504a 100644 --- a/lib/dns/tests/name_test.c +++ b/lib/dns/tests/name_test.c @@ -352,7 +352,7 @@ init_test(void **state) { assert_int_equal(name.length, 0); assert_int_equal(name.labels, 0); assert_int_equal(name.attributes, 0); - assert_int_equal(name.offsets, offsets); + assert_ptr_equal(name.offsets, offsets); assert_null(name.buffer); } @@ -387,7 +387,7 @@ buffer_test(void **state) { isc_buffer_init(&b, buf, BUFSIZ); dns_name_init(&name, NULL); dns_name_setbuffer(&name, &b); - assert_int_equal(name.buffer, &b); + assert_ptr_equal(name.buffer, &b); assert_true(dns_name_hasbuffer(&name)); } diff --git a/lib/dns/tests/tsig_test.c b/lib/dns/tests/tsig_test.c index e5bae9864b6..897f0f741fe 100644 --- a/lib/dns/tests/tsig_test.c +++ b/lib/dns/tests/tsig_test.c @@ -532,7 +532,7 @@ test_name(const char *name_string, const dns_name_t *expected) { dns_name_init(&name, NULL); assert_int_equal(dns_name_fromstring(&name, name_string, 0, dt_mctx), ISC_R_SUCCESS); - assert_int_equal(dns__tsig_algnamefromname(&name), expected); + assert_ptr_equal(dns__tsig_algnamefromname(&name), expected); dns_name_free(&name, dt_mctx); } @@ -552,7 +552,7 @@ algnamefromname_test(void **state) { test_name("gss.microsoft.com", DNS_TSIG_GSSAPIMS_NAME); /* try another name that isn't a standard algorithm name */ - assert_int_equal(dns__tsig_algnamefromname(dns_rootname), NULL); + assert_null(dns__tsig_algnamefromname(dns_rootname)); } /* Tests the dns__tsig_algallocated function */ diff --git a/lib/isc/tests/heap_test.c b/lib/isc/tests/heap_test.c index b60aba28612..2ac3a546c2f 100644 --- a/lib/isc/tests/heap_test.c +++ b/lib/isc/tests/heap_test.c @@ -91,7 +91,7 @@ isc_heap_delete_test(void **state) { assert_int_equal(e1.index, 0); isc_heap_destroy(&heap); - assert_int_equal(heap, NULL); + assert_null(heap); } int diff --git a/lib/isc/tests/radix_test.c b/lib/isc/tests/radix_test.c index 8f273410967..2149ae17155 100644 --- a/lib/isc/tests/radix_test.c +++ b/lib/isc/tests/radix_test.c @@ -92,7 +92,7 @@ isc_radix_search_test(void **state) { node = NULL; result = isc_radix_search(radix, &node, &prefix); assert_int_equal(result, ISC_R_SUCCESS); - assert_int_equal(node->data[0], (void *)2); + assert_ptr_equal(node->data[0], (void *)2); isc_refcount_destroy(&prefix.refcount);