|
@@ -15,12 +15,9 @@ START_TEST (test_init_guess_date)
|
15
|
15
|
int ret;
|
16
|
16
|
struct tm tm;
|
17
|
17
|
char res[] = "%Y/%m/%d";
|
18
|
|
- ret = ttail_format_guess(ttail, "1988/10/22", &tm);
|
|
18
|
+ ret = ttail_format_guess("1988/10/22", &tm);
|
19
|
19
|
ck_assert_int_ne(ret, -1);
|
20
|
20
|
ck_assert_str_eq(fmt[ret], res);
|
21
|
|
- ck_assert(ttail->fmt != NULL);
|
22
|
|
- ck_assert_str_eq(ttail->fmt, res);
|
23
|
|
- ck_assert((ttail->flag & TTAIL_FLAG_FORMAT) == TTAIL_FLAG_FORMAT);
|
24
|
21
|
ck_assert_int_eq(tm.tm_year, 88);
|
25
|
22
|
ck_assert_int_eq(tm.tm_mon, 9);
|
26
|
23
|
ck_assert_int_eq(tm.tm_mday, 22);
|
|
@@ -35,12 +32,9 @@ START_TEST (test_init_guess_datetime)
|
35
|
32
|
int ret;
|
36
|
33
|
struct tm tm;
|
37
|
34
|
char res[] = "%Y/%m/%d:%H:%M";
|
38
|
|
- ret = ttail_format_guess(ttail, "1988/10/22:22:10:00", &tm);
|
|
35
|
+ ret = ttail_format_guess("1988/10/22:22:10:00", &tm);
|
39
|
36
|
ck_assert_int_ne(ret, -1);
|
40
|
37
|
ck_assert_str_eq(fmt[ret], res);
|
41
|
|
- ck_assert(ttail->fmt != NULL);
|
42
|
|
- ck_assert_str_eq(ttail->fmt, res);
|
43
|
|
- ck_assert((ttail->flag & TTAIL_FLAG_FORMAT) == TTAIL_FLAG_FORMAT);
|
44
|
38
|
ck_assert_int_eq(tm.tm_year, 88);
|
45
|
39
|
ck_assert_int_eq(tm.tm_mon, 9);
|
46
|
40
|
ck_assert_int_eq(tm.tm_mday, 22);
|
|
@@ -55,12 +49,9 @@ START_TEST (test_init_guess_datetime2)
|
55
|
49
|
int ret;
|
56
|
50
|
struct tm tm;
|
57
|
51
|
char res[] = "%B%n%d %H:%M:%S";
|
58
|
|
- ret = ttail_format_guess(ttail, "Mar 6 00:01:39 pilgrim dhclient", &tm);
|
|
52
|
+ ret = ttail_format_guess("Mar 6 00:01:39 pilgrim dhclient", &tm);
|
59
|
53
|
ck_assert_int_ne(ret, -1);
|
60
|
54
|
ck_assert_str_eq(fmt[ret], res);
|
61
|
|
- ck_assert(ttail->fmt != NULL);
|
62
|
|
- ck_assert_str_eq(ttail->fmt, res);
|
63
|
|
- ck_assert((ttail->flag & TTAIL_FLAG_FORMAT) == TTAIL_FLAG_FORMAT);
|
64
|
55
|
ck_assert_int_eq(tm.tm_year, 0);
|
65
|
56
|
ck_assert_int_eq(tm.tm_mon, 2);
|
66
|
57
|
ck_assert_int_eq(tm.tm_mday, 6);
|
|
@@ -74,10 +65,8 @@ START_TEST (test_init_guess_noguess)
|
74
|
65
|
{
|
75
|
66
|
int ret;
|
76
|
67
|
struct tm tm;
|
77
|
|
- ret = ttail_format_guess(ttail, "notadate", &tm);
|
|
68
|
+ ret = ttail_format_guess("notadate", &tm);
|
78
|
69
|
ck_assert_int_eq(ret, -1);
|
79
|
|
- ck_assert(ttail->fmt == NULL);
|
80
|
|
- ck_assert((ttail->flag & TTAIL_FLAG_FORMAT) == 0);
|
81
|
70
|
ck_assert_int_eq(tm.tm_year, 0);
|
82
|
71
|
ck_assert_int_eq(tm.tm_mon, 0);
|
83
|
72
|
ck_assert_int_eq(tm.tm_mday, 0);
|
|
@@ -91,12 +80,9 @@ START_TEST (test_init_guess_date_notm)
|
91
|
80
|
{
|
92
|
81
|
int ret;
|
93
|
82
|
char res[] = "%Y/%m/%d";
|
94
|
|
- ret = ttail_format_guess(ttail, "1988/10/22", NULL);
|
|
83
|
+ ret = ttail_format_guess("1988/10/22", NULL);
|
95
|
84
|
ck_assert_int_ne(ret, -1);
|
96
|
85
|
ck_assert_str_eq(fmt[ret], res);
|
97
|
|
- ck_assert(ttail->fmt != NULL);
|
98
|
|
- ck_assert_str_eq(ttail->fmt, res);
|
99
|
|
- ck_assert((ttail->flag & TTAIL_FLAG_FORMAT) == TTAIL_FLAG_FORMAT);
|
100
|
86
|
}
|
101
|
87
|
END_TEST
|
102
|
88
|
|
|
@@ -104,26 +90,13 @@ START_TEST (test_init_guess_noguess_notm)
|
104
|
90
|
{
|
105
|
91
|
int ret;
|
106
|
92
|
struct tm tm;
|
107
|
|
- ret = ttail_format_guess(ttail, "notadate", &tm);
|
|
93
|
+ ret = ttail_format_guess("notadate", &tm);
|
108
|
94
|
ck_assert_int_eq(ret, -1);
|
109
|
95
|
ck_assert(ttail->fmt == NULL);
|
110
|
96
|
ck_assert((ttail->flag & TTAIL_FLAG_FORMAT) == 0);
|
111
|
97
|
}
|
112
|
98
|
END_TEST
|
113
|
99
|
|
114
|
|
-START_TEST (test_init_guess_fmt_set)
|
115
|
|
-{
|
116
|
|
- int ret;
|
117
|
|
- char res[] = "%Y/%m/%d";
|
118
|
|
- ret = ttail_format_guess(ttail, "1988/10/22", NULL);
|
119
|
|
- ck_assert_str_eq(fmt[ret], res);
|
120
|
|
- ret = ttail_format_guess(ttail, "1988/10/22", NULL);
|
121
|
|
- ck_assert_int_eq(ret, -2);
|
122
|
|
- ck_assert_str_eq(ttail->fmt, res);
|
123
|
|
- ck_assert((ttail->flag & TTAIL_FLAG_FORMAT) == TTAIL_FLAG_FORMAT);
|
124
|
|
-}
|
125
|
|
-END_TEST
|
126
|
|
-
|
127
|
100
|
TTAIL_CHECK_START("ttail init checks", "date format guess init checks")
|
128
|
101
|
TTAIL_SET_FIXTURE(setup_ttail_empty, teardown_ttail);
|
129
|
102
|
TTAIL_ADD_TEST(test_init_guess_date);
|
|
@@ -132,6 +105,5 @@ TTAIL_CHECK_START("ttail init checks", "date format guess init checks")
|
132
|
105
|
TTAIL_ADD_TEST(test_init_guess_noguess);
|
133
|
106
|
TTAIL_ADD_TEST(test_init_guess_date_notm);
|
134
|
107
|
TTAIL_ADD_TEST(test_init_guess_noguess_notm);
|
135
|
|
- TTAIL_ADD_TEST(test_init_guess_fmt_set);
|
136
|
108
|
TTAIL_CHECK_END
|
137
|
109
|
|