Branch Coverage

srl_path.c
Criterion Covered Total %
branch 122 160 76.2


line true false branch
109 0 18 if (path == NULL) croak("Out of memory");
123 0 18 CLEAR_RESULTS(path);
124 18 0 CLEAR_ITERATOR(path);
18 0 CLEAR_ITERATOR(path);
132 0 19 CLEAR_RESULTS(path);
133 1 18 CLEAR_ITERATOR(path);
1 0 CLEAR_ITERATOR(path);
135 0 19 if (sv_isobject(src) && sv_isa(src, "Sereal::Path::Iterator")) {
0 0 if (sv_isobject(src) && sv_isa(src, "Sereal::Path::Iterator")) {
136 0 0 path->iter = INT2PTR(srl_iterator_ptr, SvIV((SV*) SvRV(src)));
138 19 0 } else if (SvPOK(src)) {
151 0 60 if (!path->iter) croak("No document to traverse");
156 0 60 CLEAR_RESULTS(path);
169 60 0 AV *results = path->results ? path->results : newAV();
183 0 219 if (srl_iterator_eof(aTHX_ iter)) return;
184 129 90 if (expr_idx > av_len(path->expr)) { /* scaned entiry expr */
194 36 54 if ((type & SRL_ITERATOR_INFO_HASH) == SRL_ITERATOR_INFO_HASH) {
197 54 0 } else if ((type & SRL_ITERATOR_INFO_ARRAY) == SRL_ITERATOR_INFO_ARRAY) {
234 36 0 loc_str = SvPV(loc, loc_len);
236 8 28 if (is_all(loc_str, loc_len)) { /* * */
238 5 23 } else if (is_list(loc_str, loc_len)) { /* [name1,name2] */
257 24 8 for (idx = 0; idx < length; idx += 2) {
278 12 5 while (next_item_in_list(list, list_len, &item, &item_len)) {
280 0 12 if (item_len == 0) continue;
285 12 0 if (srl_iterator_hash_exists(aTHX_ iter, item, item_len) != SRL_ITER_NOT_FOUND) {
301 21 2 if (srl_iterator_hash_exists(aTHX_ iter, str, str_len) != SRL_ITER_NOT_FOUND) {
319 54 0 loc_str = SvPV(loc, loc_len);
321 10 44 if (is_all(loc_str, loc_len)) { /* * */
323 27 17 } else if (is_number(loc_str, loc_len)) { /* [10] */
325 12 5 } else if (is_list(loc_str, loc_len)) { /* [0,1,2] */
327 5 0 } else if (is_range(loc_str, loc_len, (int*) &range)) { /* [start:stop:step] */
342 37 10 for (idx = 0; idx < length; ++idx) {
365 34 12 while (next_item_in_list(list, list_len, &item, &item_len)) {
366 0 34 if (item_len == 0) continue;
372 34 0 if (srl_iterator_array_exists(aTHX_ iter, idx) != SRL_ITER_NOT_FOUND) {
393 1 4 start = start < 0 ? SRL_MAX(0, start + (I32) length) : SRL_MIN((I32) length, start);
394 0 5 stop = stop < 0 ? SRL_MAX(0, stop + (I32) length) : SRL_MIN((I32) length, stop);
395 5 0 step = step ? step : 1;
397 0 5 if (step < 0) croak("negative step in not supported");
402 9 5 for (idx = start; idx < stop; idx += step) {
419 22 5 if (srl_iterator_array_exists(aTHX_ iter, idx) != SRL_ITER_NOT_FOUND) {
435 0 70 if ((IV) expected_depth > depth) {
443 0 70 if (expected_idx < idx) {
454 60 30 return len == 1 ? str[0] == '*' : 0;
18 42 return len == 1 ? str[0] == '*' : 0;
461 91 28 for (i = 0; i < len; ++i) {
462 17 74 if (str[i] == ',') return 1;
479 76 21 for (i = 0, ndel = 0; i < len; ++i) {
480 28 48 if (str[i] == ':') {
481 2 26 if (ndel >= 2) return NULL;
493 1 0 valid = (start_len != 0 || stop_len != 0 || step_len != 0)
0 1 valid = (start_len != 0 || stop_len != 0 || step_len != 0)
494 4 0 && (start_len == 0 || is_number(str, start_len))
4 0 && (start_len == 0 || is_number(str, start_len))
495 4 0 && (stop_len == 0 || is_number(str + pos[0] + 1, stop_len))
4 0 && (stop_len == 0 || is_number(str + pos[0] + 1, stop_len))
496 1 4 && (step_len == 0 || is_number(str + pos[1] + 1, step_len));
3 1 && (step_len == 0 || is_number(str + pos[1] + 1, step_len));
2 1 && (step_len == 0 || is_number(str + pos[1] + 1, step_len));
498 2 3 if (!valid) return NULL;
504 3 0 out[0] = start_len == 0 ? 0 : atoi(ptr); /* start */
505 3 0 out[1] = stop_len == 0 ? 0x7FFFFFFF : atoi(ptr+ pos[0] + 1); /* stop */
506 2 1 out[2] = step_len == 0 ? 1 : atoi(ptr + pos[1] + 1); /* step */
516 2 1 valid = (start_len != 0 || stop_len != 0)
517 9 2 && (start_len == 0 || is_number(str, pos[0]))
9 0 && (start_len == 0 || is_number(str, pos[0]))
518 3 9 && (stop_len == 0 || is_number(str + pos[0] + 1, stop_len));
7 4 && (stop_len == 0 || is_number(str + pos[0] + 1, stop_len));
6 1 && (stop_len == 0 || is_number(str + pos[0] + 1, stop_len));
520 2 10 if (!valid) return NULL;
525 8 2 out[0] = start_len == 0 ? 0 : atoi(ptr); /* start */
526 6 4 out[1] = stop_len == 0 ? 0x7FFFFFFF : atoi(ptr+ pos[0] + 1); /* stop */
540 15 56 if (*str == '-') {
545 89 52 for (i = 0; i < len; ++i) {
546 77 12 if (str[i] < '0' || str[i] > '9')
7 70 if (str[i] < '0' || str[i] > '9')
558 46 17 : list;
562 17 46 if (start_pos - list >= (ptrdiff_t) list_len) return 0;
566 85 17 while (list_len-- && *list != ',') list++;
56 29 while (list_len-- && *list != ',') list++;