163
164
t_string_list_clear(&list, 0);
165
}
166
+
167
+static void t_string_list_remove_duplicates(struct string_list *list, ...)
168
+{
169
+ struct string_list expected_strings = STRING_LIST_INIT_DUP;
170
+ va_list ap;
171
+
172
+ va_start(ap, list);
173
+ t_vcreate_string_list_dup(&expected_strings, 0, ap);
174
+ va_end(ap);
175
+
176
+ string_list_remove_duplicates(list, 0);
177
+ t_string_list_equal(list, &expected_strings);
178
+
179
+ string_list_clear(&expected_strings, 0);
180
+}
181
+
182
+void test_string_list__remove_duplicates(void)
183
+{
184
+ struct string_list list = STRING_LIST_INIT_DUP;
185
+
186
+ t_create_string_list_dup(&list, 0, NULL);
187
+ t_string_list_remove_duplicates(&list, NULL);
188
+
189
+ t_create_string_list_dup(&list, 0, "", NULL);
190
+ t_string_list_remove_duplicates(&list, "", NULL);
191
+
192
+ t_create_string_list_dup(&list, 0, "a", NULL);
193
+ t_string_list_remove_duplicates(&list, "a", NULL);
194
+
195
+ t_create_string_list_dup(&list, 0, "a", "a", NULL);
196
+ t_string_list_remove_duplicates(&list, "a", NULL);
197
+
198
+ t_create_string_list_dup(&list, 0, "a", "a", "a", NULL);
199
+ t_string_list_remove_duplicates(&list, "a", NULL);
200
+
201
+ t_create_string_list_dup(&list, 0, "a", "a", "b", NULL);
202
+ t_string_list_remove_duplicates(&list, "a", "b", NULL);
203
+
204
+ t_create_string_list_dup(&list, 0, "a", "b", "b", NULL);
205
+ t_string_list_remove_duplicates(&list, "a", "b", NULL);
206
+
207
+ t_create_string_list_dup(&list, 0, "a", "b", "c", NULL);
208
+ t_string_list_remove_duplicates(&list, "a", "b", "c", NULL);
209
+
210
+ t_create_string_list_dup(&list, 0, "a", "a", "b", "c", NULL);
211
+ t_string_list_remove_duplicates(&list, "a", "b", "c", NULL);
212
+
213
+ t_create_string_list_dup(&list, 0, "a", "b", "b", "c", NULL);
214
+ t_string_list_remove_duplicates(&list, "a", "b", "c", NULL);
215
+
216
+ t_create_string_list_dup(&list, 0, "a", "b", "c", "c", NULL);
217
+ t_string_list_remove_duplicates(&list, "a", "b", "c", NULL);
218
+
219
+ t_create_string_list_dup(&list, 0, "a", "a", "b", "b", "c", "c", NULL);
220
+ t_string_list_remove_duplicates(&list, "a", "b", "c", NULL);
221
+
222
+ t_create_string_list_dup(&list, 0, "a", "a", "a", "b", "b", "b",
223
+ "c", "c", "c", NULL);
224
+ t_string_list_remove_duplicates(&list, "a", "b", "c", NULL);
225
+
226
+ t_string_list_clear(&list, 0);
227
+}