about summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_autocomplete.c2
-rw-r--r--tests/test_common.c2
-rw-r--r--tests/testsuite.c65
3 files changed, 64 insertions, 5 deletions
diff --git a/tests/test_autocomplete.c b/tests/test_autocomplete.c
index 3eea639b..e6fdde47 100644
--- a/tests/test_autocomplete.c
+++ b/tests/test_autocomplete.c
@@ -44,7 +44,7 @@ void add_one_and_complete(void **state)
     autocomplete_add(ac, "Hello");
     char *result = autocomplete_complete(ac, "Hel");
 
-    assert_string_equal("Hello", result);
+    assert_string_equal("Hello aaaa", result);
 
     autocomplete_clear(ac);
 }
diff --git a/tests/test_common.c b/tests/test_common.c
index 0d02bbd0..bcd421a0 100644
--- a/tests/test_common.c
+++ b/tests/test_common.c
@@ -46,7 +46,7 @@ void replace_two_substr(void **state)
 
     char *result = str_replace(string, sub, new);
 
-    assert_string_equal("it was a was string", result);
+    assert_string_equal("it was a was string ssss", result);
 }
 
 void replace_char(void **state)
diff --git a/tests/testsuite.c b/tests/testsuite.c
index 7d1e5165..1c91e17a 100644
--- a/tests/testsuite.c
+++ b/tests/testsuite.c
@@ -1,4 +1,7 @@
 #include <stdarg.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <fcntl.h>
 #include <stddef.h>
 #include <setjmp.h>
 #include <cmocka.h>
@@ -16,8 +19,12 @@
 #include "test_parser.h"
 #include "test_roster_list.h"
 
