Branch Coverage

blib/lib/Image/ExifTool/WriteIPTC.pl
Criterion Covered Total %
branch 166 250 66.4


line true false branch
87 0 2 unless ($code)
88 0 0 if (($code = $val) =~ s/ESC */\e/gi) { }
106 45 250 if ($format =~ /^int(\d+)/) { }
250 0 elsif ($format =~ /^(string|digits|undef)\[?(\d+),?(\d*)\]?$/) { }
108 0 45 if ($bytes != 1 and $bytes != 2 and $bytes != 4)
112 4 41 unless (&Image::ExifTool::IsInt($val))
113 4 0 unless &Image::ExifTool::IsHex($val)
118 0 41 if $val
122 25 225 if ($fmt eq "digits")
123 0 25 unless $$valPtr =~ /^\d*$/
124 3 22 if ($len < $minlen and $len)
130 25 225 if (defined $minlen and $fmt ne "string")
131 25 0 unless $maxlen
132 0 25 if ($len < $minlen) { }
0 50 elsif ($len > $maxlen and not $et->{'OPTIONS'}{'IgnoreMinorErrors'}) { }
133 0 0 unless ($et->{'OPTIONS'}{'IgnoreMinorErrors'})
158 0 314 unless $format
159 41 273 if ($format =~ /^int(\d+)/) { }
252 21 elsif ($format =~ /^string/) { }
160 6 35 if ($read) { }
162 6 0 if ($len <= 8)
172 0 35 if ($len == 1) { }
33 2 elsif ($len == 2) { }
181 2 250 if ($rec == 1) { }
1 249 elsif ($$xlatPtr and $rec < 7 and $$valPtr =~ /[\x80-\xff]/) { }
182 2 0 if ($tagInfo->{'Name'} eq "CodedCharacterSet")
189 165 87 if (not $read and $format =~ /^string\[(\d+),?(\d*)\]$/)
192 1 164 unless $maxlen
193 0 165 if ($len < $minlen) { }
2 163 elsif ($len > $maxlen) { }
194 0 0 if ($et->Warn("String too short for IPTC:$tagInfo->{'Name'} (padded)", 2))
198 2 0 if ($et->Warn("IPTC:$tagInfo->{'Name'} exceeds length limit (truncated)", 2))
201 1 1 if (($$xlatPtr || $et->Options('Charset')) eq "UTF8")
218 0 12 unless ($val =~ s[^.*(\d{4})[-:/.]?(\d{2})[-:/.]?(\d{2}).*][$1$2$3]s)
232 1 0 if ($val =~ /(.*?)\b(\d{1,2})(:?)(\d{2})(:?)(\d{2})(\S*)\s*$/s and $3 || !$5) { }
235 1 0 if ($tz =~ /([+-]\d{1,2}):?(\d{2})/) { }
0 0 elsif ($tz =~ /Z/i) { }
242 0 0 if ($date and $date =~ /^(\d{4}):(\d{2}):(\d{2})\s*$/ and eval { do { require Time::Local } }) { }
274 0 11 if lc $val eq "now"
285 0 0 if ($val eq "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000") { }
0 0 elsif (length $val >= 16) { }
291 0 0 if $manu
312 0 0 if (@vals >= 4) { }
0 0 elsif ($val =~ /unknown/i) { }
337 25 0 unless (exists $et->{'EDIT_DIRS'}{$dirInfo->{'DirName'}} or $tagTablePtr eq \%Image::ExifTool::IPTC::Main and exists $et->{'EDIT_DIRS'}{'IPTC'})
341 0 25 if $verbose
345 22 18 unless ($dataPt)
355 1 39 if $xlat eq $et->Options("Charset")
358 22 18 unless (defined $dirLen)
360 22 0 unless defined $dataLen
364 0 17 if ($dirLen >= 4 and substr($$dataPt, $start, 1) ne "\34" and substr($$dataPt, $start + 3, 1) eq "\34")
377 0 268 unless $tagInfo->{'SubDirectory'}
378 0 268 unless my $table = $tagInfo->{'SubDirectory'}{'TagTable'}
389 2081 170 unless defined $record
390 44 126 unless defined $iptcInfo{$record}
423 248 39 if ($pos + 5 <= $dirEnd)
426 247 1 if ($id == 28) { }
427 0 247 if ($rec < $lastRec)
428 0 0 if ($rec == 0) { }
429 0 0 if $et->Warn("IPTC record 0 encountered, subsequent records ignored", 2)
434 0 0 if $et->Warn("IPTC doesn't conform to spec: Records out of sequence", 2)
439 0 247 if ($len & 32768)
441 0 0 if ($pos + $n <= $dirEnd and $n <= 8) { }
454 0 247 if $pos > $dirEnd
461 127 160 if ($writeRec or $addNow)
464 72 228 if ($addNow) { }
84 144 elsif (not defined $newRec or $newRec != $lastRec) { }
468 44 40 if (length $newData > $lastRecPos)
469 3 41 if ($allMandatory > 1) { }
39 2 elsif ($mandatory{$lastRec} and $tagTablePtr eq \%Image::ExifTool::IPTC::Main) { }
476 0 6 if $code & 4
477 3 3 if ($code & 3) == 1
479 3 0 if ($num)
481 0 3 if $verbose > 1
490 17 22 if $foundRec{$lastRec}{$mandTag}
491 22 0 unless ($subTablePtr)
493 0 22 unless $tagInfo and $tagInfo->{'SubDirectory'}
494 0 22 unless $tagInfo->{'SubDirectory'}{'TagTable'}
497 0 22 unless $tagInfo = $subTablePtr->{$mandTag}
511 40 44 unless defined $newRec
516 188 72 unless ($addNow)
520 18 170 if defined $rec and $rec <= $newRec
528 148 94 if ($found & 2) { }
32 62 elsif ($tagInfo->{'List'}) { }
530 76 72 unless $found & 4
533 2 30 $found ? :
30 2 if $found ? !$nvHash->{'CreateOnly'} : $nvHash->{'IsCreating'}
536 61 0 if not $found and $nvHash->{'IsCreating'}
538 167 75 if ($doSet)
540 163 4 if @values
546 40 153 if ($allMandatory)
548 33 7 unless $mandatory and $mandatory->{$newTag}
556 193 0 if ($len <= 32767) { }
567 72 170 if ($addNow)
569 3 69 if $writeRec
574 44 126 unless @{$iptcInfo{$newRec};}
576 58 69 if ($writeRec)
578 40 18 unless defined $rec
589 99 148 if ($tagInfo) { }
0 295 elsif ($rec == 1 and $tag == 90) { }
594 87 12 if $tagInfo->{'Format'} and $tagInfo->{'Format'} =~ /^string/
597 89 10 if ($et->IsOverwriting($nvHash, $val))
604 14 75 if $allMandatory
606 72 12 if ($nvHash->{'Value'} and @{$nvHash->{'Value'};} and @recordList and $recordList[0] == $rec and not $foundRec{$rec}{$tag} & 4)
619 20 138 if ($allMandatory)
621 8 12 unless ($mandatory and $mandatory->{$tag})
629 4 36 if ($tail < $dirEnd)
631 0 4 if ($pad =~ /[^\0]/)
632 0 0 if $et->Warn("Unrecognized data in IPTC padding", 2)
646 370 65 unless $et
654 60 1 unless defined $nvHash
655 0 1 unless &IsStandardIPTC(scalar $et->MetadataPath)
657 1 0 if $nvHash->{'DelValue'}
660 0 1 unless $new or $old
661 0 1 unless (eval { do { require Digest::MD5 } })
666 1 0 if ($new)
667 1 0 if (defined $newData) { }
671 0 0 if ($dirInfo->{'DirStart'} or length $$dataPt != $dirInfo->{'DirLen'})
677 1 0 if length $$dataPt
679 1 0 if ($old)
680 0 1 if ($new and not defined $newData) { }
1 0 elsif ($dirInfo->{'DataPt'}) { }
684 1 0 if ($dirInfo->{'DirStart'} or length $$dataPt != $dirInfo->{'DirLen'})
688 1 0 if length $$dataPt
694 0 38 if defined $newData and length $newData and $et->{'FORCE_WRITE'}{'IPTC'}