Skip to content

Fix test normalization for integer tokens in space-delimited fields and numeric-string Software - #57

Closed
tonimelisma wants to merge 1 commit into
bep:mainfrom
tonimelisma:fix/test-infra-numeric-normalization
Closed

Fix test normalization for integer tokens in space-delimited fields and numeric-string Software#57
tonimelisma wants to merge 1 commit into
bep:mainfrom
tonimelisma:fix/test-infra-numeric-normalization

Conversation

@tonimelisma

Copy link
Copy Markdown
Contributor

Two small test infrastructure gaps discovered while adding HEIF support:

1. isSpaceDelimitedFloatRe regex too strict

The fuzzy float comparator for space-delimited fields (used for LensInfo,
PrimaryChromaticities, etc.) had regex ^(\d+\.\d+) (\d+\.\d+) which required
both the first and second token to contain a decimal point. LensInfo on some cameras
includes integer tokens (e.g. iPhone 15 Pro: "2.22 9 1.78 2.8" where 9 is the
max focal length in mm). The second token 9 has no decimal point, so the fuzzy
comparison was not applied and the test fell through to exact string comparison,
failing on float64 precision differences.

Fix: change to ^(\d+\.\d+)( \d+\.?\d*)+$ — first token still requires a decimal
(to avoid accidentally matching non-numeric strings), subsequent tokens may be integers.

2. ExifTool emits iOS software version as JSON number

ExifTool with -n outputs "Software": 26.3 (a JSON number) rather than
"Software": "26.3" (a string) when the software field contains a value that looks
like a number. After json.Unmarshal this becomes float64(26.3) in the golden
file, while imagemeta correctly returns string("26.3") (the EXIF Software tag
is defined as ASCII). The comparison failed on type mismatch.

Fix: add "Software" to the normalizeThem switch to convert float64 back to
its decimal string representation when ExifTool has emitted it as a number.

Two test infrastructure fixes:

1. The fuzzy float comparator regex for space-delimited fields (LensInfo,
PrimaryChromaticities, etc.) required both the first and second token to
contain a decimal point. Fields with integer tokens (e.g. LensInfo
"2.22 9 1.78 2.8" where 9 is the max focal length) fell through to exact
string comparison, failing on float64 precision differences.

Fix: allow subsequent tokens to be integers.

2. ExifTool with -n outputs numeric-looking software versions (e.g. iOS
"26.3") as JSON numbers rather than strings. After json.Unmarshal this
becomes float64(26.3) while imagemeta correctly returns string("26.3")
since EXIF Software is an ASCII field.

Fix: convert float64 back to string for Software in normalizeThem.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@bep

bep commented Feb 21, 2026

Copy link
Copy Markdown
Owner

This needs to fix a failing test case. As per my previous comment, if this is more practical to do as part of #58 that's fine. But in any case, we need to be able to remove this particular patch and have a test fail.

@bep

bep commented Feb 21, 2026

Copy link
Copy Markdown
Owner

I'll handle this in #58

@bep bep closed this Feb 21, 2026
@tonimelisma
tonimelisma deleted the fix/test-infra-numeric-normalization branch February 22, 2026 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants