#include #include #include #include #include "ttail_check.h" #include "ttail.h" #include "ttail_init.h" /* * ttail_set_prefix() tests */ START_TEST (test_init_prefix) { int ret; ret = ttail_set_prefix(ttail, "^[^ ]+ "); ck_assert_int_eq(ret, 0); ck_assert((ttail->flag & TTAIL_FLAG_PREFIX) == TTAIL_FLAG_PREFIX); } END_TEST START_TEST (test_init_bad_prefix) { int ret; ret = ttail_set_prefix(ttail, "^[^ + "); ck_assert_int_eq(ret, -1); ck_assert((ttail->flag & TTAIL_FLAG_PREFIX) == 0); } END_TEST START_TEST (test_init_again_prefix) { int ret; ret = ttail_set_prefix(ttail, "^[^ ]+ "); ck_assert_int_eq(ret, 0); ck_assert((ttail->flag & TTAIL_FLAG_PREFIX) == TTAIL_FLAG_PREFIX); ret = ttail_set_prefix(ttail, "^[^ + "); ck_assert_int_eq(ret, 1); ck_assert((ttail->flag & TTAIL_FLAG_PREFIX) == TTAIL_FLAG_PREFIX); } END_TEST START_TEST (test_init_againbad_prefix) { int ret; ret = ttail_set_prefix(ttail, "^[^ + "); ck_assert_int_eq(ret, -1); ck_assert((ttail->flag & TTAIL_FLAG_PREFIX) == 0); ret = ttail_set_prefix(ttail, "^[^ ]+ "); ck_assert_int_eq(ret, 0); ck_assert((ttail->flag & TTAIL_FLAG_PREFIX) == TTAIL_FLAG_PREFIX); } END_TEST TTAIL_CHECK_START("ttail init checks", "date prefix regex init checks") TTAIL_SET_FIXTURE(setup_ttail_empty, teardown_ttail); TTAIL_ADD_TEST(test_init_prefix); TTAIL_ADD_TEST(test_init_bad_prefix); TTAIL_ADD_TEST(test_init_again_prefix); TTAIL_ADD_TEST(test_init_againbad_prefix); TTAIL_CHECK_END