Branch Coverage

deps/libgit2/src/util/vector.c
Criterion Covered Total %
branch 75 148 50.6


line true false branch
21 1149 8 if (new_size < MIN_ALLOCSIZE)
23 8 0 else if (new_size <= (SIZE_MAX / 3) * 2)
35 0 5147 if (new_size == 0)
39 0 5147 GIT_ERROR_CHECK_ALLOC(new_contents);
49 25 0 if (v->_alloc_size >= size_hint)
56 0 424 GIT_ASSERT_ARG(v);
57 0 424 GIT_ASSERT_ARG(src);
61 1 423 v->_cmp = cmp ? cmp : src->_cmp;
64 1 423 if (cmp != src->_cmp)
67 393 31 if (src->length) {
69 0 393 GIT_ERROR_CHECK_ALLOC_MULTIPLY(&bytes, src->length, sizeof(void *));
0 393 GIT_ERROR_CHECK_ALLOC_MULTIPLY(&bytes, src->length, sizeof(void *));
71 0 393 GIT_ERROR_CHECK_ALLOC(v->contents);
81 0 9035 if (!v)
95 0 854 if (!v)
98 516 854 for (i = 0; i < v->length; ++i) {
108 0 3990 GIT_ASSERT_ARG(v);
123 9 0 if (size)
125 0 9 if (asize)
137 0 5828 GIT_ASSERT_ARG(v);
145 3049 2779 git_vector_set_sorted(v, v->length <= 1);
156 0 1552 GIT_ASSERT_ARG(v);
157 0 1552 GIT_ASSERT(v->_cmp);
159 16 1536 if (!git_vector_is_sorted(v))
170 7 1545 if (!git__bsearch(v->contents, v->length, element, v->_cmp, &pos) &&
7 0 if (!git__bsearch(v->contents, v->length, element, v->_cmp, &pos) &&
171 7 0 on_dup && (result = on_dup(&v->contents[pos], element)) < 0)
175 145 1400 if (pos < v->length)
187 568 7961 if (git_vector_is_sorted(v) || !v->_cmp)
0 568 if (git_vector_is_sorted(v) || !v->_cmp)
190 410 158 if (v->length > 1)
201 0 1955 GIT_ASSERT_ARG(v);
202 0 1955 GIT_ASSERT_ARG(key);
203 0 1955 GIT_ASSERT(key_lookup);
206 0 1955 if (!v->_cmp)
219 0 16 GIT_ASSERT_ARG(v);
220 0 16 GIT_ASSERT_ARG(key);
221 0 16 GIT_ASSERT(key_lookup);
223 29 11 for (i = 0; i < v->length; ++i) {
224 5 24 if (key_lookup(key, v->contents[i]) == 0) {
225 5 0 if (at_pos)
237 0 0 return (a == b) ? 0 : -1;
242 0 0 return git_vector_search2(at_pos, v, v->_cmp ? v->_cmp : strict_comparison, entry);
249 0 183 GIT_ASSERT_ARG(v);
251 0 183 if (idx >= v->length)
256 17 166 if (shift_count)
266 421 14 if (v->length > 0)
275 0 3 if (v->length <= 1)
279 3 0 cmp = v->_cmp ? v->_cmp : strict_comparison;
281 7 3 for (i = 0, j = 1 ; j < v->length; ++j)
282 3 4 if (!cmp(v->contents[i], v->contents[j])) {
283 3 0 if (git_free_cb)
300 25 39 for (i = 0, j = 0; j < v->length; ++j) {
303 25 0 if (!match(v, i, payload))
320 17 0 if (a != b) {
333 0 0 if (new_length > v->length)
346 0 0 GIT_ASSERT_ARG(insert_len > 0);
347 0 0 GIT_ASSERT_ARG(idx <= v->length);
349 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);
351 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)
367 0 0 GIT_ASSERT_ARG(remove_len > 0);
369 0 0 if (git__add_sizet_overflow(&end_idx, idx, remove_len))
372 0 0 GIT_ASSERT(end_idx <= v->length);
374 0 0 if (end_idx < v->length)
386 0 2 if (position + 1 > v->length) {
387 0 0 if (git_vector_resize_to(v, position + 1) < 0)
391 0 2 if (old != NULL)
403 0 0 if (!git_vector_is_sorted(v))
406 0 0 for (i = 1; i < v->length; ++i) {
407 0 0 if (v->_cmp(v->contents[i - 1], v->contents[i]) > 0)
418 0 5 if (v->length == 0)
424 0 5 while (a < b) {