1
0
mirror of https://gitlab.xiph.org/xiph/icecast-common.git synced 2024-12-04 14:46:31 -05:00

Update: Added tests for filters

This commit is contained in:
Philipp Schafft 2019-07-14 17:51:25 +00:00
parent 30280610ac
commit 5cd72c093c

View File

@ -15,6 +15,7 @@
#include "ctest_lib.h"
#include <igloo/logmsg.h>
#include <igloo/filter.h>
static void test_create_unref(void)
{
@ -88,6 +89,33 @@ static void test_logmsg(void)
ctest_test("un-referenced", igloo_ro_unref(msg) == 0);
}
static void test_filter(void)
{
igloo_filter_t *filter;
igloo_logmsg_t *msg;
igloo_ro_base_t *base;
filter = igloo_logmsg_filter(igloo_LOGLEVEL_ERROR, igloo_LOGLEVEL_WARN, igloo_LOGMSG_OPT_NONE, igloo_LOGMSG_OPT_NONE, NULL, NULL, NULL, NULL, igloo_RO_NULL);
ctest_test("filter created", !igloo_RO_IS_NULL(filter));
base = igloo_ro_new(igloo_ro_base_t);
ctest_test("base created", base != NULL);
ctest_test("droping base", igloo_filter_test(filter, base) == igloo_FILTER_RESULT_DROP);
ctest_test("base un-referenced", igloo_ro_unref(base) == 0);
msg = igloo_logmsg_new(NULL, igloo_RO_NULL, NULL, NULL, NULL, NULL, -1, NULL, igloo_LOGLEVEL_INFO, igloo_LOGMSG_OPT_NONE, NULL, "test");
ctest_test("logmsg created", !igloo_RO_IS_NULL(msg));
ctest_test("droping logmsg", igloo_filter_test(filter, msg) == igloo_FILTER_RESULT_DROP);
ctest_test("un-referenced", igloo_ro_unref(msg) == 0);
msg = igloo_logmsg_new(NULL, igloo_RO_NULL, NULL, NULL, NULL, NULL, -1, NULL, igloo_LOGLEVEL_WARN, igloo_LOGMSG_OPT_NONE, NULL, "test");
ctest_test("logmsg created", !igloo_RO_IS_NULL(msg));
ctest_test("passing logmsg", igloo_filter_test(filter, msg) == igloo_FILTER_RESULT_PASS);
ctest_test("un-referenced", igloo_ro_unref(msg) == 0);
ctest_test("un-referenced", igloo_ro_unref(filter) == 0);
}
int main (void)
{
ctest_init();
@ -95,6 +123,7 @@ int main (void)
test_create_unref();
test_logmsg();
test_filter();
ctest_fin();