Branch Coverage

deps/libgit2/src/vector.c
Criterion Covered Total %
branch 77 156 49.3


line true false branch
21 1083 10 if (new_size < MIN_ALLOCSIZE)
23 10 0 else if (new_size <= (SIZE_MAX / 3) * 2)
35 0 4985 if (new_size == 0)
39 0 4985 GIT_ERROR_CHECK_ALLOC(new_contents);
49 25 0 if (v->_alloc_size >= size_hint)
56 431 0 assert(v && src);
0 431 assert(v && src);
60 0 431 v->_cmp = cmp ? cmp : src->_cmp;
63 0 431 if (cmp != src->_cmp)
66 400 31 if (src->length) {
68 0 400 GIT_ERROR_CHECK_ALLOC_MULTIPLY(&bytes, src->length, sizeof(void *));
0 400 GIT_ERROR_CHECK_ALLOC_MULTIPLY(&bytes, src->length, sizeof(void *));
70 0 400 GIT_ERROR_CHECK_ALLOC(v->contents);
80 0 8494 assert(v);
93 0 862 assert(v);
95 520 862 for (i = 0; i < v->length; ++i) {
105 0 3892 assert(v);
120 9 0 if (size)
122 0 9 if (asize)
134 0 5710 assert(v);
142 2979 2731 git_vector_set_sorted(v, v->length <= 1);
153 1467 0 assert(v && v->_cmp);
0 1467 assert(v && v->_cmp);
155 16 1451 if (!git_vector_is_sorted(v))
166 7 1460 if (!git__bsearch(v->contents, v->length, element, v->_cmp, &pos) &&
7 0 if (!git__bsearch(v->contents, v->length, element, v->_cmp, &pos) &&
167 7 0 on_dup && (result = on_dup(&v->contents[pos], element)) < 0)
171 144 1316 if (pos < v->length)
183 0 8262 assert(v);
185 578 7684 if (git_vector_is_sorted(v) || !v->_cmp)
0 578 if (git_vector_is_sorted(v) || !v->_cmp)
188 412 166 if (v->length > 1)
199 1833 0 assert(v && key && key_lookup);
1833 0 assert(v && key && key_lookup);
0 1833 assert(v && key && key_lookup);
202 0 1833 if (!v->_cmp)
215 12 0 assert(v && key && key_lookup);
12 0 assert(v && key && key_lookup);
0 12 assert(v && key && key_lookup);
217 29 7 for (i = 0; i < v->length; ++i) {
218 5 24 if (key_lookup(key, v->contents[i]) == 0) {
219 5 0 if (at_pos)
231 0 0 return (a == b) ? 0 : -1;
236 0 0 return git_vector_search2(at_pos, v, v->_cmp ? v->_cmp : strict_comparison, entry);
243 0 183 assert(v);
245 0 183 if (idx >= v->length)
250 17 166 if (shift_count)
260 421 14 if (v->length > 0)
269 0 3 if (v->length <= 1)
273 3 0 cmp = v->_cmp ? v->_cmp : strict_comparison;
275 7 3 for (i = 0, j = 1 ; j < v->length; ++j)
276 3 4 if (!cmp(v->contents[i], v->contents[j])) {
277 3 0 if (git_free_cb)
294 25 39 for (i = 0, j = 0; j < v->length; ++j) {
297 25 0 if (!match(v, i, payload))
306 0 843 assert(v);
315 17 0 assert(a && b);
0 17 assert(a && b);
317 17 0 if (a != b) {
330 0 0 if (new_length > v->length)
343 0 0 assert(insert_len > 0 && idx <= v->length);
0 0 assert(insert_len > 0 && idx <= v->length);
345 0 0 GIT_ERROR_CHECK_ALLOC_ADD(&new_length, v->length, insert_len);
0 0 GIT_ERROR_CHECK_ALLOC_ADD(&new_length, v->length, insert_len);
347 0 0 if (new_length > v->_alloc_size && resize_vector(v, new_length) < 0)
0 0 if (new_length > v->_alloc_size && resize_vector(v, new_length) < 0)
363 0 0 assert(remove_len > 0);
365 0 0 if (git__add_sizet_overflow(&end_idx, idx, remove_len))
368 0 0 assert(end_idx <= v->length);
370 0 0 if (end_idx < v->length)
382 0 2 if (position + 1 > v->length) {
383 0 0 if (git_vector_resize_to(v, position + 1) < 0)
387 0 2 if (old != NULL)
399 0 0 if (!git_vector_is_sorted(v))
402 0 0 for (i = 1; i < v->length; ++i) {
403 0 0 if (v->_cmp(v->contents[i - 1], v->contents[i]) > 0)
414 0 5 if (v->length == 0)
420 0 5 while (a < b) {