aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorGravatar Jonas Gunz <himself@jonasgunz.de> 2021-09-21 22:29:46 +0200
committerGravatar Jonas Gunz <himself@jonasgunz.de> 2021-09-21 22:29:46 +0200
commitd3a71850e2731613db64ff3c5ab72f2cc921ffd2 (patch)
treec4c7033dd25f12ebc302154296bddcf727ca5196 /tests
parent8360724ed8591c995aafc43095b286ba2ee1d025 (diff)
downloaddns-d3a71850e2731613db64ff3c5ab72f2cc921ffd2.tar.gz
tests: tree, dns increase coverage
Diffstat (limited to 'tests')
-rw-r--r--tests/dns.c14
-rw-r--r--tests/tree.c3
2 files changed, 17 insertions, 0 deletions
diff --git a/tests/dns.c b/tests/dns.c
index 84346df..ff7c389 100644
--- a/tests/dns.c
+++ b/tests/dns.c
@@ -7,6 +7,7 @@
#include "tests.h"
#include "../src/dns.h"
+#include <check.h>
START_TEST (dns_qname) {
char in[128];
@@ -75,12 +76,25 @@ START_TEST (dns_message_fuzz) {
ck_assert_float_le( (float)valid_cnt / (float)limit * 100, 10);
} END_TEST
+START_TEST (dns_error_handling) {
+ char qname[32];
+ char fqdn[32];
+
+ strncpy(fqdn, "test.example.com", 32);
+
+ ck_assert_int_lt( fqdn_to_qname(fqdn, 32, qname, 5), 0 );
+
+ fqdn_to_qname(fqdn, 32, qname, 32);
+ ck_assert_int_lt( qname_to_fqdn(qname, 32, fqdn, 5), 0 );
+} END_TEST
+
TCase* test_dns(void) {
TCase *tc = tcase_create("DNS");
tcase_add_test(tc, dns_qname);
tcase_add_test(tc, dns_qname_fuzz);
tcase_add_test(tc, dns_message_fuzz);
+ tcase_add_test(tc, dns_error_handling);
return tc;
}
diff --git a/tests/tree.c b/tests/tree.c
index ccfb3fe..20f5ee2 100644
--- a/tests/tree.c
+++ b/tests/tree.c
@@ -39,6 +39,9 @@ START_TEST(tree_basic) {
ck_assert_int_eq(tree_balanced_insert( &root, (void**)data, keys, len ),0);
+ /* Check double insertion protection */
+ ck_assert_int_ne( tree_insert( &root, keys[0], (void*)data[0] ), 0 );
+
for ( i = 0; i < len; i++ ) {
ck_assert_str_eq( tree_get(&root, keys[i]), data[i] );
}