|
@@ -60,6 +60,12 @@ START_TEST (test_argparse_empty_verbose)
|
60
|
60
|
"ttail_t.verbose should be 0");
|
61
|
61
|
}
|
62
|
62
|
END_TEST
|
|
63
|
+START_TEST (test_argparse_empty_prefixsz)
|
|
64
|
+{
|
|
65
|
+ ck_assert_msg(ttail->prefix_sz == -1,
|
|
66
|
+ "ttail_t.prefix_sz should be NULL");
|
|
67
|
+}
|
|
68
|
+END_TEST
|
63
|
69
|
|
64
|
70
|
/*
|
65
|
71
|
* Bad arguments
|
|
@@ -255,17 +261,17 @@ START_TEST (test_argparse_file_multiple)
|
255
|
261
|
}
|
256
|
262
|
END_TEST
|
257
|
263
|
|
258
|
|
-START_TEST (test_argparse_prefix_short)
|
|
264
|
+START_TEST (test_argparse_reprefix_short)
|
259
|
265
|
{
|
260
|
266
|
ttail_t *t;
|
261
|
|
- char *args[] = {"foo", "-p", "^[^ ]+ "};
|
|
267
|
+ char *args[] = {"foo", "-r", "^[^ ]+ "};
|
262
|
268
|
t = ttail_init(3, args);
|
263
|
269
|
ck_assert(t != NULL);
|
264
|
270
|
ck_assert((t->flag & TTAIL_FLAG_PREFIX) == TTAIL_FLAG_PREFIX);
|
265
|
271
|
}
|
266
|
272
|
END_TEST
|
267
|
273
|
|
268
|
|
-START_TEST (test_argparse_prefix_long)
|
|
274
|
+START_TEST (test_argparse_reprefix_long)
|
269
|
275
|
{
|
270
|
276
|
ttail_t *t;
|
271
|
277
|
char *args[] = {"foo", "--re-prefix", "^[^ ]+ "};
|
|
@@ -275,10 +281,33 @@ START_TEST (test_argparse_prefix_long)
|
275
|
281
|
}
|
276
|
282
|
END_TEST
|
277
|
283
|
|
|
284
|
+START_TEST (test_argparse_prefixlen_short)
|
|
285
|
+{
|
|
286
|
+ ttail_t *t;
|
|
287
|
+ char *args[] = {"foo", "-p", "10"};
|
|
288
|
+ t = ttail_init(3, args);
|
|
289
|
+ ck_assert(t != NULL);
|
|
290
|
+ ck_assert((t->flag & TTAIL_FLAG_PREFIX) == TTAIL_FLAG_PREFIX);
|
|
291
|
+ ck_assert_int_eq(t->prefix_sz, 10);
|
|
292
|
+}
|
|
293
|
+END_TEST
|
|
294
|
+
|
|
295
|
+START_TEST (test_argparse_prefixlen_long)
|
|
296
|
+{
|
|
297
|
+ ttail_t *t;
|
|
298
|
+ char *args[] = {"foo", "--prefix-len", "42"};
|
|
299
|
+ t = ttail_init(3, args);
|
|
300
|
+ ck_assert(t != NULL);
|
|
301
|
+ ck_assert((t->flag & TTAIL_FLAG_PREFIX) == TTAIL_FLAG_PREFIX);
|
|
302
|
+ ck_assert_int_eq(t->prefix_sz, 42);
|
|
303
|
+}
|
|
304
|
+END_TEST
|
|
305
|
+
|
|
306
|
+
|
278
|
307
|
START_TEST (test_argparse_prefix_multiple)
|
279
|
308
|
{
|
280
|
309
|
ttail_t *t;
|
281
|
|
- char *args[] = {"foo", "--re-prefix", "^[^ ]+ ", "-p", "^[ -]+ "};
|
|
310
|
+ char *args[] = {"foo", "--re-prefix", "^[^ ]+ ", "-p", "20"};
|
282
|
311
|
t = ttail_init(5, args);
|
283
|
312
|
ck_assert(t == NULL);
|
284
|
313
|
}
|
|
@@ -331,6 +360,7 @@ Suite * ttail_init_suite(void)
|
331
|
360
|
tcase_add_test(tc_argparse_empty, test_argparse_empty_flag);
|
332
|
361
|
tcase_add_test(tc_argparse_empty, test_argparse_empty_fmt);
|
333
|
362
|
tcase_add_test(tc_argparse_empty, test_argparse_empty_verbose);
|
|
363
|
+ tcase_add_test(tc_argparse_empty, test_argparse_empty_prefixsz);
|
334
|
364
|
|
335
|
365
|
tc_argparse_badarg = tcase_create("bad arguments parsing");
|
336
|
366
|
tcase_add_test(tc_argparse_badarg, test_argparse_bad1);
|
|
@@ -349,8 +379,10 @@ Suite * ttail_init_suite(void)
|
349
|
379
|
tcase_add_test(tc_argparse_files, test_argparse_file_multiple);
|
350
|
380
|
|
351
|
381
|
tc_argparse_prefix = tcase_create("re-prefix arguments parsing");
|
352
|
|
- tcase_add_test(tc_argparse_prefix, test_argparse_prefix_short);
|
353
|
|
- tcase_add_test(tc_argparse_prefix, test_argparse_prefix_long);
|
|
382
|
+ tcase_add_test(tc_argparse_prefix, test_argparse_reprefix_short);
|
|
383
|
+ tcase_add_test(tc_argparse_prefix, test_argparse_reprefix_long);
|
|
384
|
+ tcase_add_test(tc_argparse_prefix, test_argparse_prefixlen_short);
|
|
385
|
+ tcase_add_test(tc_argparse_prefix, test_argparse_prefixlen_long);
|
354
|
386
|
tcase_add_test(tc_argparse_prefix, test_argparse_prefix_multiple);
|
355
|
387
|
|
356
|
388
|
tc_argparse_fmt = tcase_create("date format arguments parsing");
|