| ... | ... |
@@ -62,41 +62,41 @@ TEST test_relative_scores() {
|
| 62 | 62 |
|
| 63 | 63 |
TEST test_exact_scores() {
|
| 64 | 64 |
/* Exact match is SCORE_MAX */ |
| 65 |
- ASSERT(match("abc", "abc") == SCORE_MAX);
|
|
| 66 |
- ASSERT(match("aBc", "abC") == SCORE_MAX);
|
|
| 65 |
+ ASSERT_EQ(SCORE_MAX, match("abc", "abc"));
|
|
| 66 |
+ ASSERT_EQ(SCORE_MAX, match("aBc", "abC"));
|
|
| 67 | 67 |
|
| 68 | 68 |
/* Empty query always results in SCORE_MIN */ |
| 69 |
- ASSERT(match("", "") == SCORE_MIN);
|
|
| 70 |
- ASSERT(match("", "a") == SCORE_MIN);
|
|
| 71 |
- ASSERT(match("", "bb") == SCORE_MIN);
|
|
| 69 |
+ ASSERT_EQ(SCORE_MIN, match("", ""));
|
|
| 70 |
+ ASSERT_EQ(SCORE_MIN, match("", "a"));
|
|
| 71 |
+ ASSERT_EQ(SCORE_MIN, match("", "bb"));
|
|
| 72 | 72 |
|
| 73 | 73 |
/* Gaps */ |
| 74 |
- ASSERT(match("a", "*a") == SCORE_GAP_LEADING);
|
|
| 75 |
- ASSERT(match("a", "*ba") == SCORE_GAP_LEADING*2);
|
|
| 76 |
- ASSERT(match("a", "**a*") == SCORE_GAP_LEADING*2 + SCORE_GAP_TRAILING);
|
|
| 77 |
- ASSERT(match("a", "**a**") == SCORE_GAP_LEADING*2 + SCORE_GAP_TRAILING*2);
|
|
| 78 |
- ASSERT(match("aa", "**aa**") == SCORE_GAP_LEADING*2 + SCORE_MATCH_CONSECUTIVE + SCORE_GAP_TRAILING*2);
|
|
| 79 |
- ASSERT(match("aa", "**a*a**") == SCORE_GAP_LEADING + SCORE_GAP_LEADING + SCORE_GAP_INNER + SCORE_GAP_TRAILING + SCORE_GAP_TRAILING);
|
|
| 74 |
+ ASSERT_EQ(SCORE_GAP_LEADING, match("a", "*a"));
|
|
| 75 |
+ ASSERT_EQ(SCORE_GAP_LEADING*2, match("a", "*ba"));
|
|
| 76 |
+ ASSERT_EQ(SCORE_GAP_LEADING*2 + SCORE_GAP_TRAILING, match("a", "**a*"));
|
|
| 77 |
+ ASSERT_EQ(SCORE_GAP_LEADING*2 + SCORE_GAP_TRAILING*2, match("a", "**a**"));
|
|
| 78 |
+ ASSERT_EQ(SCORE_GAP_LEADING*2 + SCORE_MATCH_CONSECUTIVE + SCORE_GAP_TRAILING*2, match("aa", "**aa**"));
|
|
| 79 |
+ ASSERT_EQ(SCORE_GAP_LEADING + SCORE_GAP_LEADING + SCORE_GAP_INNER + SCORE_GAP_TRAILING + SCORE_GAP_TRAILING, match("aa", "**a*a**"));
|
|
| 80 | 80 |
|
| 81 | 81 |
/* Consecutive */ |
| 82 |
- ASSERT(match("aa", "*aa") == SCORE_GAP_LEADING + SCORE_MATCH_CONSECUTIVE);
|
|
| 83 |
- ASSERT(match("aaa", "*aaa") == SCORE_GAP_LEADING + SCORE_MATCH_CONSECUTIVE*2);
|
|
| 84 |
- ASSERT(match("aaa", "*a*aa") == SCORE_GAP_LEADING + SCORE_GAP_INNER + SCORE_MATCH_CONSECUTIVE);
|
|
| 82 |
+ ASSERT_EQ(SCORE_GAP_LEADING + SCORE_MATCH_CONSECUTIVE, match("aa", "*aa"));
|
|
| 83 |
+ ASSERT_EQ(SCORE_GAP_LEADING + SCORE_MATCH_CONSECUTIVE*2, match("aaa", "*aaa"));
|
|
| 84 |
+ ASSERT_EQ(SCORE_GAP_LEADING + SCORE_GAP_INNER + SCORE_MATCH_CONSECUTIVE, match("aaa", "*a*aa"));
|
|
| 85 | 85 |
|
| 86 | 86 |
/* Slash */ |
| 87 |
- ASSERT(match("a", "/a") == SCORE_GAP_LEADING + SCORE_MATCH_SLASH);
|
|
| 88 |
- ASSERT(match("a", "*/a") == SCORE_GAP_LEADING*2 + SCORE_MATCH_SLASH);
|
|
| 89 |
- ASSERT(match("aa", "a/aa") == SCORE_GAP_LEADING*2 + SCORE_MATCH_SLASH + SCORE_MATCH_CONSECUTIVE);
|
|
| 87 |
+ ASSERT_EQ(SCORE_GAP_LEADING + SCORE_MATCH_SLASH, match("a", "/a"));
|
|
| 88 |
+ ASSERT_EQ(SCORE_GAP_LEADING*2 + SCORE_MATCH_SLASH, match("a", "*/a"));
|
|
| 89 |
+ ASSERT_EQ(SCORE_GAP_LEADING*2 + SCORE_MATCH_SLASH + SCORE_MATCH_CONSECUTIVE, match("aa", "a/aa"));
|
|
| 90 | 90 |
|
| 91 | 91 |
/* Capital */ |
| 92 |
- ASSERT(match("a", "bA") == SCORE_GAP_LEADING + SCORE_MATCH_CAPITAL);
|
|
| 93 |
- ASSERT(match("a", "baA") == SCORE_GAP_LEADING*2 + SCORE_MATCH_CAPITAL);
|
|
| 94 |
- ASSERT(match("aa", "baAa") == SCORE_GAP_LEADING*2 + SCORE_MATCH_CAPITAL + SCORE_MATCH_CONSECUTIVE);
|
|
| 92 |
+ ASSERT_EQ(SCORE_GAP_LEADING + SCORE_MATCH_CAPITAL, match("a", "bA"));
|
|
| 93 |
+ ASSERT_EQ(SCORE_GAP_LEADING*2 + SCORE_MATCH_CAPITAL, match("a", "baA"));
|
|
| 94 |
+ ASSERT_EQ(SCORE_GAP_LEADING*2 + SCORE_MATCH_CAPITAL + SCORE_MATCH_CONSECUTIVE, match("aa", "baAa"));
|
|
| 95 | 95 |
|
| 96 | 96 |
/* Dot */ |
| 97 |
- ASSERT(match("a", ".a") == SCORE_GAP_LEADING + SCORE_MATCH_DOT);
|
|
| 98 |
- ASSERT(match("a", "*a.a") == SCORE_GAP_LEADING*3 + SCORE_MATCH_DOT);
|
|
| 99 |
- ASSERT(match("a", "*a.a") == SCORE_GAP_LEADING + SCORE_GAP_INNER + SCORE_MATCH_DOT);
|
|
| 97 |
+ ASSERT_EQ(SCORE_GAP_LEADING + SCORE_MATCH_DOT, match("a", ".a"));
|
|
| 98 |
+ ASSERT_EQ(SCORE_GAP_LEADING*3 + SCORE_MATCH_DOT, match("a", "*a.a"));
|
|
| 99 |
+ ASSERT_EQ(SCORE_GAP_LEADING + SCORE_GAP_INNER + SCORE_MATCH_DOT, match("a", "*a.a"));
|
|
| 100 | 100 |
|
| 101 | 101 |
PASS(); |
| 102 | 102 |
} |
| ... | ... |
@@ -104,9 +104,9 @@ TEST test_exact_scores() {
|
| 104 | 104 |
TEST test_positions_1() {
|
| 105 | 105 |
size_t positions[3]; |
| 106 | 106 |
match_positions("amo", "app/models/foo", positions);
|
| 107 |
- ASSERT(positions[0] == 0); |
|
| 108 |
- ASSERT(positions[1] == 4); |
|
| 109 |
- ASSERT(positions[2] == 5); |
|
| 107 |
+ ASSERT_EQ(0, positions[0]); |
|
| 108 |
+ ASSERT_EQ(4, positions[1]); |
|
| 109 |
+ ASSERT_EQ(5, positions[2]); |
|
| 110 | 110 |
|
| 111 | 111 |
PASS(); |
| 112 | 112 |
} |
| ... | ... |
@@ -118,9 +118,9 @@ TEST test_positions_2() {
|
| 118 | 118 |
*/ |
| 119 | 119 |
size_t positions[4]; |
| 120 | 120 |
match_positions("amor", "app/models/order", positions);
|
| 121 |
- ASSERT(positions[0] == 0); |
|
| 122 |
- ASSERT(positions[1] == 4); |
|
| 123 |
- ASSERT(positions[2] == 11); |
|
| 121 |
+ ASSERT_EQ(0, positions[0]); |
|
| 122 |
+ ASSERT_EQ(4, positions[1]); |
|
| 123 |
+ ASSERT_EQ(11, positions[2]); |
|
| 124 | 124 |
|
| 125 | 125 |
PASS(); |
| 126 | 126 |
} |
| ... | ... |
@@ -128,8 +128,8 @@ TEST test_positions_2() {
|
| 128 | 128 |
TEST test_positions_3() {
|
| 129 | 129 |
size_t positions[2]; |
| 130 | 130 |
match_positions("as", "tags", positions);
|
| 131 |
- ASSERT(positions[0] == 1); |
|
| 132 |
- ASSERT(positions[1] == 3); |
|
| 131 |
+ ASSERT_EQ(1, positions[0]); |
|
| 132 |
+ ASSERT_EQ(3, positions[1]); |
|
| 133 | 133 |
|
| 134 | 134 |
PASS(); |
| 135 | 135 |
} |
| ... | ... |
@@ -137,8 +137,8 @@ TEST test_positions_3() {
|
| 137 | 137 |
TEST test_positions_4() {
|
| 138 | 138 |
size_t positions[2]; |
| 139 | 139 |
match_positions("as", "examples.txt", positions);
|
| 140 |
- ASSERT(positions[0] == 2); |
|
| 141 |
- ASSERT(positions[1] == 7); |
|
| 140 |
+ ASSERT_EQ(2, positions[0]); |
|
| 141 |
+ ASSERT_EQ(7, positions[1]); |
|
| 142 | 142 |
|
| 143 | 143 |
PASS(); |
| 144 | 144 |
} |
| ... | ... |
@@ -146,9 +146,9 @@ TEST test_positions_4() {
|
| 146 | 146 |
TEST test_positions_5() {
|
| 147 | 147 |
size_t positions[3]; |
| 148 | 148 |
match_positions("abc", "a/a/b/c/c", positions);
|
| 149 |
- ASSERT(positions[0] == 2); |
|
| 150 |
- ASSERT(positions[1] == 4); |
|
| 151 |
- ASSERT(positions[2] == 6); |
|
| 149 |
+ ASSERT_EQ(2, positions[0]); |
|
| 150 |
+ ASSERT_EQ(4, positions[1]); |
|
| 151 |
+ ASSERT_EQ(6, positions[2]); |
|
| 152 | 152 |
|
| 153 | 153 |
PASS(); |
| 154 | 154 |
} |
| ... | ... |
@@ -156,9 +156,9 @@ TEST test_positions_5() {
|
| 156 | 156 |
TEST test_positions_exact() {
|
| 157 | 157 |
size_t positions[3]; |
| 158 | 158 |
match_positions("foo", "foo", positions);
|
| 159 |
- ASSERT(positions[0] == 0); |
|
| 160 |
- ASSERT(positions[1] == 1); |
|
| 161 |
- ASSERT(positions[2] == 2); |
|
| 159 |
+ ASSERT_EQ(0, positions[0]); |
|
| 160 |
+ ASSERT_EQ(1, positions[1]); |
|
| 161 |
+ ASSERT_EQ(2, positions[2]); |
|
| 162 | 162 |
|
| 163 | 163 |
PASS(); |
| 164 | 164 |
} |
| ... | ... |
@@ -166,15 +166,15 @@ TEST test_positions_exact() {
|
| 166 | 166 |
TEST test_choices_empty() {
|
| 167 | 167 |
choices_t choices; |
| 168 | 168 |
choices_init(&choices, &default_options); |
| 169 |
- ASSERT(choices.size == 0); |
|
| 170 |
- ASSERT(choices.available == 0); |
|
| 171 |
- ASSERT(choices.selection == 0); |
|
| 169 |
+ ASSERT_EQ(0, choices.size); |
|
| 170 |
+ ASSERT_EQ(0, choices.available); |
|
| 171 |
+ ASSERT_EQ(0, choices.selection); |
|
| 172 | 172 |
|
| 173 | 173 |
choices_prev(&choices); |
| 174 |
- ASSERT(choices.selection == 0); |
|
| 174 |
+ ASSERT_EQ(0, choices.selection); |
|
| 175 | 175 |
|
| 176 | 176 |
choices_next(&choices); |
| 177 |
- ASSERT(choices.selection == 0); |
|
| 177 |
+ ASSERT_EQ(0, choices.selection); |
|
| 178 | 178 |
|
| 179 | 179 |
choices_destroy(&choices); |
| 180 | 180 |
|
| ... | ... |
@@ -187,21 +187,21 @@ TEST test_choices_1() {
|
| 187 | 187 |
choices_add(&choices, "tags"); |
| 188 | 188 |
|
| 189 | 189 |
choices_search(&choices, ""); |
| 190 |
- ASSERT(choices.available == 1); |
|
| 191 |
- ASSERT(choices.selection == 0); |
|
| 190 |
+ ASSERT_EQ(1, choices.available); |
|
| 191 |
+ ASSERT_EQ(0, choices.selection); |
|
| 192 | 192 |
|
| 193 | 193 |
choices_search(&choices, "t"); |
| 194 |
- ASSERT(choices.available == 1); |
|
| 195 |
- ASSERT(choices.selection == 0); |
|
| 194 |
+ ASSERT_EQ(1, choices.available); |
|
| 195 |
+ ASSERT_EQ(0, choices.selection); |
|
| 196 | 196 |
|
| 197 | 197 |
choices_prev(&choices); |
| 198 |
- ASSERT(choices.selection == 0); |
|
| 198 |
+ ASSERT_EQ(0, choices.selection); |
|
| 199 | 199 |
|
| 200 | 200 |
choices_next(&choices); |
| 201 |
- ASSERT(choices.selection == 0); |
|
| 201 |
+ ASSERT_EQ(0, choices.selection); |
|
| 202 | 202 |
|
| 203 | 203 |
ASSERT(!strcmp(choices_get(&choices, 0), "tags")); |
| 204 |
- ASSERT(choices_get(&choices, 1) == NULL); |
|
| 204 |
+ ASSERT_EQ(NULL, choices_get(&choices, 1)); |
|
| 205 | 205 |
|
| 206 | 206 |
choices_destroy(&choices); |
| 207 | 207 |
|
| ... | ... |
@@ -216,40 +216,40 @@ TEST test_choices_2() {
|
| 216 | 216 |
|
| 217 | 217 |
/* Empty search */ |
| 218 | 218 |
choices_search(&choices, ""); |
| 219 |
- ASSERT(choices.selection == 0); |
|
| 220 |
- ASSERT(choices.available == 2); |
|
| 219 |
+ ASSERT_EQ(0, choices.selection); |
|
| 220 |
+ ASSERT_EQ(2, choices.available); |
|
| 221 | 221 |
|
| 222 | 222 |
choices_next(&choices); |
| 223 |
- ASSERT(choices.selection == 1); |
|
| 223 |
+ ASSERT_EQ(1, choices.selection); |
|
| 224 | 224 |
choices_next(&choices); |
| 225 |
- ASSERT(choices.selection == 0); |
|
| 225 |
+ ASSERT_EQ(0, choices.selection); |
|
| 226 | 226 |
|
| 227 | 227 |
choices_prev(&choices); |
| 228 |
- ASSERT(choices.selection == 1); |
|
| 228 |
+ ASSERT_EQ(1, choices.selection); |
|
| 229 | 229 |
choices_prev(&choices); |
| 230 |
- ASSERT(choices.selection == 0); |
|
| 230 |
+ ASSERT_EQ(0, choices.selection); |
|
| 231 | 231 |
|
| 232 | 232 |
/* Filtered search */ |
| 233 | 233 |
choices_search(&choices, "te"); |
| 234 |
- ASSERT(choices.available == 1); |
|
| 235 |
- ASSERT(choices.selection == 0); |
|
| 234 |
+ ASSERT_EQ(1, choices.available); |
|
| 235 |
+ ASSERT_EQ(0, choices.selection); |
|
| 236 | 236 |
ASSERT_STR_EQ("test", choices_get(&choices, 0));
|
| 237 | 237 |
|
| 238 | 238 |
choices_next(&choices); |
| 239 |
- ASSERT(choices.selection == 0); |
|
| 239 |
+ ASSERT_EQ(0, choices.selection); |
|
| 240 | 240 |
|
| 241 | 241 |
choices_prev(&choices); |
| 242 |
- ASSERT(choices.selection == 0); |
|
| 242 |
+ ASSERT_EQ(0, choices.selection); |
|
| 243 | 243 |
|
| 244 | 244 |
/* No results */ |
| 245 | 245 |
choices_search(&choices, "foobar"); |
| 246 |
- ASSERT(choices.available == 0); |
|
| 247 |
- ASSERT(choices.selection == 0); |
|
| 246 |
+ ASSERT_EQ(0, choices.available); |
|
| 247 |
+ ASSERT_EQ(0, choices.selection); |
|
| 248 | 248 |
|
| 249 | 249 |
/* Different order due to scoring */ |
| 250 | 250 |
choices_search(&choices, "ts"); |
| 251 |
- ASSERT(choices.available == 2); |
|
| 252 |
- ASSERT(choices.selection == 0); |
|
| 251 |
+ ASSERT_EQ(2, choices.available); |
|
| 252 |
+ ASSERT_EQ(0, choices.selection); |
|
| 253 | 253 |
ASSERT_STR_EQ("test", choices_get(&choices, 0));
|
| 254 | 254 |
ASSERT_STR_EQ("tags", choices_get(&choices, 1));
|
| 255 | 255 |
|
| ... | ... |
@@ -264,17 +264,17 @@ TEST test_choices_without_search() {
|
| 264 | 264 |
choices_t choices; |
| 265 | 265 |
choices_init(&choices, &default_options); |
| 266 | 266 |
|
| 267 |
- ASSERT(choices.available == 0); |
|
| 268 |
- ASSERT(choices.selection == 0); |
|
| 269 |
- ASSERT(choices.size == 0); |
|
| 270 |
- ASSERT(choices_get(&choices, 0) == NULL); |
|
| 267 |
+ ASSERT_EQ(0, choices.available); |
|
| 268 |
+ ASSERT_EQ(0, choices.selection); |
|
| 269 |
+ ASSERT_EQ(0, choices.size); |
|
| 270 |
+ ASSERT_EQ(NULL, choices_get(&choices, 0)); |
|
| 271 | 271 |
|
| 272 | 272 |
choices_add(&choices, "test"); |
| 273 | 273 |
|
| 274 |
- ASSERT(choices.available == 0); |
|
| 275 |
- ASSERT(choices.selection == 0); |
|
| 276 |
- ASSERT(choices.size == 1); |
|
| 277 |
- ASSERT(choices_get(&choices, 0) == NULL); |
|
| 274 |
+ ASSERT_EQ(0, choices.available); |
|
| 275 |
+ ASSERT_EQ(0, choices.selection); |
|
| 276 |
+ ASSERT_EQ(1, choices.size); |
|
| 277 |
+ ASSERT_EQ(NULL, choices_get(&choices, 0)); |
|
| 278 | 278 |
|
| 279 | 279 |
choices_destroy(&choices); |
| 280 | 280 |
|
| ... | ... |
@@ -308,7 +308,7 @@ TEST test_choices_large_input() {
|
| 308 | 308 |
choices_search(&choices, "12"); |
| 309 | 309 |
|
| 310 | 310 |
/* Must match `seq 0 99999 | grep '.*1.*2.*' | wc -l` */ |
| 311 |
- ASSERT(choices.available == 8146); |
|
| 311 |
+ ASSERT_EQ(8146, choices.available); |
|
| 312 | 312 |
|
| 313 | 313 |
ASSERT_STR_EQ("12", choices_get(&choices, 0));
|
| 314 | 314 |
|