Commit f2f77119 authored by Mark Andrews's avatar Mark Andrews
Browse files

add unit tests for dns_rdatatype_atcname, dns_rdatatype_atparent and iszonecutauth

parent 7e4b8210
......@@ -27,6 +27,7 @@
#include <isc/hex.h>
#include <isc/lex.h>
#include <isc/print.h>
#include <isc/stdio.h>
#include <isc/types.h>
#include <isc/util.h>
......@@ -1499,6 +1500,90 @@ wks(void **state) {
dns_rdatatype_wks, sizeof(dns_rdata_in_wks_t));
}
static void
atcname(void **state) {
unsigned int i;
UNUSED(state);
#define UNR "# Unexpected result from dns_rdatatype_atcname for type %u\n"
for (i = 0; i < 0xffffU; i++) {
bool tf = dns_rdatatype_atcname((dns_rdatatype_t)i);
switch (i) {
case dns_rdatatype_nsec:
case dns_rdatatype_key:
case dns_rdatatype_rrsig:
if (!tf) {
print_message(UNR, i);
}
assert_true(tf);
break;
default:
if (tf) {
print_message(UNR, i);
}
assert_false(tf);
break;
}
}
#undef UNR
}
static void
atparent(void **state) {
unsigned int i;
UNUSED(state);
#define UNR "# Unexpected result from dns_rdatatype_atparent for type %u\n"
for (i = 0; i < 0xffffU; i++) {
bool tf = dns_rdatatype_atparent((dns_rdatatype_t)i);
switch (i) {
case dns_rdatatype_ds:
if (!tf) {
print_message(UNR, i);
}
assert_true(tf);
break;
default:
if (tf) {
print_message(UNR, i);
}
assert_false(tf);
break;
}
}
#undef UNR
}
static void
iszonecutauth(void **state) {
unsigned int i;
UNUSED(state);
#define UNR "# Unexpected result from dns_rdatatype_iszonecutauth for type %u\n"
for (i = 0; i < 0xffffU; i++) {
bool tf = dns_rdatatype_iszonecutauth((dns_rdatatype_t)i);
switch (i) {
case dns_rdatatype_ns:
case dns_rdatatype_ds:
case dns_rdatatype_nsec:
case dns_rdatatype_key:
case dns_rdatatype_rrsig:
if (!tf) {
print_message(UNR, i);
}
assert_true(tf);
break;
default:
if (tf) {
print_message(UNR, i);
}
assert_false(tf);
break;
}
}
#undef UNR
}
int
main(void) {
const struct CMUnitTest tests[] = {
......@@ -1516,6 +1601,9 @@ main(void) {
cmocka_unit_test_setup_teardown(nsec3, _setup, _teardown),
cmocka_unit_test_setup_teardown(nxt, _setup, _teardown),
cmocka_unit_test_setup_teardown(wks, _setup, _teardown),
cmocka_unit_test_setup_teardown(atcname, NULL, NULL),
cmocka_unit_test_setup_teardown(atparent, NULL, NULL),
cmocka_unit_test_setup_teardown(iszonecutauth, NULL, NULL),
};
return (cmocka_run_group_tests(tests, NULL, NULL));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment