mirror of
https://github.com/isc-projects/bind9.git
synced 2026-05-28 04:34:54 -04:00
Add more unit tests for dns_qp unit
Add basic unit tests and add missing DbC checks for mandatory dns_qp_create() arguments.
This commit is contained in:
parent
9e2d5d94bd
commit
cdc6950d04
2 changed files with 38 additions and 0 deletions
|
|
@ -1494,6 +1494,8 @@ dns_qpsnap_destroy(dns_qpmulti_t *multi, dns_qpsnap_t **qpsp) {
|
|||
void
|
||||
dns_qp_create(isc_mem_t *mctx, const dns_qpmethods_t *methods, void *uctx,
|
||||
dns_qp_t **qptp) {
|
||||
REQUIRE(mctx != NULL);
|
||||
REQUIRE(methods != NULL);
|
||||
REQUIRE(qptp != NULL && *qptp == NULL);
|
||||
|
||||
dns_qp_t *qp = isc_mem_get(mctx, sizeof(*qp));
|
||||
|
|
|
|||
|
|
@ -40,6 +40,10 @@
|
|||
#include <tests/dns.h>
|
||||
#include <tests/qp.h>
|
||||
|
||||
#define DONT_REORDER
|
||||
|
||||
#include "../qp.c"
|
||||
|
||||
bool verbose = false;
|
||||
|
||||
ISC_RUN_TEST_IMPL(qpkey_name) {
|
||||
|
|
@ -2059,7 +2063,39 @@ ISC_RUN_TEST_IMPL(qpkey_delete) {
|
|||
dns_qp_destroy(&qp);
|
||||
}
|
||||
|
||||
ISC_RUN_TEST_IMPL(qp_basics) {
|
||||
dns_qp_t *qp = NULL;
|
||||
expect_assert_failure(
|
||||
dns_qp_create(isc_g_mctx, &string_methods, NULL, NULL));
|
||||
expect_assert_failure(dns_qp_create(NULL, &string_methods, NULL, &qp));
|
||||
expect_assert_failure(dns_qp_create(isc_g_mctx, NULL, NULL, &qp));
|
||||
|
||||
qp = NULL;
|
||||
dns_qp_create(isc_g_mctx, &string_methods, NULL, &qp);
|
||||
assert_non_null(qp);
|
||||
|
||||
dns_qp_destroy(&qp);
|
||||
assert_null(qp);
|
||||
}
|
||||
|
||||
ISC_RUN_TEST_IMPL(qp_memusage) {
|
||||
dns_qp_t *qp = NULL;
|
||||
dns_qp_memusage_t mu;
|
||||
|
||||
dns_qp_create(isc_g_mctx, &string_methods, NULL, &qp);
|
||||
assert_non_null(qp);
|
||||
|
||||
mu = dns_qp_memusage(qp);
|
||||
assert_int_equal(mu.leaves, 0);
|
||||
assert_int_equal(mu.used, 0);
|
||||
|
||||
dns_qp_destroy(&qp);
|
||||
assert_null(qp);
|
||||
}
|
||||
|
||||
ISC_TEST_LIST_START
|
||||
ISC_TEST_ENTRY(qp_basics)
|
||||
ISC_TEST_ENTRY(qp_memusage)
|
||||
ISC_TEST_ENTRY(qpkey_name)
|
||||
ISC_TEST_ENTRY(qpkey_sort)
|
||||
ISC_TEST_ENTRY(qpiter)
|
||||
|
|
|
|||
Loading…
Reference in a new issue