12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- #include <check.h>
- #include <errno.h>
- #include <stdio.h>
- #include <unistd.h>
-
- #include "ttail_check.h"
- #include "ttail.h"
- #include "ttail_init.h"
-
- START_TEST (test_argparse_reprefix_short)
- {
- ttail_t *t;
- char *args[] = {"foo", "-r", "^[^ ]+ "};
- t = ttail_init(3, args);
- ck_assert(t != NULL);
- ck_assert((t->flag & TTAIL_FLAG_PREFIX) == TTAIL_FLAG_PREFIX);
- }
- END_TEST
-
- START_TEST (test_argparse_reprefix_long)
- {
- ttail_t *t;
- char *args[] = {"foo", "--re-prefix", "^[^ ]+ "};
- t = ttail_init(3, args);
- ck_assert(t != NULL);
- ck_assert((t->flag & TTAIL_FLAG_PREFIX) == TTAIL_FLAG_PREFIX);
- }
- END_TEST
-
- START_TEST (test_argparse_prefixlen_short)
- {
- ttail_t *t;
- char *args[] = {"foo", "-p", "10"};
- t = ttail_init(3, args);
- ck_assert(t != NULL);
- ck_assert((t->flag & TTAIL_FLAG_PREFIX) == TTAIL_FLAG_PREFIX);
- ck_assert_int_eq(t->prefix_sz, 10);
- }
- END_TEST
-
- START_TEST (test_argparse_prefixlen_long)
- {
- ttail_t *t;
- char *args[] = {"foo", "--prefix-len", "42"};
- t = ttail_init(3, args);
- ck_assert(t != NULL);
- ck_assert((t->flag & TTAIL_FLAG_PREFIX) == TTAIL_FLAG_PREFIX);
- ck_assert_int_eq(t->prefix_sz, 42);
- }
- END_TEST
-
-
- START_TEST (test_argparse_prefix_multiple)
- {
- ttail_t *t;
- char *args[] = {"foo", "--re-prefix", "^[^ ]+ ", "-p", "20"};
- t = ttail_init(5, args);
- ck_assert(t == NULL);
- }
- END_TEST
-
- TTAIL_CHECK_START( "ttail argument parsing checks",\
- "re-prefix arguments parsing")
- TTAIL_ADD_TEST(test_argparse_reprefix_short);
- TTAIL_ADD_TEST(test_argparse_reprefix_long);
- TTAIL_ADD_TEST(test_argparse_prefixlen_short);
- TTAIL_ADD_TEST(test_argparse_prefixlen_long);
- TTAIL_ADD_TEST(test_argparse_prefix_multiple);
- TTAIL_CHECK_END
|