Branch Coverage

cbor_free_encode.c
Criterion Covered Total %
branch 196 286 68.5


line true false branch
103 0 2 char * words[3] = { "Unrecognized", SvPV_nolen(value), NULL };
146 34 0 : _SORT(a)->is_utf8 > _SORT(b)->is_utf8 ? 1
147 28 6 : _SORT(a)->length < _SORT(b)->length ? -1
148 18 10 : _SORT(a)->length > _SORT(b)->length ? 1
149 16 2 : memcmp( _SORT(a)->buffer, _SORT(b)->buffer, _SORT(a)->length )
156 5 109 if (!tagged_stash) {
165 33 44710 if ( (len + encode_state->len) > encode_state->buflen ) {
179 6465 16897 if ( num < CBOR_LENGTH_SMALL ) {
184 676 16221 else if ( num <= 0xff ) {
190 15901 320 else if ( num <= 0xffff ) {
197 310 10 else if ( num <= 0xffffffffU ) {
218 12 2 if ( SvREFCNT(varref) > 1 ) {
223 18 6 while ( (this_ref = encode_state->reftracker[r++]) ) {
224 6 12 if (this_ref == varref) {
231 0 6 Renew( encode_state->reftracker, 1 + r, void * );
244 5 56 if (SvMAGICAL(hash)) {
247 1762 5 while (hv_iternext(hash)) count++;
259 1235 0 char *val = SvPOK(value) ? SvPVX(value) : SvPV_nolen(value);
0 0 char *val = SvPOK(value) ? SvPVX(value) : SvPV_nolen(value);
277 196 1039 _init_length_buffer( aTHX_
289 4 6 if (SvUTF8(value)) {
306 6 5 UTF8_DOWNGRADE_IF_NEEDED(encode_state, to_encode);
2 4 UTF8_DOWNGRADE_IF_NEEDED(encode_state, to_encode);
317 6 5 UTF8_DOWNGRADE_IF_NEEDED(encode_state, to_encode);
2 4 UTF8_DOWNGRADE_IF_NEEDED(encode_state, to_encode);
324 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);
331 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);
332 4 0 UTF8_DOWNGRADE_OR_CROAK(encode_state, key_sv);
336 0 0 if (string_type == CBOR_TYPE_UTF8) SvUTF8_on(key_sv);
344 2 20529 if (encode_state->recurse_count > MAX_ENCODE_RECURSE) {
353 1762 18767 SvGETMAGIC(value);
0 1762 SvGETMAGIC(value);
355 20094 435 if (!SvROK(value)) {
357 18755 1339 if (SvIOK(value)) {
362 42 18713 if (val < 0 && !SvUOK(value)) {
39 3 if (val < 0 && !SvUOK(value)) {
370 27 1312 else if (SvNOK(value)) {
373 3 24 if (Perl_isnan(val_nv)) {
376 6 18 else if (Perl_isinf(val_nv)) {
377 3 3 if (val_nv > 0) {
409 225 1087 else if (!SvOK(value)) {
225 0 else if (!SvOK(value)) {
225 0 else if (!SvOK(value)) {
432 114 321 else if (sv_isobject(value)) {
435 105 9 if (_get_tagged_stash() == stash) {
438 105 0 IV tagnum = SvIV(*tag);
442 8 1 else if (cbf_get_boolean_stash() == stash) {
443 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(
445 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,
454 245 76 else if (SVt_PVAV == SvTYPE(SvRV(value))) {
457 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 )) {
466 362 46 for (i=0; i
472 63 13 else if (SVt_PVHV == SvTYPE(SvRV(value))) {
475 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)) {
486 22 39 if (encode_state->is_canonical) {
491 42 18 while ( (h_entry = hv_iternext(hash)) ) {
492 0 42 heutf8 = HeUTF8(h_entry);
496 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)) {
497 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 );
500 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);
506 2 4 if (heutf8) {
507 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 );
510 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);
516 4 6 if (heutf8) {
517 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);
520 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 );
535 38 18 for (curkey=0; curkey < keyscount; ++curkey) {
536 13 25 _init_length_buffer( aTHX_ sortables[curkey].length, sortables[curkey].is_utf8 ? CBOR_TYPE_UTF8 : CBOR_TYPE_BINARY, encode_state );
543 3053 35 while ( (h_entry = hv_iternext(hash)) ) {
553 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)) {
554 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 );
562 134 6 if (HeUTF8(h_entry)) {
2 138 if (HeUTF8(h_entry)) {
563 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 );
572 134 5 if (HeUTF8(h_entry)) {
2 137 if (HeUTF8(h_entry)) {
576 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 );
582 134 5 if (HeUTF8(h_entry)) {
2 137 if (HeUTF8(h_entry)) {
586 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 );
600 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)) {
603 4 8 if (!encode_state->reftracker || _check_reference( aTHX_ referent, encode_state)) {
2 2 if (!encode_state->reftracker || _check_reference( aTHX_ referent, encode_state)) {
637 2 16965 if (flags & ENCODE_FLAG_PRESERVE_REFS) {