+#define PROF_RUN_TESTS(name) fprintf(stderr, "\n-> Running %s\n", #name); \
+    fflush(stderr); \
+    result += run_tests(name);
+
 int main(int argc, char* argv[]) {
-    const UnitTest tests[] = {
+    const UnitTest common_tests[] = {
         unit_test(replace_one_substr),
         unit_test(replace_one_substr_beginning),
         unit_test(replace_one_substr_end),
@@ -58,7 +65,9 @@ int main(int argc, char* argv[]) {
         unit_test(test_available_is_not_valid_resource_presence_string),
         unit_test(test_unavailable_is_not_valid_resource_presence_string),
         unit_test(test_blah_is_not_valid_resource_presence_string),
+    };
 
+    const UnitTest autocomplete_tests[] = {
         unit_test(clear_empty),
         unit_test(reset_after_create),
         unit_test(find_after_create),
@@ -69,7 +78,9 @@ int main(int argc, char* argv[]) {
         unit_test(add_two_adds_two),
         unit_test(add_two_same_adds_one),
         unit_test(add_two_same_updates),
+    };
 
+    const UnitTest history_tests[] = {
         unit_test(previous_on_empty_returns_null),
         unit_test(next_on_empty_returns_null),
         unit_test(previous_once_returns_last),
@@ -83,7 +94,9 @@ int main(int argc, char* argv[]) {
         unit_test(edit_item_mid_history),
         unit_test(edit_previous_and_append),
         unit_test(start_session_add_new_submit_previous),
+    };
 
+    const UnitTest jid_tests[] = {
         unit_test(create_jid_from_null_returns_null),
         unit_test(create_jid_from_empty_string_returns_null),
         unit_test(create_jid_from_full_returns_full),
@@ -107,7 +120,9 @@ int main(int argc, char* argv[]) {
         unit_test(create_with_at_in_resource),
         unit_test(create_with_at_and_slash_in_resource),
         unit_test(create_full_with_trailing_slash),
+    };
 
+    const UnitTest parser_tests[] = {
         unit_test(parse_null_returns_null),
         unit_test(parse_empty_returns_null),
         unit_test(parse_space_returns_null),
@@ -149,7 +164,9 @@ int main(int argc, char* argv[]) {
         unit_test(get_first_two_of_three_first_quoted),
         unit_test(get_first_two_of_three_second_quoted),
         unit_test(get_first_two_of_three_first_and_second_quoted),
+    };
 
+    const UnitTest roster_list_tests[] = {
         unit_test(empty_list_when_none_added),
         unit_test(contains_one_element),
         unit_test(first_element_correct),
@@ -168,7 +185,9 @@ int main(int argc, char* argv[]) {
         unit_test(find_twice_returns_second_when_two_match),
         unit_test(find_five_times_finds_fifth),
         unit_test(find_twice_returns_first_when_two_match_and_reset),
+    };
 
+    const UnitTest cmd_connect_tests[] = {
         unit_test(cmd_connect_shows_message_when_disconnecting),
         unit_test(cmd_connect_shows_message_when_connecting),
         unit_test(cmd_connect_shows_message_when_connected),
@@ -195,7 +214,9 @@ int main(int argc, char* argv[]) {
         unit_test(cmd_connect_shows_usage_when_port_provided_twice),
         unit_test(cmd_connect_shows_usage_when_invalid_first_property),
         unit_test(cmd_connect_shows_usage_when_invalid_second_property),
+    };
 
+    const UnitTest cmd_rooms_tests[] = {
         unit_test(cmd_rooms_shows_message_when_disconnected),
         unit_test(cmd_rooms_shows_message_when_disconnecting),
         unit_test(cmd_rooms_shows_message_when_connecting),
@@ -203,7 +224,9 @@ int main(int argc, char* argv[]) {
         unit_test(cmd_rooms_shows_message_when_undefined),
         unit_test(cmd_rooms_uses_account_default_when_no_arg),
         unit_test(cmd_rooms_arg_used_when_passed),
+    };
 
+    const UnitTest cmd_account_tests[] = {
         unit_test(cmd_account_shows_usage_when_not_connected_and_no_args),
         unit_test(cmd_account_shows_account_when_connected_and_no_args),
         unit_test(cmd_account_list_shows_accounts),
@@ -267,10 +290,14 @@ int main(int argc, char* argv[]) {
         unit_test(cmd_account_clear_checks_account_exists),
         unit_test(cmd_account_clear_shows_message_when_account_doesnt_exist),
         unit_test(cmd_account_clear_shows_message_when_invalid_property),
+    };
 
+    const UnitTest cmd_sub_tests[] = {
         unit_test(cmd_sub_shows_message_when_not_connected),
         unit_test(cmd_sub_shows_usage_when_no_arg),
+    };
 
+    const UnitTest contact_tests[] = {
         unit_test(contact_in_group),
         unit_test(contact_not_in_group),
         unit_test(contact_name_when_name_exists),
@@ -295,12 +322,44 @@ int main(int argc, char* argv[]) {
         unit_test(contact_not_available_when_highest_priority_dnd),
         unit_test(contact_available_when_highest_priority_online),
         unit_test(contact_available_when_highest_priority_chat),
+    };
 
+    const UnitTest cmd_statuses_tests[] = {
         unit_test(cmd_statuses_shows_usage_when_bad_subcmd),
         unit_test(cmd_statuses_shows_usage_when_bad_console_setting),
         unit_test(cmd_statuses_shows_usage_when_bad_chat_setting),
         unit_test(cmd_statuses_shows_usage_when_bad_muc_setting),
-
     };
-    return run_tests(tests);
+
+    int bak, new;
+    fflush(stdout);
+    bak = dup(1);
+    new = open("/dev/null", O_WRONLY);
+    dup2(new, 1);
+    close(new);
+
+    int result = 0;
+
+    PROF_RUN_TESTS(common_tests);
+    PROF_RUN_TESTS(autocomplete_tests);
+    PROF_RUN_TESTS(history_tests);
+    PROF_RUN_TESTS(jid_tests);
+    PROF_RUN_TESTS(parser_tests);
+    PROF_RUN_TESTS(roster_list_tests);
+    PROF_RUN_TESTS(cmd_connect_tests);
+    PROF_RUN_TESTS(cmd_rooms_tests);
+    PROF_RUN_TESTS(cmd_account_tests);
+    PROF_RUN_TESTS(cmd_sub_tests);
+    PROF_RUN_TESTS(contact_tests);
+    PROF_RUN_TESTS(cmd_statuses_tests);
+
+    fflush(stdout);
+    dup2(bak, 1);
+    close(bak);
+
+    if (result > 0) {
+        return 1;
+    } else {
+        return 0;
+    }
 }
8845cafdd62b664bec1afd8'>^
1fc1d8af ^



























03413d1c ^
50f9f94b ^
1fc1d8af ^


b223937f ^
03413d1c ^
1fc1d8af ^




















1367261d ^
1fc1d8af ^







e087f6d4
2d161b7d ^
1fc1d8af ^










2d161b7d ^
e087f6d4
1fc1d8af ^



































e087f6d4


1fc1d8af ^



d326f24d ^
1fc1d8af ^



d326f24d ^
1fc1d8af ^

d326f24d ^
1fc1d8af ^

d326f24d ^
1fc1d8af ^



d326f24d ^
1fc1d8af ^
d326f24d ^
1fc1d8af ^

d326f24d ^
1fc1d8af ^


2d161b7d ^
1fc1d8af ^






b223937f ^
d61bc4e5 ^
1fc1d8af ^
b223937f ^
327b7c16 ^
1fc1d8af ^
383b3f2d ^

1fc1d8af ^
383b3f2d ^
a2a1ab1e ^
1fc1d8af ^



a2a1ab1e ^
1fc1d8af ^



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290