Bugfix + tests

This commit is contained in:
Yann Weber 2017-03-06 21:00:11 +01:00
commit 92d5f72ddc
2 changed files with 7 additions and 3 deletions

View file

@ -200,7 +200,7 @@ long _ttail_file_start_line(FILE* f)
}
last = -1; /* last pos we saw a '\n' */
cur = read_beg;
while(cur < start)
while(cur <= start)
{
c = getc(f);
if(c == EOF)

View file

@ -125,18 +125,22 @@ START_TEST (test_file_line_start)
long res;
fseek(fpl, -1, SEEK_END);
res = _ttail_file_start_line(fpl);
printf("%ld\n", res);
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);
printf("%ld\n", res);
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);
}