Browse code

Error on usage of VLA

John Hawthorn authored on 28/12/2019 02:44:01
Showing 1 changed files
... ...
@@ -135,8 +135,8 @@ TEST test_choices_unicode() {
135 135
 }
136 136
 
137 137
 TEST test_choices_large_input() {
138
-	int N = 100000;
139
-	char *strings[N];
138
+	const int N = 100000;
139
+	char *strings[100000];
140 140
 
141 141
 	for(int i = 0; i < N; i++) {
142 142
 		asprintf(&strings[i], "%i", i);
Browse code

Fix warnings due to types in test

John Hawthorn authored on 27/04/2017 01:09:45
Showing 1 changed files
... ...
@@ -8,7 +8,7 @@
8 8
 
9 9
 #include "greatest/greatest.h"
10 10
 
11
-#define ASSERT_INT_EQ(a,b) ASSERT_EQ_FMT((a), (b), "%d")
11
+#define ASSERT_SIZE_T_EQ(a,b) ASSERT_EQ_FMT((size_t)(a), (b), "%zu")
12 12
 
13 13
 static options_t default_options;
14 14
 static choices_t choices;
... ...
@@ -26,15 +26,15 @@ static void teardown(void *udata) {
26 26
 }
27 27
 
28 28
 TEST test_choices_empty() {
29
-	ASSERT_INT_EQ(0, choices.size);
30
-	ASSERT_INT_EQ(0, choices.available);
31
-	ASSERT_INT_EQ(0, choices.selection);
29
+	ASSERT_SIZE_T_EQ(0, choices.size);
30
+	ASSERT_SIZE_T_EQ(0, choices.available);
31
+	ASSERT_SIZE_T_EQ(0, choices.selection);
32 32
 
33 33
 	choices_prev(&choices);
34
-	ASSERT_INT_EQ(0, choices.selection);
34
+	ASSERT_SIZE_T_EQ(0, choices.selection);
35 35
 
36 36
 	choices_next(&choices);
37
-	ASSERT_INT_EQ(0, choices.selection);
37
+	ASSERT_SIZE_T_EQ(0, choices.selection);
38 38
 
39 39
 	PASS();
40 40
 }
... ...
@@ -43,21 +43,21 @@ TEST test_choices_1() {
43 43
 	choices_add(&choices, "tags");
44 44
 
45 45
 	choices_search(&choices, "");
46
-	ASSERT_INT_EQ(1, choices.available);
47
-	ASSERT_INT_EQ(0, choices.selection);
46
+	ASSERT_SIZE_T_EQ(1, choices.available);
47
+	ASSERT_SIZE_T_EQ(0, choices.selection);
48 48
 
49 49
 	choices_search(&choices, "t");
50
-	ASSERT_INT_EQ(1, choices.available);
51
-	ASSERT_INT_EQ(0, choices.selection);
50
+	ASSERT_SIZE_T_EQ(1, choices.available);
51
+	ASSERT_SIZE_T_EQ(0, choices.selection);
52 52
 
53 53
 	choices_prev(&choices);
54
-	ASSERT_INT_EQ(0, choices.selection);
54
+	ASSERT_SIZE_T_EQ(0, choices.selection);
55 55
 
56 56
 	choices_next(&choices);
57
-	ASSERT_INT_EQ(0, choices.selection);
57
+	ASSERT_SIZE_T_EQ(0, choices.selection);
58 58
 
59 59
 	ASSERT(!strcmp(choices_get(&choices, 0), "tags"));
60
-	ASSERT_INT_EQ(NULL, choices_get(&choices, 1));
60
+	ASSERT_EQ(NULL, choices_get(&choices, 1));
61 61
 
62 62
 	PASS();
63 63
 }
... ...
@@ -68,40 +68,40 @@ TEST test_choices_2() {
68 68
 
69 69
 	/* Empty search */
70 70
 	choices_search(&choices, "");
71
-	ASSERT_INT_EQ(0, choices.selection);
72
-	ASSERT_INT_EQ(2, choices.available);
71
+	ASSERT_SIZE_T_EQ(0, choices.selection);
72
+	ASSERT_SIZE_T_EQ(2, choices.available);
73 73
 
74 74
 	choices_next(&choices);
75
-	ASSERT_INT_EQ(1, choices.selection);
75
+	ASSERT_SIZE_T_EQ(1, choices.selection);
76 76
 	choices_next(&choices);
77
-	ASSERT_INT_EQ(0, choices.selection);
77
+	ASSERT_SIZE_T_EQ(0, choices.selection);
78 78
 
79 79
 	choices_prev(&choices);
80
-	ASSERT_INT_EQ(1, choices.selection);
80
+	ASSERT_SIZE_T_EQ(1, choices.selection);
81 81
 	choices_prev(&choices);
82
-	ASSERT_INT_EQ(0, choices.selection);
82
+	ASSERT_SIZE_T_EQ(0, choices.selection);
83 83
 
84 84
 	/* Filtered search */
85 85
 	choices_search(&choices, "te");
86
-	ASSERT_INT_EQ(1, choices.available);
87
-	ASSERT_INT_EQ(0, choices.selection);
86
+	ASSERT_SIZE_T_EQ(1, choices.available);
87
+	ASSERT_SIZE_T_EQ(0, choices.selection);
88 88
 	ASSERT_STR_EQ("test", choices_get(&choices, 0));
89 89
 
90 90
 	choices_next(&choices);
91
-	ASSERT_INT_EQ(0, choices.selection);
91
+	ASSERT_SIZE_T_EQ(0, choices.selection);
92 92
 
93 93
 	choices_prev(&choices);
94
-	ASSERT_INT_EQ(0, choices.selection);
94
+	ASSERT_SIZE_T_EQ(0, choices.selection);
95 95
 
96 96
 	/* No results */
97 97
 	choices_search(&choices, "foobar");
98
-	ASSERT_INT_EQ(0, choices.available);
99
-	ASSERT_INT_EQ(0, choices.selection);
98
+	ASSERT_SIZE_T_EQ(0, choices.available);
99
+	ASSERT_SIZE_T_EQ(0, choices.selection);
100 100
 
101 101
 	/* Different order due to scoring */
102 102
 	choices_search(&choices, "ts");
103
-	ASSERT_INT_EQ(2, choices.available);
104
-	ASSERT_INT_EQ(0, choices.selection);
103
+	ASSERT_SIZE_T_EQ(2, choices.available);
104
+	ASSERT_SIZE_T_EQ(0, choices.selection);
105 105
 	ASSERT_STR_EQ("test", choices_get(&choices, 0));
106 106
 	ASSERT_STR_EQ("tags", choices_get(&choices, 1));
107 107
 
... ...
@@ -111,17 +111,17 @@ TEST test_choices_2() {
111 111
 TEST test_choices_without_search() {
112 112
 	/* Before a search is run, it should return no results */
113 113
 
114
-	ASSERT_INT_EQ(0, choices.available);
115
-	ASSERT_INT_EQ(0, choices.selection);
116
-	ASSERT_INT_EQ(0, choices.size);
117
-	ASSERT_INT_EQ(NULL, choices_get(&choices, 0));
114
+	ASSERT_SIZE_T_EQ(0, choices.available);
115
+	ASSERT_SIZE_T_EQ(0, choices.selection);
116
+	ASSERT_SIZE_T_EQ(0, choices.size);
117
+	ASSERT_EQ(NULL, choices_get(&choices, 0));
118 118
 
119 119
 	choices_add(&choices, "test");
120 120
 
121
-	ASSERT_INT_EQ(0, choices.available);
122
-	ASSERT_INT_EQ(0, choices.selection);
123
-	ASSERT_INT_EQ(1, choices.size);
124
-	ASSERT_INT_EQ(NULL, choices_get(&choices, 0));
121
+	ASSERT_SIZE_T_EQ(0, choices.available);
122
+	ASSERT_SIZE_T_EQ(0, choices.selection);
123
+	ASSERT_SIZE_T_EQ(1, choices.size);
124
+	ASSERT_EQ(NULL, choices_get(&choices, 0));
125 125
 
126 126
 	PASS();
127 127
 }
... ...
@@ -146,7 +146,7 @@ TEST test_choices_large_input() {
146 146
 	choices_search(&choices, "12");
147 147
 
148 148
 	/* Must match `seq 0 99999 | grep '.*1.*2.*' | wc -l` */
149
-	ASSERT_INT_EQ(8146, choices.available);
149
+	ASSERT_SIZE_T_EQ(8146, choices.available);
150 150
 
151 151
 	ASSERT_STR_EQ("12", choices_get(&choices, 0));
152 152
 
Browse code

Format values in errored tests

John Hawthorn authored on 17/04/2017 06:12:21
Showing 1 changed files
... ...
@@ -8,7 +8,7 @@
8 8
 
9 9
 #include "greatest/greatest.h"
10 10
 
11
-#define ASSERT_EQ(a,b) ASSERT_EQ_FMT((a), (b), "%d")
11
+#define ASSERT_INT_EQ(a,b) ASSERT_EQ_FMT((a), (b), "%d")
12 12
 
13 13
 static options_t default_options;
14 14
 static choices_t choices;
... ...
@@ -26,15 +26,15 @@ static void teardown(void *udata) {
26 26
 }
27 27
 
28 28
 TEST test_choices_empty() {
29
-	ASSERT_EQ(0, choices.size);
30
-	ASSERT_EQ(0, choices.available);
31
-	ASSERT_EQ(0, choices.selection);
29
+	ASSERT_INT_EQ(0, choices.size);
30
+	ASSERT_INT_EQ(0, choices.available);
31
+	ASSERT_INT_EQ(0, choices.selection);
32 32
 
33 33
 	choices_prev(&choices);
34
-	ASSERT_EQ(0, choices.selection);
34
+	ASSERT_INT_EQ(0, choices.selection);
35 35
 
36 36
 	choices_next(&choices);
37
-	ASSERT_EQ(0, choices.selection);
37
+	ASSERT_INT_EQ(0, choices.selection);
38 38
 
39 39
 	PASS();
40 40
 }
... ...
@@ -43,21 +43,21 @@ TEST test_choices_1() {
43 43
 	choices_add(&choices, "tags");
44 44
 
45 45
 	choices_search(&choices, "");
46
-	ASSERT_EQ(1, choices.available);
47
-	ASSERT_EQ(0, choices.selection);
46
+	ASSERT_INT_EQ(1, choices.available);
47
+	ASSERT_INT_EQ(0, choices.selection);
48 48
 
49 49
 	choices_search(&choices, "t");
50
-	ASSERT_EQ(1, choices.available);
51
-	ASSERT_EQ(0, choices.selection);
50
+	ASSERT_INT_EQ(1, choices.available);
51
+	ASSERT_INT_EQ(0, choices.selection);
52 52
 
53 53
 	choices_prev(&choices);
54
-	ASSERT_EQ(0, choices.selection);
54
+	ASSERT_INT_EQ(0, choices.selection);
55 55
 
56 56
 	choices_next(&choices);
57
-	ASSERT_EQ(0, choices.selection);
57
+	ASSERT_INT_EQ(0, choices.selection);
58 58
 
59 59
 	ASSERT(!strcmp(choices_get(&choices, 0), "tags"));
60
-	ASSERT_EQ(NULL, choices_get(&choices, 1));
60
+	ASSERT_INT_EQ(NULL, choices_get(&choices, 1));
61 61
 
62 62
 	PASS();
63 63
 }
... ...
@@ -68,40 +68,40 @@ TEST test_choices_2() {
68 68
 
69 69
 	/* Empty search */
70 70
 	choices_search(&choices, "");
71
-	ASSERT_EQ(0, choices.selection);
72
-	ASSERT_EQ(2, choices.available);
71
+	ASSERT_INT_EQ(0, choices.selection);
72
+	ASSERT_INT_EQ(2, choices.available);
73 73
 
74 74
 	choices_next(&choices);
75
-	ASSERT_EQ(1, choices.selection);
75
+	ASSERT_INT_EQ(1, choices.selection);
76 76
 	choices_next(&choices);
77
-	ASSERT_EQ(0, choices.selection);
77
+	ASSERT_INT_EQ(0, choices.selection);
78 78
 
79 79
 	choices_prev(&choices);
80
-	ASSERT_EQ(1, choices.selection);
80
+	ASSERT_INT_EQ(1, choices.selection);
81 81
 	choices_prev(&choices);
82
-	ASSERT_EQ(0, choices.selection);
82
+	ASSERT_INT_EQ(0, choices.selection);
83 83
 
84 84
 	/* Filtered search */
85 85
 	choices_search(&choices, "te");
86
-	ASSERT_EQ(1, choices.available);
87
-	ASSERT_EQ(0, choices.selection);
86
+	ASSERT_INT_EQ(1, choices.available);
87
+	ASSERT_INT_EQ(0, choices.selection);
88 88
 	ASSERT_STR_EQ("test", choices_get(&choices, 0));
89 89
 
90 90
 	choices_next(&choices);
91
-	ASSERT_EQ(0, choices.selection);
91
+	ASSERT_INT_EQ(0, choices.selection);
92 92
 
93 93
 	choices_prev(&choices);
94
-	ASSERT_EQ(0, choices.selection);
94
+	ASSERT_INT_EQ(0, choices.selection);
95 95
 
96 96
 	/* No results */
97 97
 	choices_search(&choices, "foobar");
98
-	ASSERT_EQ(0, choices.available);
99
-	ASSERT_EQ(0, choices.selection);
98
+	ASSERT_INT_EQ(0, choices.available);
99
+	ASSERT_INT_EQ(0, choices.selection);
100 100
 
101 101
 	/* Different order due to scoring */
102 102
 	choices_search(&choices, "ts");
103
-	ASSERT_EQ(2, choices.available);
104
-	ASSERT_EQ(0, choices.selection);
103
+	ASSERT_INT_EQ(2, choices.available);
104
+	ASSERT_INT_EQ(0, choices.selection);
105 105
 	ASSERT_STR_EQ("test", choices_get(&choices, 0));
106 106
 	ASSERT_STR_EQ("tags", choices_get(&choices, 1));
107 107
 
... ...
@@ -111,17 +111,17 @@ TEST test_choices_2() {
111 111
 TEST test_choices_without_search() {
112 112
 	/* Before a search is run, it should return no results */
113 113
 
114
-	ASSERT_EQ(0, choices.available);
115
-	ASSERT_EQ(0, choices.selection);
116
-	ASSERT_EQ(0, choices.size);
117
-	ASSERT_EQ(NULL, choices_get(&choices, 0));
114
+	ASSERT_INT_EQ(0, choices.available);
115
+	ASSERT_INT_EQ(0, choices.selection);
116
+	ASSERT_INT_EQ(0, choices.size);
117
+	ASSERT_INT_EQ(NULL, choices_get(&choices, 0));
118 118
 
119 119
 	choices_add(&choices, "test");
120 120
 
121
-	ASSERT_EQ(0, choices.available);
122
-	ASSERT_EQ(0, choices.selection);
123
-	ASSERT_EQ(1, choices.size);
124
-	ASSERT_EQ(NULL, choices_get(&choices, 0));
121
+	ASSERT_INT_EQ(0, choices.available);
122
+	ASSERT_INT_EQ(0, choices.selection);
123
+	ASSERT_INT_EQ(1, choices.size);
124
+	ASSERT_INT_EQ(NULL, choices_get(&choices, 0));
125 125
 
126 126
 	PASS();
127 127
 }
... ...
@@ -146,7 +146,7 @@ TEST test_choices_large_input() {
146 146
 	choices_search(&choices, "12");
147 147
 
148 148
 	/* Must match `seq 0 99999 | grep '.*1.*2.*' | wc -l` */
149
-	ASSERT_EQ(8146, choices.available);
149
+	ASSERT_INT_EQ(8146, choices.available);
150 150
 
151 151
 	ASSERT_STR_EQ("12", choices_get(&choices, 0));
152 152
 
Browse code

Use setup and teardown in choices suite

John Hawthorn authored on 05/04/2017 08:18:19
Showing 1 changed files
... ...
@@ -8,11 +8,24 @@
8 8
 
9 9
 #include "greatest/greatest.h"
10 10
 
11
+#define ASSERT_EQ(a,b) ASSERT_EQ_FMT((a), (b), "%d")
12
+
11 13
 static options_t default_options;
14
+static choices_t choices;
15
+
16
+static void setup(void *udata) {
17
+    (void)udata;
18
+
19
+    options_init(&default_options);
20
+    choices_init(&choices, &default_options);
21
+}
22
+
23
+static void teardown(void *udata) {
24
+    (void)udata;
25
+    choices_destroy(&choices);
26
+}
12 27
 
13 28
 TEST test_choices_empty() {
14
-	choices_t choices;
15
-	choices_init(&choices, &default_options);
16 29
 	ASSERT_EQ(0, choices.size);
17 30
 	ASSERT_EQ(0, choices.available);
18 31
 	ASSERT_EQ(0, choices.selection);
... ...
@@ -23,14 +36,10 @@ TEST test_choices_empty() {
23 36
 	choices_next(&choices);
24 37
 	ASSERT_EQ(0, choices.selection);
25 38
 
26
-	choices_destroy(&choices);
27
-
28 39
 	PASS();
29 40
 }
30 41
 
31 42
 TEST test_choices_1() {
32
-	choices_t choices;
33
-	choices_init(&choices, &default_options);
34 43
 	choices_add(&choices, "tags");
35 44
 
36 45
 	choices_search(&choices, "");
... ...
@@ -50,14 +59,10 @@ TEST test_choices_1() {
50 59
 	ASSERT(!strcmp(choices_get(&choices, 0), "tags"));
51 60
 	ASSERT_EQ(NULL, choices_get(&choices, 1));
52 61
 
53
-	choices_destroy(&choices);
54
-
55 62
 	PASS();
56 63
 }
57 64
 
58 65
 TEST test_choices_2() {
59
-	choices_t choices;
60
-	choices_init(&choices, &default_options);
61 66
 	choices_add(&choices, "tags");
62 67
 	choices_add(&choices, "test");
63 68
 
... ...
@@ -100,17 +105,12 @@ TEST test_choices_2() {
100 105
 	ASSERT_STR_EQ("test", choices_get(&choices, 0));
101 106
 	ASSERT_STR_EQ("tags", choices_get(&choices, 1));
102 107
 
103
-	choices_destroy(&choices);
104
-
105 108
 	PASS();
106 109
 }
107 110
 
108 111
 TEST test_choices_without_search() {
109 112
 	/* Before a search is run, it should return no results */
110 113
 
111
-	choices_t choices;
112
-	choices_init(&choices, &default_options);
113
-
114 114
 	ASSERT_EQ(0, choices.available);
115 115
 	ASSERT_EQ(0, choices.selection);
116 116
 	ASSERT_EQ(0, choices.size);
... ...
@@ -123,27 +123,18 @@ TEST test_choices_without_search() {
123 123
 	ASSERT_EQ(1, choices.size);
124 124
 	ASSERT_EQ(NULL, choices_get(&choices, 0));
125 125
 
126
-	choices_destroy(&choices);
127
-
128 126
 	PASS();
129 127
 }
130 128
 
131 129
 /* Regression test for segfault */
132 130
 TEST test_choices_unicode() {
133
-	choices_t choices;
134
-	choices_init(&choices, &default_options);
135
-
136 131
 	choices_add(&choices, "Edmund Husserl - Méditations cartésiennes - Introduction a la phénoménologie.pdf");
137 132
 	choices_search(&choices, "e");
138 133
 
139
-	choices_destroy(&choices);
140 134
 	PASS();
141 135
 }
142 136
 
143 137
 TEST test_choices_large_input() {
144
-	choices_t choices;
145
-	choices_init(&choices, &default_options);
146
-
147 138
 	int N = 100000;
148 139
 	char *strings[N];
149 140
 
... ...
@@ -163,13 +154,12 @@ TEST test_choices_large_input() {
163 154
 		free(strings[i]);
164 155
 	}
165 156
 
166
-	choices_destroy(&choices);
167
-
168 157
 	PASS();
169 158
 }
170 159
 
171 160
 SUITE(choices_suite) {
172
-	options_init(&default_options);
161
+	SET_SETUP(setup, NULL);
162
+	SET_TEARDOWN(teardown, NULL);
173 163
 
174 164
 	RUN_TEST(test_choices_empty);
175 165
 	RUN_TEST(test_choices_1);
Browse code

Move test suites into separate files

John Hawthorn authored on 05/04/2017 05:52:53
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,180 @@
1
+#define _GNU_SOURCE
2
+#include <stdlib.h>
3
+#include <string.h>
4
+
5
+#include "../config.h"
6
+#include "options.h"
7
+#include "choices.h"
8
+
9
+#include "greatest/greatest.h"
10
+
11
+static options_t default_options;
12
+
13
+TEST test_choices_empty() {
14
+	choices_t choices;
15
+	choices_init(&choices, &default_options);
16
+	ASSERT_EQ(0, choices.size);
17
+	ASSERT_EQ(0, choices.available);
18
+	ASSERT_EQ(0, choices.selection);
19
+
20
+	choices_prev(&choices);
21
+	ASSERT_EQ(0, choices.selection);
22
+
23
+	choices_next(&choices);
24
+	ASSERT_EQ(0, choices.selection);
25
+
26
+	choices_destroy(&choices);
27
+
28
+	PASS();
29
+}
30
+
31
+TEST test_choices_1() {
32
+	choices_t choices;
33
+	choices_init(&choices, &default_options);
34
+	choices_add(&choices, "tags");
35
+
36
+	choices_search(&choices, "");
37
+	ASSERT_EQ(1, choices.available);
38
+	ASSERT_EQ(0, choices.selection);
39
+
40
+	choices_search(&choices, "t");
41
+	ASSERT_EQ(1, choices.available);
42
+	ASSERT_EQ(0, choices.selection);
43
+
44
+	choices_prev(&choices);
45
+	ASSERT_EQ(0, choices.selection);
46
+
47
+	choices_next(&choices);
48
+	ASSERT_EQ(0, choices.selection);
49
+
50
+	ASSERT(!strcmp(choices_get(&choices, 0), "tags"));
51
+	ASSERT_EQ(NULL, choices_get(&choices, 1));
52
+
53
+	choices_destroy(&choices);
54
+
55
+	PASS();
56
+}
57
+
58
+TEST test_choices_2() {
59
+	choices_t choices;
60
+	choices_init(&choices, &default_options);
61
+	choices_add(&choices, "tags");
62
+	choices_add(&choices, "test");
63
+
64
+	/* Empty search */
65
+	choices_search(&choices, "");
66
+	ASSERT_EQ(0, choices.selection);
67
+	ASSERT_EQ(2, choices.available);
68
+
69
+	choices_next(&choices);
70
+	ASSERT_EQ(1, choices.selection);
71
+	choices_next(&choices);
72
+	ASSERT_EQ(0, choices.selection);
73
+
74
+	choices_prev(&choices);
75
+	ASSERT_EQ(1, choices.selection);
76
+	choices_prev(&choices);
77
+	ASSERT_EQ(0, choices.selection);
78
+
79
+	/* Filtered search */
80
+	choices_search(&choices, "te");
81
+	ASSERT_EQ(1, choices.available);
82
+	ASSERT_EQ(0, choices.selection);
83
+	ASSERT_STR_EQ("test", choices_get(&choices, 0));
84
+
85
+	choices_next(&choices);
86
+	ASSERT_EQ(0, choices.selection);
87
+
88
+	choices_prev(&choices);
89
+	ASSERT_EQ(0, choices.selection);
90
+
91
+	/* No results */
92
+	choices_search(&choices, "foobar");
93
+	ASSERT_EQ(0, choices.available);
94
+	ASSERT_EQ(0, choices.selection);
95
+
96
+	/* Different order due to scoring */
97
+	choices_search(&choices, "ts");
98
+	ASSERT_EQ(2, choices.available);
99
+	ASSERT_EQ(0, choices.selection);
100
+	ASSERT_STR_EQ("test", choices_get(&choices, 0));
101
+	ASSERT_STR_EQ("tags", choices_get(&choices, 1));
102
+
103
+	choices_destroy(&choices);
104
+
105
+	PASS();
106
+}
107
+
108
+TEST test_choices_without_search() {
109
+	/* Before a search is run, it should return no results */
110
+
111
+	choices_t choices;
112
+	choices_init(&choices, &default_options);
113
+
114
+	ASSERT_EQ(0, choices.available);
115
+	ASSERT_EQ(0, choices.selection);
116
+	ASSERT_EQ(0, choices.size);
117
+	ASSERT_EQ(NULL, choices_get(&choices, 0));
118
+
119
+	choices_add(&choices, "test");
120
+
121
+	ASSERT_EQ(0, choices.available);
122
+	ASSERT_EQ(0, choices.selection);
123
+	ASSERT_EQ(1, choices.size);
124
+	ASSERT_EQ(NULL, choices_get(&choices, 0));
125
+
126
+	choices_destroy(&choices);
127
+
128
+	PASS();
129
+}
130
+
131
+/* Regression test for segfault */
132
+TEST test_choices_unicode() {
133
+	choices_t choices;
134
+	choices_init(&choices, &default_options);
135
+
136
+	choices_add(&choices, "Edmund Husserl - Méditations cartésiennes - Introduction a la phénoménologie.pdf");
137
+	choices_search(&choices, "e");
138
+
139
+	choices_destroy(&choices);
140
+	PASS();
141
+}
142
+
143
+TEST test_choices_large_input() {
144
+	choices_t choices;
145
+	choices_init(&choices, &default_options);
146
+
147
+	int N = 100000;
148
+	char *strings[N];
149
+
150
+	for(int i = 0; i < N; i++) {
151
+		asprintf(&strings[i], "%i", i);
152
+		choices_add(&choices, strings[i]);
153
+	}
154
+
155
+	choices_search(&choices, "12");
156
+
157
+	/* Must match `seq 0 99999 | grep '.*1.*2.*' | wc -l` */
158
+	ASSERT_EQ(8146, choices.available);
159
+
160
+	ASSERT_STR_EQ("12", choices_get(&choices, 0));
161
+
162
+	for(int i = 0; i < N; i++) {
163
+		free(strings[i]);
164
+	}
165
+
166
+	choices_destroy(&choices);
167
+
168
+	PASS();
169
+}
170
+
171
+SUITE(choices_suite) {
172
+	options_init(&default_options);
173
+
174
+	RUN_TEST(test_choices_empty);
175
+	RUN_TEST(test_choices_1);
176
+	RUN_TEST(test_choices_2);
177
+	RUN_TEST(test_choices_without_search);
178
+	RUN_TEST(test_choices_unicode);
179
+	RUN_TEST(test_choices_large_input);
180
+}