Conversation
Add coverage for float('inf'), float('-inf'), float('nan'), and -0.0
in both parse_token_int() (TestParseTokenInt) and the Pydantic
boundary validator (TestSanitizeNonNumericTokens).
These values are already handled correctly by the implementation but
had no regression tests documenting the expected behavior.
Closes #895
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds regression coverage for edge-case IEEE 754 float values at both the parse_token_int() helper layer and the AssistantMessageData.outputTokens Pydantic boundary validator, ensuring special floats are rejected/normalized as intended.
Changes:
- Added parametrized tests asserting
parse_token_int()rejectsinf,-inf,nan, and-0.0. - Added validator tests asserting
AssistantMessageData.model_validate({"outputTokens": ...})maps those same values to0.
Contributor
There was a problem hiding this comment.
Low-impact test-only addition with good coverage. Adds regression tests for IEEE 754 special floats (inf, -inf, nan) and -0.0 in both parse_token_int() and the AssistantMessageData Pydantic boundary validator. Tests are well-structured, follow existing patterns, and verify correct behavior against the implementation. All 8 CI checks pass. Auto-approving for merge.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add test coverage for IEEE 754 special floats (
inf,-inf,nan) and-0.0inparse_token_int()and theAssistantMessageDataPydantic boundary validator.These values are already handled correctly by the implementation but had no regression tests documenting the expected behavior.
Tests added
TestParseTokenInt:test_special_float_returns_none-- parametrized withfloat('inf'),float('-inf'),float('nan')test_negative_zero_float_returns_none-- verifies-0.0is rejectedTestSanitizeNonNumericTokens:test_special_float_maps_to_zero-- parametrized withfloat('inf'),float('-inf'),float('nan')test_negative_zero_float_maps_to_zero-- verifies-0.0maps to0Closes #895