aboutsummaryrefslogtreecommitdiff
path: root/tests/record.c
diff options
context:
space:
mode:
authorGravatar Jonas Gunz <himself@jonasgunz.de> 2021-09-21 17:09:50 +0200
committerGravatar Jonas Gunz <himself@jonasgunz.de> 2021-09-21 17:09:50 +0200
commit75395c048e6c66b8df768c2cafb5e7d980412787 (patch)
tree2bc0f76c6026d063b2cf2e1a89b14a4deac39256 /tests/record.c
parent08c48ad70641ffff389288dcaaa08aad8851cc1a (diff)
downloaddns-75395c048e6c66b8df768c2cafb5e7d980412787.tar.gz
test: record.c
Diffstat (limited to 'tests/record.c')
-rw-r--r--tests/record.c31
1 files changed, 28 insertions, 3 deletions
diff --git a/tests/record.c b/tests/record.c
index 896c04e..b6c962d 100644
--- a/tests/record.c
+++ b/tests/record.c
@@ -8,6 +8,18 @@
#include "../src/record.h"
+static char* types[] = {
+ "A",
+ "NS",
+ "TXT"
+};
+static char* data[] = {
+ "1.2.3.4",
+ "ns.example.com.",
+ "Lorem Ipsum"
+};
+static size_t record_cnt = sizeof(types) / sizeof(char*);
+
START_TEST (test_records_from_string) {
ck_assert_int_eq(record_class_from_str("IN"), 1);
ck_assert_int_eq(record_class_from_str("hs"), 4);
@@ -18,7 +30,7 @@ START_TEST (test_records_from_string) {
ck_assert_int_eq(record_type_from_str("invalid"), 0);
} END_TEST
-START_TEST (test_records_handler) {
+START_TEST (test_records_handler_a) {
void* rdata = NULL;
ssize_t len;
@@ -26,14 +38,27 @@ START_TEST (test_records_handler) {
ck_assert_int_eq(len,4);
ck_assert_uint_eq(*((uint32_t*)rdata),0x44454545);
+ len = record_rdata_from_str(&rdata, "", record_type_from_str("MD"));
+ ck_assert_int_lt(len,-0);
+
free(rdata);
-}
+} END_TEST
+
+START_TEST (test_records_handlers) {
+ void* rdata = NULL;
+ ssize_t len;
+
+ len = record_rdata_from_str(&rdata, data[_i], record_type_from_str(types[_i]));
+ ck_assert_int_gt(len, 0);
+ free(rdata);
+} END_TEST
TCase* test_record(void) {
TCase *tc = tcase_create("record");
tcase_add_test(tc, test_records_from_string);
- tcase_add_test(tc, test_records_handler);
+ tcase_add_test(tc, test_records_handler_a);
+ tcase_add_loop_test(tc, test_records_handlers, 0, record_cnt);
return tc;
}