Browse code

Test choices before search is run.

John Hawthorn authored on 21/09/2014 21:18:22
Showing 1 changed files

... ...
@@ -209,6 +209,27 @@ int test_choices_2(){
209 209
 	return 0;
210 210
 }
211 211
 
212
+int test_choices_without_search(){
213
+	/* Before a search is run, it should return no results */
214
+
215
+	choices_t choices;
216
+	choices_init(&choices);
217
+
218
+	assert(choices.available == 0);
219
+	assert(choices.selection == 0);
220
+	assert(choices.size == 0);
221
+	assert(choices_get(&choices, 0) == NULL);
222
+
223
+	choices_add(&choices, "test");
224
+
225
+	assert(choices.available == 0);
226
+	assert(choices.selection == 0);
227
+	assert(choices.size == 1);
228
+	assert(choices_get(&choices, 0) == NULL);
229
+
230
+	return 0;
231
+}
232
+
212 233
 void summary(){
213 234
 	printf("%i tests, %i assertions, %i failures\n", testsrun, assertionsrun, testsfailed);
214 235
 }
... ...
@@ -228,6 +249,7 @@ int main(int argc, char *argv[]){
228 249
 	runtest(test_choices_empty);
229 250
 	runtest(test_choices_1);
230 251
 	runtest(test_choices_2);
252
+	runtest(test_choices_without_search);
231 253
 
232 254
 	summary();
233 255