Skip to content
Snippets Groups Projects
Commit dc35e304 authored by Marek Vavruša's avatar Marek Vavruša
Browse files

tests: added parameter checks for zonecut

parent c7d62055
No related branches found
No related tags found
No related merge requests found
......@@ -15,6 +15,7 @@
*.6
*.log
*.inc
*.mdb
.dirstamp
.libs
.deps
......@@ -46,3 +47,4 @@ tmp*
/tests/test_pack
/tests/test_set
/tests/test_utils
/tests/test_zonecut
......@@ -65,7 +65,7 @@ static void update_cut_name(struct kr_zonecut *cut, const knot_dname_t *name)
int kr_zonecut_init(struct kr_zonecut *cut, const knot_dname_t *name, mm_ctx_t *pool)
{
if (cut == NULL) {
if (cut == NULL || name == NULL) {
return kr_error(EINVAL);
}
......@@ -98,7 +98,7 @@ void kr_zonecut_deinit(struct kr_zonecut *cut)
void kr_zonecut_set(struct kr_zonecut *cut, const knot_dname_t *name)
{
if (cut == NULL) {
if (cut == NULL || name == NULL) {
return;
}
kr_zonecut_deinit(cut);
......
/* Copyright (C) 2014 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "tests/test.h"
#include "lib/zonecut.h"
static void test_zonecut_params(void **state)
{
/* NULL args */
struct kr_zonecut cut;
assert_int_not_equal(kr_zonecut_init(NULL, NULL, NULL), 0);
assert_int_not_equal(kr_zonecut_init(&cut, NULL, NULL), 0);
kr_zonecut_deinit(NULL);
kr_zonecut_set(NULL, NULL);
kr_zonecut_set(&cut, NULL);
assert_int_not_equal(kr_zonecut_add(NULL, NULL, NULL), 0);
assert_null(kr_zonecut_find(NULL, NULL));
assert_null(kr_zonecut_find(&cut, NULL));
assert_int_not_equal(kr_zonecut_set_sbelt(NULL), 0);
assert_int_not_equal(kr_zonecut_find_cached(NULL, NULL, 0), 0);
}
int main(void)
{
const UnitTest tests[] = {
unit_test(test_zonecut_params)
};
return run_tests(tests);
}
......@@ -9,8 +9,9 @@ tests_BIN := \
test_pack \
test_utils \
test_module \
test_rplan \
test_cache \
test_zonecut \
test_rplan \
test_resolve
mock_cmodule_SOURCES := tests/mock_cmodule.c
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment