12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- #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(fpl);
- ck_assert(res == 77);
- res = _ttail_file_next_line(fpl);
- ck_assert(res == 136);
- res = _ttail_file_next_line(fpl);
- ck_assert(res == 221);
- res = _ttail_file_next_line(fpl);
- ck_assert(res == 298);
- res = _ttail_file_next_line(fpl);
- ck_assert(res == 357);
- res = _ttail_file_next_line(fpl);
- ck_assert(res == 0);
- res = _ttail_file_next_line(fpl);
- ck_assert(res == -1);
- }
- END_TEST
-
- START_TEST (test_file_line_start)
- {
- long res;
- fseek(fpl, -1, SEEK_END);
- res = _ttail_file_start_line(fpl);
- ck_assert(res == 357);
- res = _ttail_file_start_line(fpl);
- ck_assert(res == 357);
- fseek(fpl, -1, SEEK_CUR);
- res = _ttail_file_start_line(fpl);
- ck_assert(res == 298);
- fseek(fpl, -1, SEEK_CUR);
- res = _ttail_file_start_line(fpl);
- ck_assert(res == 221);
- fseek(fpl, -1, SEEK_CUR);
- res = _ttail_file_start_line(fpl);
- ck_assert(res == 136);
- fseek(fpl, -1, SEEK_CUR);
- res = _ttail_file_start_line(fpl);
- ck_assert(res == 77);
- fseek(fpl, -1, SEEK_CUR);
- res = _ttail_file_start_line(fpl);
- ck_assert(res == 0);
- }
- END_TEST
-
- Suite * ttail_search_files_suite(void)
- {
- Suite *s;
- TCase *tc_file_line;
-
- s = suite_create("ttail search_files checks");
-
- tc_file_line = tcase_create("ttail_file_*line*() checks");
- tcase_add_checked_fixture(tc_file_line,
- setup_file_line, teardown_file_line);
- tcase_add_test(tc_file_line, test_file_line_next);
- tcase_add_test(tc_file_line, test_file_line_start);
-
- suite_add_tcase(s, tc_file_line);
- return s;
- }
-
- TTAIL_CHECK_MAIN(ttail_search_files_suite)
|