diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/main.c | 1 | ||||
-rw-r--r-- | tests/record.c | 39 | ||||
-rw-r--r-- | tests/tests.h | 1 | ||||
-rw-r--r-- | tests/zonefile.c | 2 |
4 files changed, 42 insertions, 1 deletions
diff --git a/tests/main.c b/tests/main.c index 8dbe07e..f1a9f7d 100644 --- a/tests/main.c +++ b/tests/main.c @@ -20,6 +20,7 @@ int main() { suite_add_tcase(s, test_dns()); suite_add_tcase(s, test_tree()); suite_add_tcase(s, test_zonefile()); + suite_add_tcase(s, test_record()); sr = srunner_create(s); srunner_run_all(sr,CK_VERBOSE); diff --git a/tests/record.c b/tests/record.c new file mode 100644 index 0000000..f5c638b --- /dev/null +++ b/tests/record.c @@ -0,0 +1,39 @@ +/* + * tests/record.c + * (c) 2021 Jonas Gunz <himself@jonasgunz.de> + * License: MIT + */ + +#include "tests.h" + +#include "../src/record.h" + +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); + ck_assert_int_eq(record_class_from_str("invalid"), 0); + + ck_assert_int_eq(record_type_from_str("A"), 1); + ck_assert_int_eq(record_type_from_str("txt"), 16); + ck_assert_int_eq(record_type_from_str("invalid"), 0); +} END_TEST + +START_TEST (test_records_handler) { + void* rdata = NULL; + ssize_t len; + + len = record_rdata_from_str(&rdata, "69.69.69.68", record_class_from_str("A")); + ck_assert_int_eq(len,4); + ck_assert_uint_eq(*((uint32_t*)rdata),0x45454544); + + free(rdata); +} + +TCase* test_record(void) { + TCase *tc = tcase_create("record"); + + tcase_add_test(tc, test_records_from_string); + tcase_add_test(tc, test_records_handler); + + return tc; +} diff --git a/tests/tests.h b/tests/tests.h index 96ae1d6..469e715 100644 --- a/tests/tests.h +++ b/tests/tests.h @@ -15,3 +15,4 @@ TCase* test_dns(void); TCase* test_tree(void); TCase* test_zonefile(void); +TCase* test_record(void); diff --git a/tests/zonefile.c b/tests/zonefile.c index b142f8e..9cc1c4f 100644 --- a/tests/zonefile.c +++ b/tests/zonefile.c @@ -35,7 +35,7 @@ START_TEST (test_zonefile_string_split) { } END_TEST TCase* test_zonefile(void) { - TCase *tc = tcase_create("DNS"); + TCase *tc = tcase_create("zonefile"); tcase_add_test(tc, test_zonefile_string_split); |