Branch Coverage

cbor_free_encode.c
Criterion Covered Total %
branch 196 286 68.5


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 24 10 : _SORT(a)->length < _SORT(b)->length ? -1
152 20 4 : _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 33 44710 if ( (len + encode_state->len) > encode_state->buflen ) {
183 6465 16897 if ( num < CBOR_LENGTH_SMALL ) {
188 676 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 5 56 if (SvMAGICAL(hash)) {
251 1762 5 while (hv_iternext(hash)) count++;
263 1235 0 char *val = SvPOK(value) ? SvPVX(value) : SvPV_nolen(value);
0 0 char *val = SvPOK(value) ? SvPVX(value) : SvPV_nolen(value);
281 196 1039 _init_length_buffer( aTHX_
293 4 6 if (SvUTF8(value)) {
310 6 5 UTF8_DOWNGRADE_IF_NEEDED(encode_state, to_encode);
2 4 UTF8_DOWNGRADE_IF_NEEDED(encode_state, to_encode);
321 6 5 UTF8_DOWNGRADE_IF_NEEDED(encode_state, to_encode);
2 4 UTF8_DOWNGRADE_IF_NEEDED(encode_state, to_encode);
328 152 0 CBF_HeSVKEY_force(h_entry, key_sv);
134 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 20529 if (encode_state->recurse_count > MAX_ENCODE_RECURSE) {
357 1762 18767 SvGETMAGIC(value);
0 1762 SvGETMAGIC(value);
359 20094 435 if (!SvROK(value)) {
361 18755 1339 if (SvIOK(value)) {
366 42 18713 if (val < 0 && !SvUOK(value)) {
39 3 if (val < 0 && !SvUOK(value)) {
374 27 1312 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 1087 else if (!SvOK(value)) {
225 0 else if (!SvOK(value)) {
225 0 else if (!SvOK(value)) {
436 114 321 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 76 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 63 13 else if (SVt_PVHV == SvTYPE(SvRV(value))) {
479 4 59 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 39 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 3053 35 while ( (h_entry = hv_iternext(hash)) ) {
557 1360 1275 if (HeUTF8(h_entry) || !CBF_HeUTF8(h_entry)) {
1360 0 if (HeUTF8(h_entry) || !CBF_HeUTF8(h_entry)) {
1274 1 if (HeUTF8(h_entry) || !CBF_HeUTF8(h_entry)) {
1360 1274 if (HeUTF8(h_entry) || !CBF_HeUTF8(h_entry)) {
1360 0 if (HeUTF8(h_entry) || !CBF_HeUTF8(h_entry)) {
1274 0 if (HeUTF8(h_entry) || !CBF_HeUTF8(h_entry)) {
2634 0 if (HeUTF8(h_entry) || !CBF_HeUTF8(h_entry)) {
1360 1274 if (HeUTF8(h_entry) || !CBF_HeUTF8(h_entry)) {
0 1360 if (HeUTF8(h_entry) || !CBF_HeUTF8(h_entry)) {
1260 14 if (HeUTF8(h_entry) || !CBF_HeUTF8(h_entry)) {
558 1360 1261 STORE_PLAIN_HASH_KEY( encode_state, h_entry, key, key_length, HeUTF8(h_entry) ? CBOR_TYPE_UTF8 : CBOR_TYPE_BINARY );
1360 0 STORE_PLAIN_HASH_KEY( encode_state, h_entry, key, key_length, HeUTF8(h_entry) ? CBOR_TYPE_UTF8 : CBOR_TYPE_BINARY );
1360 1261 STORE_PLAIN_HASH_KEY( encode_state, h_entry, key, key_length, HeUTF8(h_entry) ? CBOR_TYPE_UTF8 : CBOR_TYPE_BINARY );
1 2620 STORE_PLAIN_HASH_KEY( encode_state, h_entry, key, key_length, HeUTF8(h_entry) ? CBOR_TYPE_UTF8 : CBOR_TYPE_BINARY );
566 134 6 if (HeUTF8(h_entry)) {
2 138 if (HeUTF8(h_entry)) {
567 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 );
576 134 5 if (HeUTF8(h_entry)) {
2 137 if (HeUTF8(h_entry)) {
580 134 3 STORE_PLAIN_HASH_KEY( encode_state, h_entry, key, key_length, CBOR_TYPE_UTF8 );
134 0 STORE_PLAIN_HASH_KEY( encode_state, h_entry, key, key_length, CBOR_TYPE_UTF8 );
586 134 5 if (HeUTF8(h_entry)) {
2 137 if (HeUTF8(h_entry)) {
590 134 3 STORE_PLAIN_HASH_KEY( encode_state, h_entry, key, key_length, CBOR_TYPE_BINARY );
134 0 STORE_PLAIN_HASH_KEY( encode_state, h_entry, key, key_length, CBOR_TYPE_BINARY );
604 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)) {
607 4 8 if (!encode_state->reftracker || _check_reference( aTHX_ referent, encode_state)) {
2 2 if (!encode_state->reftracker || _check_reference( aTHX_ referent, encode_state)) {
641 2 16965 if (flags & ENCODE_FLAG_PRESERVE_REFS) {