Branch Coverage

cbor_free_encode.c
Criterion Covered Total %
branch 188 286 65.7


line true false branch
107 0 2 char * words[3] = { "Unrecognized", SvPV_nolen(value), NULL };
150 34 0 : _SORT(a)->is_utf8 > _SORT(b)->is_utf8 ? 1
151 28 6 : _SORT(a)->length < _SORT(b)->length ? -1
152 20 8 : _SORT(a)->length > _SORT(b)->length ? 1
153 14 6 : memcmp( _SORT(a)->buffer, _SORT(b)->buffer, _SORT(a)->length )
160 5 109 if (!tagged_stash) {
169 29 43092 if ( (len + encode_state->len) > encode_state->buflen ) {
183 5391 16893 if ( num < CBOR_LENGTH_SMALL ) {
188 672 16221 else if ( num <= 0xff ) {
194 15901 320 else if ( num <= 0xffff ) {
201 310 10 else if ( num <= 0xffffffffU ) {
222 12 2 if ( SvREFCNT(varref) > 1 ) {
227 18 6 while ( (this_ref = encode_state->reftracker[r++]) ) {
228 6 12 if (this_ref == varref) {
235 0 6 Renew( encode_state->reftracker, 1 + r, void * );
248 1 56 if (SvMAGICAL(hash)) {
251 1226 1 while (hv_iternext(hash)) count++;
263 1099 0 char *val = SvPOK(value) ? SvPVX(value) : SvPV_nolen(value);
0 0 char *val = SvPOK(value) ? SvPVX(value) : SvPV_nolen(value);
281 61 1038 _init_length_buffer( aTHX_
293 4 6 if (SvUTF8(value)) {
310 6 4 UTF8_DOWNGRADE_IF_NEEDED(encode_state, to_encode);
2 4 UTF8_DOWNGRADE_IF_NEEDED(encode_state, to_encode);
321 6 4 UTF8_DOWNGRADE_IF_NEEDED(encode_state, to_encode);
2 4 UTF8_DOWNGRADE_IF_NEEDED(encode_state, to_encode);
328 18 0 CBF_HeSVKEY_force(h_entry, key_sv);
0 18 CBF_HeSVKEY_force(h_entry, key_sv);
0 18 CBF_HeSVKEY_force(h_entry, key_sv);
335 4 0 CBF_HeSVKEY_force(h_entry, key_sv);
0 4 CBF_HeSVKEY_force(h_entry, key_sv);
4 0 CBF_HeSVKEY_force(h_entry, key_sv);
336 4 0 UTF8_DOWNGRADE_OR_CROAK(encode_state, key_sv);
340 0 0 if (string_type == CBOR_TYPE_UTF8) SvUTF8_on(key_sv);
348 2 19987 if (encode_state->recurse_count > MAX_ENCODE_RECURSE) {
357 1226 18761 SvGETMAGIC(value);
0 1226 SvGETMAGIC(value);
359 19556 431 if (!SvROK(value)) {
361 18219 1337 if (SvIOK(value)) {
366 42 18177 if (val < 0 && !SvUOK(value)) {
39 3 if (val < 0 && !SvUOK(value)) {
374 27 1310 else if (SvNOK(value)) {
377 3 24 if (Perl_isnan(val_nv)) {
380 6 18 else if (Perl_isinf(val_nv)) {
381 3 3 if (val_nv > 0) {
413 225 1085 else if (!SvOK(value)) {
225 0 else if (!SvOK(value)) {
225 0 else if (!SvOK(value)) {
436 114 317 else if (sv_isobject(value)) {
439 105 9 if (_get_tagged_stash() == stash) {
442 105 0 IV tagnum = SvIV(*tag);
446 8 1 else if (cbf_get_boolean_stash() == stash) {
447 8 0 _COPY_INTO_ENCODE(
0 8 _COPY_INTO_ENCODE(
0 8 _COPY_INTO_ENCODE(
0 8 _COPY_INTO_ENCODE(
8 0 _COPY_INTO_ENCODE(
449 0 0 SvTRUE(SvRV(value)) ? &CBOR_TRUE_U8 : &CBOR_FALSE_U8,
0 0 SvTRUE(SvRV(value)) ? &CBOR_TRUE_U8 : &CBOR_FALSE_U8,
0 0 SvTRUE(SvRV(value)) ? &CBOR_TRUE_U8 : &CBOR_FALSE_U8,
0 0 SvTRUE(SvRV(value)) ? &CBOR_TRUE_U8 : &CBOR_FALSE_U8,
0 0 SvTRUE(SvRV(value)) ? &CBOR_TRUE_U8 : &CBOR_FALSE_U8,
0 0 SvTRUE(SvRV(value)) ? &CBOR_TRUE_U8 : &CBOR_FALSE_U8,
0 0 SvTRUE(SvRV(value)) ? &CBOR_TRUE_U8 : &CBOR_FALSE_U8,
0 0 SvTRUE(SvRV(value)) ? &CBOR_TRUE_U8 : &CBOR_FALSE_U8,
8 0 SvTRUE(SvRV(value)) ? &CBOR_TRUE_U8 : &CBOR_FALSE_U8,
3 5 SvTRUE(SvRV(value)) ? &CBOR_TRUE_U8 : &CBOR_FALSE_U8,
0 3 SvTRUE(SvRV(value)) ? &CBOR_TRUE_U8 : &CBOR_FALSE_U8,
0 0 SvTRUE(SvRV(value)) ? &CBOR_TRUE_U8 : &CBOR_FALSE_U8,
5 3 SvTRUE(SvRV(value)) ? &CBOR_TRUE_U8 : &CBOR_FALSE_U8,
0 0 SvTRUE(SvRV(value)) ? &CBOR_TRUE_U8 : &CBOR_FALSE_U8,
458 245 72 else if (SVt_PVAV == SvTYPE(SvRV(value))) {
461 6 239 if (!encode_state->reftracker || _check_reference( aTHX_ (SV *)array, encode_state )) {
4 2 if (!encode_state->reftracker || _check_reference( aTHX_ (SV *)array, encode_state )) {
470 362 46 for (i=0; i
476 59 13 else if (SVt_PVHV == SvTYPE(SvRV(value))) {
479 4 55 if (!encode_state->reftracker || _check_reference( aTHX_ (SV *)hash, encode_state)) {
2 2 if (!encode_state->reftracker || _check_reference( aTHX_ (SV *)hash, encode_state)) {
490 22 35 if (encode_state->is_canonical) {
495 42 18 while ( (h_entry = hv_iternext(hash)) ) {
496 0 42 heutf8 = HeUTF8(h_entry);
500 26 0 if (heutf8 || !CBF_HeUTF8(h_entry)) {
0 26 if (heutf8 || !CBF_HeUTF8(h_entry)) {
0 0 if (heutf8 || !CBF_HeUTF8(h_entry)) {
26 0 if (heutf8 || !CBF_HeUTF8(h_entry)) {
26 0 if (heutf8 || !CBF_HeUTF8(h_entry)) {
0 26 if (heutf8 || !CBF_HeUTF8(h_entry)) {
0 0 if (heutf8 || !CBF_HeUTF8(h_entry)) {
22 4 if (heutf8 || !CBF_HeUTF8(h_entry)) {
501 0 22 STORE_SORTABLE_HASH_KEY( sortables[curkey], h_entry, key, key_length, heutf8 );
0 0 STORE_SORTABLE_HASH_KEY( sortables[curkey], h_entry, key, key_length, heutf8 );
504 4 0 STORE_UPGRADED_SORTABLE_HASH_KEY(sortables[curkey], h_entry);
0 4 STORE_UPGRADED_SORTABLE_HASH_KEY(sortables[curkey], h_entry);
0 4 STORE_UPGRADED_SORTABLE_HASH_KEY(sortables[curkey], h_entry);
4 0 STORE_UPGRADED_SORTABLE_HASH_KEY(sortables[curkey], h_entry);
510 2 4 if (heutf8) {
511 0 2 STORE_SORTABLE_HASH_KEY( sortables[curkey], h_entry, key, key_length, true );
0 0 STORE_SORTABLE_HASH_KEY( sortables[curkey], h_entry, key, key_length, true );
514 4 0 STORE_UPGRADED_SORTABLE_HASH_KEY(sortables[curkey], h_entry);
0 4 STORE_UPGRADED_SORTABLE_HASH_KEY(sortables[curkey], h_entry);
0 4 STORE_UPGRADED_SORTABLE_HASH_KEY(sortables[curkey], h_entry);
4 0 STORE_UPGRADED_SORTABLE_HASH_KEY(sortables[curkey], h_entry);
520 4 6 if (heutf8) {
521 4 0 STORE_DOWNGRADED_SORTABLE_HASH_KEY(sortables[curkey], h_entry, encode_state->string_encode_mode == CBF_STRING_ENCODE_UTF8);
0 4 STORE_DOWNGRADED_SORTABLE_HASH_KEY(sortables[curkey], h_entry, encode_state->string_encode_mode == CBF_STRING_ENCODE_UTF8);
4 0 STORE_DOWNGRADED_SORTABLE_HASH_KEY(sortables[curkey], h_entry, encode_state->string_encode_mode == CBF_STRING_ENCODE_UTF8);
4 0 STORE_DOWNGRADED_SORTABLE_HASH_KEY(sortables[curkey], h_entry, encode_state->string_encode_mode == CBF_STRING_ENCODE_UTF8);
0 0 STORE_DOWNGRADED_SORTABLE_HASH_KEY(sortables[curkey], h_entry, encode_state->string_encode_mode == CBF_STRING_ENCODE_UTF8);
524 0 6 STORE_SORTABLE_HASH_KEY( sortables[curkey], h_entry, key, key_length, encode_state->string_encode_mode == CBF_STRING_ENCODE_UTF8 );
0 0 STORE_SORTABLE_HASH_KEY( sortables[curkey], h_entry, key, key_length, encode_state->string_encode_mode == CBF_STRING_ENCODE_UTF8 );
539 38 18 for (curkey=0; curkey < keyscount; ++curkey) {
540 13 25 _init_length_buffer( aTHX_ sortables[curkey].length, sortables[curkey].is_utf8 ? CBOR_TYPE_UTF8 : CBOR_TYPE_BINARY, encode_state );
547 2517 31 while ( (h_entry = hv_iternext(hash)) ) {
558 1226 1275 if (HeUTF8(h_entry) || !CBF_HeUTF8(h_entry)) {
1226 0 if (HeUTF8(h_entry) || !CBF_HeUTF8(h_entry)) {
1274 1 if (HeUTF8(h_entry) || !CBF_HeUTF8(h_entry)) {
1226 1274 if (HeUTF8(h_entry) || !CBF_HeUTF8(h_entry)) {
1226 0 if (HeUTF8(h_entry) || !CBF_HeUTF8(h_entry)) {
1274 0 if (HeUTF8(h_entry) || !CBF_HeUTF8(h_entry)) {
2500 0 if (HeUTF8(h_entry) || !CBF_HeUTF8(h_entry)) {
1226 1274 if (HeUTF8(h_entry) || !CBF_HeUTF8(h_entry)) {
0 1226 if (HeUTF8(h_entry) || !CBF_HeUTF8(h_entry)) {
1260 14 if (HeUTF8(h_entry) || !CBF_HeUTF8(h_entry)) {
559 1226 1261 STORE_PLAIN_HASH_KEY( encode_state, h_entry, key, key_length, HeUTF8(h_entry) ? CBOR_TYPE_UTF8 : CBOR_TYPE_BINARY );
1226 0 STORE_PLAIN_HASH_KEY( encode_state, h_entry, key, key_length, HeUTF8(h_entry) ? CBOR_TYPE_UTF8 : CBOR_TYPE_BINARY );
1226 1261 STORE_PLAIN_HASH_KEY( encode_state, h_entry, key, key_length, HeUTF8(h_entry) ? CBOR_TYPE_UTF8 : CBOR_TYPE_BINARY );
1 2486 STORE_PLAIN_HASH_KEY( encode_state, h_entry, key, key_length, HeUTF8(h_entry) ? CBOR_TYPE_UTF8 : CBOR_TYPE_BINARY );
567 0 6 if (HeUTF8(h_entry)) {
2 4 if (HeUTF8(h_entry)) {
568 0 2 STORE_PLAIN_HASH_KEY( encode_state, h_entry, key, key_length, CBOR_TYPE_UTF8 );
0 0 STORE_PLAIN_HASH_KEY( encode_state, h_entry, key, key_length, CBOR_TYPE_UTF8 );
577 0 5 if (HeUTF8(h_entry)) {
2 3 if (HeUTF8(h_entry)) {
581 0 3 STORE_PLAIN_HASH_KEY( encode_state, h_entry, key, key_length, CBOR_TYPE_UTF8 );
0 0 STORE_PLAIN_HASH_KEY( encode_state, h_entry, key, key_length, CBOR_TYPE_UTF8 );
587 0 5 if (HeUTF8(h_entry)) {
2 3 if (HeUTF8(h_entry)) {
591 0 3 STORE_PLAIN_HASH_KEY( encode_state, h_entry, key, key_length, CBOR_TYPE_BINARY );
0 0 STORE_PLAIN_HASH_KEY( encode_state, h_entry, key, key_length, CBOR_TYPE_BINARY );
605 12 1 else if (encode_state->encode_scalar_refs && IS_SCALAR_REFERENCE(value)) {
12 0 else if (encode_state->encode_scalar_refs && IS_SCALAR_REFERENCE(value)) {
608 4 8 if (!encode_state->reftracker || _check_reference( aTHX_ referent, encode_state)) {
2 2 if (!encode_state->reftracker || _check_reference( aTHX_ referent, encode_state)) {
642 2 16959 if (flags & ENCODE_FLAG_PRESERVE_REFS) {