Improve VersionMap documentation and add comprehensive tests#3
Merged
Conversation
Merged
Contributor
Author
This stack of pull requests is managed by Graphite. Learn more about stacking. |
This was referenced May 23, 2025
9b3f645 to
2505633
Compare
03ade8b to
33f88fe
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR refines the VersionMap module by enhancing its documentation and substantially expanding test coverage.
- Clarifies the behavior of
insertwith alternate versions - Splits the previous monolithic test into focused test cases (basic ops, alternates, latest, removal)
- Adds thorough tests for
version_alternateacross pre-release, major, minor, and patch scenarios
Comments suppressed due to low confidence (2)
src/semver.rs:285
- [nitpick] The variable names
v1andv2are inconsistent with the earlierversion0..version3naming. Consider renaming them toversion1andversion2for clarity and consistency.
let v1 = Version::new(1, 0, 0);
src/semver.rs:296
- Consider adding an explicit test for
version_alternate(&Version::new(0, 0, 0))to verify and document the behavior when both major and minor are zero.
fn test_version_alternate_function() {
Comment on lines
+269
to
+271
| map.insert(Version::new(1, 0, 0), "v1.0.0"); | ||
| map.insert(Version::new(2, 0, 0), "v2.0.0"); | ||
| map.insert(Version::new(0, 1, 0), "v0.1.0"); |
There was a problem hiding this comment.
[nitpick] Tests mix the infallible insert API with the fallible try_insert. For consistency and clearer error handling, consider using try_insert in all test cases.
Suggested change
| map.insert(Version::new(1, 0, 0), "v1.0.0"); | |
| map.insert(Version::new(2, 0, 0), "v2.0.0"); | |
| map.insert(Version::new(0, 1, 0), "v0.1.0"); | |
| assert!(map.try_insert(Version::new(1, 0, 0), "v1.0.0").is_ok()); | |
| assert!(map.try_insert(Version::new(2, 0, 0), "v2.0.0").is_ok()); | |
| assert!(map.try_insert(Version::new(0, 1, 0), "v0.1.0").is_ok()); |
Code Coverage Report
Minimum allowed coverage is |
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.

Improved VersionMap tests and documentation
This PR enhances the
VersionMapimplementation by:insertmethod to clarify its behavior with alternatesversion_alternatefunction to verify behavior with: