12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- #include <check.h>
- #include <stdio.h>
- #include <libgen.h>
-
- #include "ttail_check.h"
- #include "ttail.h"
- #include "ttail_init.h"
- #include "ttail_search.h"
-
- /*
- * _ttail_file_next_line() & _ttail_file_line_start() tests
- */
- START_TEST (test_file_line_next)
- {
- long res;
- res = _ttail_file_next_line(ttail, 0);
- ck_assert(res == 77);
- res = _ttail_file_next_line(ttail, 0);
- ck_assert(res == 136);
- res = _ttail_file_next_line(ttail, 0);
- ck_assert(res == 221);
- res = _ttail_file_next_line(ttail, 0);
- ck_assert(res == 298);
- res = _ttail_file_next_line(ttail, 0);
- ck_assert(res == 357);
- res = _ttail_file_next_line(ttail, 0);
- ck_assert(res == 0);
- res = _ttail_file_next_line(ttail, 0);
- ck_assert(res == -1);
- }
- END_TEST
-
- START_TEST (test_file_line_start)
- {
- long res;
- fseek(ttail->logfile[0], -1, SEEK_END);
- res = _ttail_file_start_line(ttail, 0);
- ck_assert(res == 357);
- res = _ttail_file_start_line(ttail, 0);
- ck_assert(res == 357);
- fseek(ttail->logfile[0], -1, SEEK_CUR);
- res = _ttail_file_start_line(ttail, 0);
- ck_assert(res == 298);
- fseek(ttail->logfile[0], -1, SEEK_CUR);
- res = _ttail_file_start_line(ttail, 0);
- ck_assert(res == 221);
- fseek(ttail->logfile[0], -1, SEEK_CUR);
- res = _ttail_file_start_line(ttail, 0);
- ck_assert(res == 136);
- fseek(ttail->logfile[0], -1, SEEK_CUR);
- res = _ttail_file_start_line(ttail, 0);
- ck_assert(res == 77);
- fseek(ttail->logfile[0], -1, SEEK_CUR);
- res = _ttail_file_start_line(ttail, 0);
- ck_assert(res == 0);
- }
- END_TEST
-
- TTAIL_CHECK_START("ttail search_files checks", "ttail_file_*line*() checks")
- TTAIL_SET_FIXTURE(setup_file_line, teardown_ttail);
- TTAIL_ADD_TEST(test_file_line_next);
- TTAIL_ADD_TEST(test_file_line_start);
- TTAIL_CHECK_END
|