Browse Source

Tests update

Yann Weber 7 years ago
parent
commit
6ed34f4e0f
2 changed files with 28 additions and 22 deletions
  1. 13
    13
      tests/ttail_argparse_check.c
  2. 15
    9
      tests/ttail_search_check.c

+ 13
- 13
tests/ttail_argparse_check.c View File

@@ -190,15 +190,15 @@ void teardown_fname(void)
190 190
 START_TEST (test_argparse_file_non_exist)
191 191
 {
192 192
 	ttail_t *t;
193
-	char *args[3] = {"foo", "-l", NULL};
193
+	char *args[4] = {"foo", "-d", "Mar 6 13:37", NULL};
194 194
 
195
-	args[2] = fname[FNAME_NO_EXIST];
196
-	t = ttail_init(3, args);
195
+	args[3] = fname[FNAME_NO_EXIST];
196
+	t = ttail_init(4, args);
197 197
 	ck_assert_msg(t != NULL, "init failed");
198 198
 
199 199
 	ck_assert_msg(t->logfile_sz == 1,
200 200
 		"ttail_t.logfile_sz should be 1");
201
-	ck_assert_msg(strcmp(t->logfile_name[0], args[2]) == 0,
201
+	ck_assert_msg(strcmp(t->logfile_name[0], args[3]) == 0,
202 202
 		"ttail_t.logfile_name[0] does not contain the filename");
203 203
 	ck_assert_msg(t->logfile[0] == NULL,
204 204
 		"ttail_t.logfile[0] should be NULL");
@@ -211,16 +211,16 @@ END_TEST
211 211
 START_TEST (test_argparse_file_exist)
212 212
 {
213 213
 	ttail_t *t;
214
-	char *args[3] = {"foo", "-l", NULL};
214
+	char *args[4] = {"foo", "-d", "Mar 10 13:37", NULL};
215 215
 
216
-	args[2] = fname[FNAME_EXIST];
216
+	args[3] = fname[FNAME_EXIST];
217 217
 
218
-	t = ttail_init(3, args);
218
+	t = ttail_init(4, args);
219 219
 	ck_assert_msg(t != NULL, "init failed");
220 220
 
221 221
 	ck_assert_msg(t->logfile_sz == 1,
222 222
 		"ttail_t.logfile_sz should be 1");
223
-	ck_assert_msg(strcmp(t->logfile_name[0], args[2]) == 0,
223
+	ck_assert_msg(strcmp(t->logfile_name[0], args[3]) == 0,
224 224
 		"ttail_t.logfile_name[0] does not contain the filename");
225 225
 	ck_assert_msg(t->logfile[0] != NULL,
226 226
 		"ttail_t.logfile[0] shouldn't be NULL");
@@ -234,15 +234,15 @@ START_TEST (test_argparse_file_multiple)
234 234
 {
235 235
 	ttail_t *t;
236 236
 	int i;
237
-	char *args[11] = {"foo", "-l", NULL, "-l", NULL,
238
-		"-l", NULL, "-l", NULL, "-l", NULL};
237
+	char *args[8] = {"foo", "-d", "mar 10 13:37", NULL, NULL, NULL, NULL,
238
+		NULL};
239 239
 	
240 240
 	for(i=0; i<__Fname_sz; i++)
241 241
 	{
242
-		args[(i*2)+2] = fname[i];
242
+		args[i+3] = fname[i];
243 243
 	}
244 244
 
245
-	t = ttail_init(11, args);
245
+	t = ttail_init(8, args);
246 246
 	ck_assert_msg(t != NULL, "init failed");
247 247
 	
248 248
 	ck_assert_msg(t->logfile_sz == __Fname_sz,
@@ -250,7 +250,7 @@ START_TEST (test_argparse_file_multiple)
250 250
 
251 251
 	for(i=0;i<__Fname_sz; i++)
252 252
 	{
253
-		ck_assert_msg(strcmp(t->logfile_name[i], args[(i*2)+2]) == 0,
253
+		ck_assert_msg(strcmp(t->logfile_name[i], args[i+3]) == 0,
254 254
 			"some filename corrupted in ttail_t.logfile_name");
255 255
 		if(i%2)
256 256
 		{

+ 15
- 9
tests/ttail_search_check.c View File

@@ -319,11 +319,13 @@ START_TEST (test_search_files1)
319 319
 	ttail->flag |= TTAIL_FLAG_PREFIX;
320 320
 	ttail->prefix_sz = 0;
321 321
 	ttail_set_fmt(ttail, "%B%n%d %H:%M");
322
+	memcpy(&(ttail->date_min), &tm, sizeof(tm));
323
+	ttail->flag |= TTAIL_FLAG_DATE_MIN;
322 324
 
323
-	ret = _ttail_search_closest_files(ttail, &tm);
325
+	ret = _ttail_search_closest_files(ttail);
324 326
 	ck_assert_int_eq(ret, 0);
325
-	ck_assert(ttail->session->file.id == 0);
326
-	ck_assert(ttail->session->file.off == 0);
327
+	ck_assert(ttail->session->file.off_min.id == 0);
328
+	ck_assert(ttail->session->file.off_min.off == 0);
327 329
 }
328 330
 END_TEST
329 331
 
@@ -348,11 +350,13 @@ START_TEST (test_search_files2)
348 350
 	tm.tm_hour = 0;
349 351
 	tm.tm_min = 29;
350 352
 	tm.tm_sec = -1;
353
+	memcpy(&(ttail->date_min), &tm, sizeof(tm));
354
+	ttail->flag |= TTAIL_FLAG_DATE_MIN;
351 355
 	
352
-	ret = _ttail_search_closest_files(ttail, &tm);
356
+	ret = _ttail_search_closest_files(ttail);
353 357
 	ck_assert_int_eq(ret, 0);
354
-	ck_assert(ttail->session->file.id == 0);
355
-	ck_assert_int_eq(ttail->session->file.off, 221);
358
+	ck_assert(ttail->session->file.off_min.id == 0);
359
+	ck_assert_int_eq(ttail->session->file.off_min.off, 221);
356 360
 }
357 361
 END_TEST
358 362
 
@@ -377,11 +381,13 @@ START_TEST (test_search_files3)
377 381
 	tm.tm_hour = 1;
378 382
 	tm.tm_min = 0;
379 383
 	tm.tm_sec = -1;
384
+	memcpy(&(ttail->date_min), &tm, sizeof(tm));
385
+	ttail->flag |= TTAIL_FLAG_DATE_MIN;
380 386
 
381
-	ret = _ttail_search_closest_files(ttail, &tm);
387
+	ret = _ttail_search_closest_files(ttail);
382 388
 	ck_assert_int_eq(ret, 0);
383
-	ck_assert_int_eq(ttail->session->file.id, 5);
384
-	ck_assert_int_eq(ttail->session->file.off, 0);
389
+	ck_assert_int_eq(ttail->session->file.off_min.id, 5);
390
+	ck_assert_int_eq(ttail->session->file.off_min.off, 0);
385 391
 }
386 392
 END_TEST
387 393
 

Loading…
Cancel
Save