aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;
}