Browse Source

Bugfix + tests

Yann Weber 7 years ago
parent
commit
92d5f72ddc
2 changed files with 7 additions and 3 deletions
  1. 1
    1
      src/ttail_search_files.c
  2. 6
    2
      tests/ttail_search_check.c

+ 1
- 1
src/ttail_search_files.c View File

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

+ 6
- 2
tests/ttail_search_check.c View File

@@ -125,18 +125,22 @@ START_TEST (test_file_line_start)
125 125
 	long res;
126 126
 	fseek(fpl, -1, SEEK_END);
127 127
 	res = _ttail_file_start_line(fpl);
128
-	printf("%ld\n", res);
128
+	ck_assert(res == 357);
129
+	res = _ttail_file_start_line(fpl);
129 130
 	ck_assert(res == 357);
130 131
 	fseek(fpl, -1, SEEK_CUR);
131 132
 	res = _ttail_file_start_line(fpl);
132
-	printf("%ld\n", res);
133 133
 	ck_assert(res == 298);
134
+	fseek(fpl, -1, SEEK_CUR);
134 135
 	res = _ttail_file_start_line(fpl);
135 136
 	ck_assert(res == 221);
137
+	fseek(fpl, -1, SEEK_CUR);
136 138
 	res = _ttail_file_start_line(fpl);
137 139
 	ck_assert(res == 136);
140
+	fseek(fpl, -1, SEEK_CUR);
138 141
 	res = _ttail_file_start_line(fpl);
139 142
 	ck_assert(res == 77);
143
+	fseek(fpl, -1, SEEK_CUR);
140 144
 	res = _ttail_file_start_line(fpl);
141 145
 	ck_assert(res == 0);
142 146
 }

Loading…
Cancel
Save