-
Notifications
You must be signed in to change notification settings - Fork 1
Improve VersionMap documentation and add comprehensive tests #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
9b3f645 to
2505633
Compare
03ade8b to
33f88fe
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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() {
| 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"); |
Copilot
AI
Jun 3, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[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.
| 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 |

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