Branch Coverage

blib/lib/MP3/Tag/ID3v2.pm
Criterion Covered Total %
branch 409 726 56.3


line true false branch
170 72 59 if (exists $self->{'frameIDs'})
171 66 6 unless defined wantarray
174 0 22 if $basic and length $_ > 4
189 0 144 if ($self->{'major'} == 2) { }
0 144 elsif ($self->{'major'} == 4) { }
0 144 elsif ($self->{'major'} == 3 and $size > 255) { }
203 0 0 if ($pos + $headersize + $size > $self->{'data_size'} or not exists $MP3::Tag::ID3v2::long_names{substr $self->{'tag_data'}, $pos + $size, 4})
207 0 0 if ($pos + 20 + $fsize < $self->{'data_size'} and exists $MP3::Tag::ID3v2::long_names{substr $self->{'tag_data'}, $pos + 10 + $fsize, 4})
216 101 43 if (not $ID =~ /\000\000\000/) { }
218 0 101 if ($major == 2)
220 0 0 if (exists $MP3::Tag::ID3v2::v2names_to_v3{$ID})
226 17 84 if (exists $self->{'frames'}{$ID})
251 0 101 if $basic and length $_ > 4
325 54 673 unless exists $self->{'frameIDs'}
328 161 264 if wantarray and $self->{'extra_frames'} and length $fname == 4
333 386 341 unless defined $frame or $e
335 4 337 unless defined $frame
337 0 337 if ($frame->{'flags'}{'encryption'})
350 0 337 if ($frame->{'flags'}{'groupid'})
355 0 337 if ($frame->{'flags'}{'compression'})
359 0 0 if $usize = !length($result)
362 2 335 if (($raw ||= 0) eq "raw")
363 2 0 if wantarray
368 335 0 if (defined $format)
370 0 335 if $raw eq "array"
371 5 330 if $raw eq "array_nokey" or $raw eq "array_nodecode"
372 0 335 if $raw eq "array_nodecode"
373 5 326 if $raw eq "intact" or $raw eq "hash" or $as_arr
376 330 5 unless ($as_arr or $raw eq "hash")
378 329 1 if exists $result->{'encoding'}
379 129 201 if ($k == 1)
380 129 0 if (exists $result->{'Text'}) { }
0 0 elsif (exists $result->{'URL'}) { }
0 0 elsif ($fname =~ /^MCDI/) { }
390 224 111 if (wantarray) { }
417 0 26 unless defined $frame
418 15 11 unless ref $frame
420 11 0 if ($k == 5 and substr($fname, 0, 4) eq "APIC")
422 0 11 unless $frame->{'MIME type'} eq $self->_Data_to_MIME($frame->{'_Data'})
427 0 11 unless $k <= 4
428 11 0 if exists $frame->{'encoding'}
429 0 11 unless $k <= 3
431 11 0 if defined $l
432 0 11 unless $k <= 2
434 11 0 if defined $d
435 0 11 unless $k <= 1
437 11 0 if defined $l
438 11 0 if defined $d
456 0 0 if not $bin || ref $val and $descr =~ /^(MCDI|APIC)/
458 0 0 unless ref $val
466 0 0 $optnl{$_} ? :
467 0 0 @miss ? :
472 0 0 if $bin
475 0 0 $_ =~ /^_(?!encoding)/ ? :
482 0 0 unless $MP3::Tag::ID3v2::long_names{$short}
516 0 0 unless exists $self->{'frameIDs'}
517 0 0 unless exists $self->{'frames'}{$fname}
543 0 0 unless exists $self->{'frameIDs'}
544 0 0 unless exists $self->{'frames'}{$fname}
545 0 0 if (exists $self->{'frames'}{$fname}{'flags'}{$option}) { }
546 0 0 $value ? :
556 53 12 unless $a_APIC cmp $b_APIC
572 0 78 if ($frame->{'major'} < 3)
575 0 0 if $ignore_error
581 0 78 if ($frame->{'flags'}{'compression'} or $self->{'flags'}{'compress_all'})
583 0 0 unless $frame->{'flags'}{'unchanged'}
587 0 78 if ($frame->{'flags'}{'encryption'} or $self->{'flags'}{'encrypt_all'})
588 0 0 if ($frame->{'flags'}{'unchanged'}) { }
592 0 0 unless $ignore_error
598 0 78 if ($frame->{'flags'}{'group_id'})
599 0 0 unless $ignore_error
605 0 78 if ($self->get_config("id3v23_unsync")->[0] and $self->{'version'} == 3 && $self->get_config('id3v23_unsync_size_w')->[0] || $self->{'version'} >= 4)
633 0 0 if ($count++ > 999)
639 0 16 unless (open NEW, ">$tempfile")
650 0 16 if ($pos_old < $ins->[0])
652 0 0 $ins->[0] < 16384 ? :
654 0 0 $ins->[0] < 16384 ? :
660 1 15 if ($ins->[1])
673 0 16 unless (rename $tempfile, $mp3obj->{'filename'} or system("mv", $tempfile, $mp3obj->{'filename'}) == 0)
697 79 224 unless my($info, $name, @rest) = $self->get_frame($fname, $raw)
777 0 0 if $raw_ok and $self->{'raw_data'} and not $self->{'modified'} and not $update_file
780 0 33 if $self->{'major'} == 4 and not $self->get_config1("write_v24")
781 0 33 if ($self->{'major'} > 4)
791 0 33 unless defined $tag_data
794 0 33 if $tag_data =~ /[^\x00-\xFF]/
801 0 33 if $self->get_config("id3v23_unsync")->[0] and $tag_data =~ s/\xFF(?=[\x00\xE0-\xFF])/\377\000/g
803 0 33 if length $tag_data and "\377" eq substr($tag_data, -1, 1)
809 33 0 if ($update_file)
812 19 14 if ($o_tsize < $n_tsize or $self->get_config('id3v2_shrink')->[0]) { }
824 16 3 if ($o_tsize != $n_tsize) { }
826 0 16 unless insert_space($self, \@insert) == 0
835 0 33 if $add_padding < 0
836 33 0 if $update_file =~ /padding/
849 0 33 if $self->get_config1("id3v2_fix_encoding_on_write")
857 0 33 unless ($mp3obj->open("write"))
863 0 33 unless defined $tag
866 0 33 unless ($mp3obj->open("write"))
901 0 0 if ($count++ > 999)
907 0 0 if (open NEW, ">$tempfile") { }
916 0 0 unless (rename $tempfile, $mp3obj->{'filename'} or system("mv", $tempfile, $mp3obj->{'filename'}) == 0)
1001 1 67 unless exists $self->{'frameIDs'}
1003 0 68 unless defined $format
1008 0 68 unless (@data)
1015 67 1 if (@data < $args)
1019 65 2 if @data == $args - 1 - $opt || $split && @data <= $args - 1 - $opt and $format->[0]{'name'} eq "_encoding"
1020 3 64 if ($opt)
1022 0 1 if $format->[0]{'name'} eq "_encoding" and defined $data[0] and not $data[0] =~ /^[0-3]?$/
1026 3 65 if ($split and @data < $args)
1027 1 2 if ($MP3::Tag::ID3v2::back_splt{$fname}) { }
1033 1 0 if ($tail =~ s/^;//)
1042 0 0 if @data == $args + 1 and not defined $data[0] and $format->[0]{'name'} eq "_encoding"
1044 0 68 unless @data <= $args and @data >= $args - $opt
1046 65 3 if ($format->[0]{'name'} eq "_encoding" and not defined $data[0])
1052 65 3 if ($calc_enc)
1055 0 82 if $fs->{'encoded'} and $d[0] and $d[0] =~ /[^\x00-\xff]/
1056 122 65 unless $fs->{'name'} eq "_encoding"
1060 3 193 if $fs->{'optional'} and not @data
1061 65 128 if ($fs->{'name'} eq "_encoding")
1062 65 0 if ($calc_enc) { }
1063 0 65 $have_high ? :
1071 7 121 if ($fs->{'isnum'}) { }
100 21 elsif (exists $fs->{'len'} and not exists $fs->{'func'}) { }
0 42 elsif (exists $fs->{'mlen'} and $fs->{'mlen'} > 0) { }
1076 6 1 if (exists $fs->{'len'} and $fs->{'len'} > 0)
1078 3 3 if length $d < $fs->{'len'}
1080 1 6 if (exists $fs->{'mlen'} and $fs->{'mlen'} > 0)
1081 1 0 if length $d < $fs->{'mlen'}
1084 14 86 if ($fs->{'len'} > 0) { }
35 51 elsif ($fs->{'len'} == 0) { }
1086 1 13 if length $d < $fs->{'len'}
1091 0 0 if length $d < $fs->{'mlen'}
1093 1 127 if (exists $fs->{'re2b'})
1098 12 116 if (exists $fs->{'func_back'}) { }
9 107 elsif (exists $fs->{'func'}) { }
1101 8 1 if ($fs->{'small_max'})
1103 2 6 if $d =~ /^\d+$/
1107 82 46 if ($fs->{'encoded'})
1108 0 82 if ($encoding) { }
0 82 elsif (not $self->{'fixed_encoding'} and $self->get_config1('id3v2_fix_encoding_on_edit') and $e = $self->botched_encoding and do { require Encode; Encode::decode($e, $d) ne $d }) { }
1114 0 0 if ($calc_enc or $encode_utf8) { }
0 0 elsif ($encoding < 3) { }
1121 0 0 if $use_utf16le and $encoding == 1
1151 6 62 if (exists $self->{'frames'}{$fname})
1158 6 0 if $c > ($self->{'extra_frames'}{$ID} || 0)
1185 0 0 unless exists $self->{'frameIDs'}
1186 0 0 unless exists $self->{'frames'}{$fname}
1209 3 40 unless exists $self->{'frameIDs'}
1210 11 32 unless exists $self->{'frames'}{$fname}
1240 0 0 if not $expl and $fn =~ /^(GRID|TLEN)/
1241 0 0 if (($overwrite || 0) eq 'delete') { }
0 0 elsif (not $overwrite) { }
1244 0 0 if $to->frame_have($from->get_frame_descr($fn))
1250 0 0 if delete $fl{'groupid'}
1251 0 0 $keep_flags ? :
1286 0 0 if get_format($fname, "quiet")
1330 0 0 if length $fname == 3
1333 0 0 unless defined $format
1337 0 0 unless exists $_->{'name'}
1338 0 0 unless $_->{'name'} eq "_encoding"
1339 0 0 unless $reswanted
1341 0 0 if exists $MP3::Tag::ID3v2::field_map{$key}
1345 0 0 if $reswanted
1353 0 9 unless my $m = $MP3::Tag::ID3v2::field_map_back{my $t = "$fname$nfield"}
1354 7 2 if exists $m->{$v}
1356 0 2 unless my $m1 = $MP3::Tag::ID3v2::field_map{$t}
1357 2 0 if exists $m1->{$v}
1358 0 0 if $m->{'_FREE'}
1383 11 33 if (@_)
1385 0 11 if @_ == 1 and $_[0] eq ""
1390 15 18 unless @parts
1395 0 0 unless $part =~ /[.,;:\n\t]\s*$/
1396 0 0 unless $part =~ /\s$/
1422 2 20 if @_
1426 0 16 unless defined $comment
1427 11 5 unless exists $comment->{'Description'} and not length $comment->{'Description'}
1429 1 1 if defined $language and !exists $comment->{'Language'} || lc $comment->{'Language'} ne $language
1430 0 4 $check_have ? :
1432 18 0 if grep(($_ eq "TIT3"), $self->v2title_order)
1433 0 0 $check_have ? :
1469 20 1 unless my($comment, $short, $language) = @_
1476 0 1 unless defined $comment
1478 0 1 unless exists $comment->{'Description'} and $comment->{'Description'} eq $desc
1480 0 1 if defined $language and !exists $comment->{'Language'} || lc $comment->{'Language'} ne lc $language
1481 0 1 $c ? :
1485 0 1 if @_ == 1 and $_[0] eq ""
1486 0 1 unless defined $language
1488 0 1 unless defined $short
1580 46 286 if shift() or $l eq "XXX"
1590 37 0 if $res
1591 0 0 if $data =~ /^\xff[\xe0-\xff]/
1592 0 0 unless $force
1602 32 213 if (ref $descr eq 'HASH') { }
124 178 elsif (defined $descr and not ref $descr) { }
1609 41 204 $lang_special ? :
1612 169 76 if (defined $languages)
1613 106 63 unless ref $languages
1615 37 132 if ($lang_special) { }
1617 37 0 if ($m)
1620 37 0 if ($lang_special->[2])
1623 39 13 exists $m->{$_} ? :
1624 0 37 unless my $m1 = $MP3::Tag::ID3v2::field_map_back{"$fname$lang_field"}
1626 44 8 exists $m1->{$_} ? :
1639 169 76 if (defined $languages)
1643 28 238 if ($l =~ /^#(\d+)$/) { }
0 238 elsif (length $l > 3 and not $lang_special) { }
1644 1 27 if not $seen{$1}++ and $1 < @found_frames
1649 3 206 unless my $f = $found_frames[$c]
1654 119 87 if $l eq '' || ref $f && defined $f->{$lang_field} && $l eq &__to_lang($f->{$lang_field}, $lang_special) and not $seen{$c}++
1663 67 137 unless defined $descr
1666 89 36 if defined $f and ref $f and defined $f->{'Description'} and grep(($_ eq $f->{'Description'}), @$descr)
1668 27 218 unless $extract_content
1669 179 39 unless (@_)
1670 63 116 unless @select
1672 32 84 unless ref $res
1674 76 8 if exists $res->{'Description'} and defined $descr || $any_descr
1675 65 19 if exists $res->{$lang_field} and defined $languages
1676 84 0 if exists $res->{'encoding'}
1679 22 0 if $c == 2 and $ic == 5 and exists $res->{'MIME type'} and exists $res->{'_Data'} and $res->{'MIME type'} eq $self->_Data_to_MIME($res->{'_Data'})
1680 74 10 if ($c <= 1)
1681 52 22 if exists $res->{'Text'}
1682 0 22 if exists $res->{'URL'}
1683 22 0 if exists $res->{'_Data'}
1690 11 12 $c ? :
1692 15 24 unless @_ > 1 or defined $_[0]
1693 6 18 if (defined $languages) { }
1 17 elsif ($lang_special) { }
1694 3 3 if defined $languages_mangled
1703 4 20 if $lang_special and @_ == 1
1705 8 16 unless defined $descr
1707 1 23 if $MP3::Tag::ID3v2::embedded_Descr{$fname}
1709 0 24 unless $self->add_frame_split($fname, @$languages, @$descr, @_)
1785 152 44 if ($d =~ s/^(\w{4})(?:\(([^()]*(?:\([^()]+\)[^()]*)*)\))?(?:\[(.*)\])?$/$1/)
1786 51 43 $what > 1 && !@_ ? :
58 94 defined $2 ? :
1788 32 13 $what > 2 && !@_ ? :
107 45 defined $3 ? :
1856 2 21 if (@_)
1857 0 2 if defined $self->get_frame("TYER")
1858 0 2 if defined $self->get_frame("TDRC")
1859 0 2 if @_ == 1 and $_[0] eq ""
1870 18 3 unless ($y) = $self->get_frame("TDRC", "intact") or ($y) = $self->get_frame("TYER")
1872 0 3 unless $self->get_config("year_is_timestamp")->[0]
1875 2 1 $y =~ /-/ ? :
1898 14 40 if (@_)
1899 0 14 if defined $self->get_frame("TRCK")
1900 13 1 if @_ == 1 and not $_[0]
1930 12 15 if (@_)
1931 0 12 if defined $self->get_frame("TPE1")
1932 9 3 if @_ == 1 and $_[0] eq ""
1936 2 13 if ($a) = $self->get_frame("TPE1")
1937 0 13 if ($a) = $self->get_frame("TPE2")
1938 0 13 if ($a) = $self->get_frame("TCOM")
1939 0 13 if ($a) = $self->get_frame("TPE3")
1940 0 13 if ($a) = $self->get_frame("TEXT")
1964 14 15 if (@_)
1965 0 14 if defined $self->get_frame("TALB")
1966 14 0 if @_ == 1 and $_[0] eq ""
1970 0 15 if ($a) = $self->get_frame("TALB")
1971 15 0 if grep(($_ eq "TIT1"), $self->v2title_order)
1977 0 0 if $self->frame_have("TALB")
1978 0 0 if grep(($_ eq "TIT1"), $self->v2title_order)
1993 11 27 if (@_)
1994 7 4 if defined $self->get_frame("TCON")
1995 0 11 if @_ == 1 and $_[0] eq ""
1999 16 11 unless defined $g
2022 0 0 if (wantarray) { }
2059 100 1 if (defined $mp3obj)
2060 86 14 unless $mp3obj->is_open
2063 54 46 if $r_header and 10 == length $header
2072 44 57 if (defined $mp3obj and $self->read_header($header)) { }
2073 0 44 if ($create) { }
2080 0 44 if (defined $s and $s - 10 < $s1)
2088 1 43 if ($self->{'flags'}{'unsync'})
2094 0 44 if ($self->{'flags'}{'compress_all'})
2100 0 44 if ($self->{'flags'}{'extheader'})
2102 0 0 unless ($self->read_ext_header)
2107 0 44 if $self->{'footer_size'}
2110 8 36 $merge ? :
2114 9 36 if $merge
2115 44 1 unless length $z == length $d
2118 4 40 if defined $r and length $r < 10
2119 40 4 if $r_header and 10 <= length $d
2124 56 1 if defined $mp3obj
2125 16 41 if (defined $create and $create)
2140 54 31 if $header and $parent
2141 41 44 unless $new
2160 44 56 if (substr($header, 0, 3) eq "ID3")
2176 0 44 if ($major > $#MP3::Tag::ID3v2::supported_majors or $MP3::Tag::ID3v2::supported_majors[$major] == 0)
2180 0 0 if ($major > $#MP3::Tag::ID3v2::supported_majors) { }
2190 0 44 if ($major == 4 and $self->get_config1("prohibit_v24"))
2194 0 44 if ($revision != 0)
2202 1 351 if $_
2214 0 44 $self->{'flags'}{'footer'} ? :
2252 0 0 if ($self->{'major'} == 4) { }
2268 0 1105 if exists $rule->{'v3name'}
2269 2 1103 if $rule->{'optional'} and not length $data
2271 1 1102 if (exists $rule->{'mlen'}) { }
257 845 elsif ($rule->{'len'} == 0) { }
330 515 elsif ($rule->{'len'} == -1) { }
2274 0 257 if (exists $rule->{'encoded'} and $encoding =~ /^[12]$/) { }
2287 6 1097 unless (defined $found and $found ne "")
2289 0 6 if exists $rule->{'default'}
2293 331 772 if ($rule->{'name'} eq '_encoding') { }
2295 329 2 unless $arr == 1
2298 480 292 if (exists $rule->{'encoded'})
2299 0 480 if ($encoding > 3) { }
0 480 elsif ($encoding and not $trustencoding) { }
0 480 elsif ($encoding) { }
0 480 elsif (not $noDecode and $e = $self->botched_encoding) { }
2311 0 0 if ($decode_utf8) { }
0 0 elsif ($encoding < 3) { }
2326 10 762 if $rule->{'isnum'}
2328 757 15 unless ($arr)
2329 72 685 if exists $rule->{'func'}
2331 701 56 unless (exists $rule->{'data'} or not defined $found)
2337 21 736 if (exists $rule->{'re2'})
2344 757 15 unless $arr == 1
2348 330 5 unless $arr
2354 0 562 if $self->{'fixed_encoding'}
2355 562 0 unless my $enc = $self->get_config1("decode_encoding_v2")
2359 0 0 unless $self->get_config1("ignore_trusted_encoding0_v2") or not $self->frame_select("TXXX", "trusted_encoding0_v2")
2367 0 0 unless $self->botched_encoding
2371 0 0 unless defined $frame
2375 0 0 unless defined $format
2377 0 0 if exists $rule->{'v3name'}
2379 0 0 if $rule->{'name'} ne "_encoding"
2382 0 0 unless defined $e and not $e
2385 0 0 if join("\0\0\0", @$txts) ne join("\0\0\0", @$raw_txts)
2388 0 0 unless %fix
2395 0 0 unless $fix
2397 0 0 unless $self->change_frame($fname, @$txt)
2400 0 0 if $self->get_config1("id3v2_set_trusted_encoding0")
2415 427 414 if exists $MP3::Tag::ID3v2::format{$fname}
2418 0 0 unless defined $quiet
2454 0 169 $self->{'major'} == 4 ? :
2466 0 0 if ($set and exists $flagmap{$flag}) { }
0 0 elsif (not exists $flagmap{$flag}) { }
2546 6 52 if (defined $how)
2547 0 6 unless $how eq 1 and $byte eq 1
2553 0 52 if $index > $#pictypes
2566 6 0 if (defined $how)
2567 0 6 unless $how eq 1 and $data eq 1
2572 0 0 if $number > 8
2582 0 0 if (defined $how)
2583 0 0 unless $how eq 1 and $data eq 1
2588 0 0 if ($data eq '-->') { }
2600 6 19 if (defined $how)
2601 0 6 unless $how eq 1 and $data eq 1
2624 6 1 if (defined $how)
2625 0 6 unless $how eq 1 and $text eq 1
2639 0 1 if $text eq ""
2644 1 0 unless ($text =~ s[/1][MPEG 1/2 layer I])
2645 1 0 unless ($text =~ s[/2][MPEG 1/2 layer II])
2646 0 1 unless ($text =~ s[/3][MPEG 1/2 layer III])
2657 0 0 if $text eq ""
2658 0 0 if ($text =~ m[(?
2660 0 0 if ($found =~ s/DIG/Other digital Media/ or $found =~ /DAT/ or $found =~ /DCC/ or $found =~ /DVD/ or $found =~ s/MD/MiniDisc/ or $found =~ s/LD/Laserdisc/) { }
0 0 elsif ($found =~ /CD/) { }
0 0 elsif ($found =~ s/ANA/Other analog Media/) { }
0 0 elsif ($found =~ s/TT/Turntable records/) { }
0 0 elsif ($found =~ s/TV/Television/ or $found =~ s/VID/Video/ or $found =~ s/RAD/Radio/) { }
0 0 elsif ($found =~ s/TEL/Telephone/) { }
0 0 elsif ($found =~ s/REE/Reel/ or $found =~ s/MC/MC (normal cassette)/) { }