diff options
author | Jonas Gunz <himself@jonasgunz.de> | 2021-09-21 21:37:49 +0200 |
---|---|---|
committer | Jonas Gunz <himself@jonasgunz.de> | 2021-09-21 21:37:49 +0200 |
commit | 4127daa65ed8962900b386e138577a83bbc6baa5 (patch) | |
tree | a923ad42e411d94ac31a20d149dacd86ae648c31 /tests | |
parent | a0ff652261af4bebad0419aaf99ccea64c7ccf2e (diff) | |
download | dns-4127daa65ed8962900b386e138577a83bbc6baa5.tar.gz |
test: database
Diffstat (limited to 'tests')
-rw-r--r-- | tests/database.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/database.c b/tests/database.c index 18c7ec4..c1bd9ed 100644 --- a/tests/database.c +++ b/tests/database.c @@ -8,6 +8,7 @@ #include "../src/database.h" #include "../src/zonefile.h" +#include <check.h> START_TEST ( test_database_parse_zonefile ) { int ret; @@ -32,11 +33,31 @@ START_TEST ( test_database_parse_zonefile ) { ck_assert_ptr_null( db.zone ); } END_TEST +START_TEST (test_database_error_handling) { + database_t db; + database_rdata_t rdata; + database_init(&db); + + ck_assert_int_ne(database_init(NULL), 0); + ck_assert_int_ne(database_destroy(NULL), 0); + ck_assert_int_ne(database_query(NULL, NULL, NULL, 0, 0, 0), 0); + + /* Record not found */ + ck_assert_int_ne(database_query(&rdata, &db, "aa", 3, 1, 1), 0); + + /* Invalid record */ + ck_assert_int_ne(database_query(&rdata, &db, "aa", 3, 1, 777), 0); + ck_assert_int_ne(database_query(&rdata, &db, "aa", 3, 777, 1), 0); + + database_destroy(&db); +} END_TEST + TCase* test_database(void) { TCase *tc = tcase_create("Database"); tcase_add_test(tc, test_database_parse_zonefile); + tcase_add_test(tc, test_database_error_handling); return tc; } |