Repository navigation
Format YAML doubles with shortest round-trip and compare floats numerically in YamlMatcher - #2478
Open
copybara-service[bot] wants to merge 1 commit into
Open
copybara-service[bot] wants to merge 1 commit into
copybara-service[bot] wants to merge 1 commit into
Conversation
…ically in YamlMatcher - Update `EnvConfigToYaml` to serialize `double` variable defaults using `std::to_chars` (`std::chars_format::general`) with a `%.17g` fallback and YAML 1.2 `.nan`/`.inf`/`-.inf` literals, avoiding trailing precision noise (e.g., `3.1400000000000001`) while preserving full IEEE-754 precision. - Update `EqualsYaml` in `yaml_matcher.cc` to compare unquoted/`!!float` YAML float scalars numerically as `double` (with `NaN == NaN`), while keeping exact string comparison for quoted strings, `!!str`, and pure integers. - Add unit tests in `env_yaml_test.cc` and `yaml_matcher_test.cc`. PiperOrigin-RevId: 1028480496
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.
Format YAML doubles with shortest round-trip and compare floats numerically in YamlMatcher
EnvConfigToYamlto serializedoublevariable defaults usingstd::to_chars(std::chars_format::general) with a%.17gfallback andYAML 1.2
.nan/.inf/-.infliterals, avoiding trailing precision noise(e.g.,
3.1400000000000001) while preserving full IEEE-754 precision.EqualsYamlinyaml_matcher.ccto compare unquoted/!!floatYAMLfloat scalars numerically as
double(withNaN == NaN), while keepingexact string comparison for quoted strings,
!!str, and pure integers.env_yaml_test.ccandyaml_matcher_test.cc.