Bugfix + tests
This commit is contained in:
parent
01c295d459
commit
92d5f72ddc
2 changed files with 7 additions and 3 deletions
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue