Add doctests for experimental unit converter#8056
Open
sffc wants to merge 4 commits into
Open
Conversation
Adds detailed doctests to ConverterFactory, UnitsConverter, and the units module covering proportional, offset, and reciprocal conversions, as well as edge cases like incompatible units. Co-authored-by: Gemini <176961590+gemini-code-assist[bot]@users.noreply.github.com>
sffc
commented
Jun 10, 2026
Remove self-evident comments, move converter creation down, and remove redundant doctest. Co-authored-by: Gemini <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Member
Author
|
🤖 This comment is written by an AI agent working with @sffc The feedback on the PR has been addressed:
All doctests have been verified to pass locally. |
Simplify ConverterFactory doctest, add BigRational example to UnitsConverter, and remove redundant UnitsConverter::convert doctest. Co-authored-by: Gemini <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Demonstrates factory reuse by creating both meter-to-foot and foot-to-meter converters from the same factory instance. Co-authored-by: Gemini <176961590+gemini-code-assist[bot]@users.noreply.github.com>
younies
reviewed
Jun 10, 2026
| //! let converter = factory.converter::<f64>(&celsius, &fahrenheit).unwrap(); | ||
| //! | ||
| //! // 0°C is exactly 32°F. | ||
| //! assert!((converter.convert(&0.0) - 32.0).abs() < 1e-9); |
Member
There was a problem hiding this comment.
to calculate the precision, you should use something like:
Suggested change
| //! assert!((converter.convert(&0.0) - 32.0).abs() < 1e-9); | |
| //! assert!(((converter.convert(&0.0) - 32.0).abs())/32.0 < 1e-9); |
Member
There was a problem hiding this comment.
for precision:
Member
Author
There was a problem hiding this comment.
Acknowledged, but I'm hoping to just remove the error bars entirely after we land #8058
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.
This PR adds doctests showing the status quo for the unit converter in the
icu_experimentalcrate.🤖 This pull request was created by an AI agent working with @sffc.
Changelog
N/A (docs only)