Skip to content

Commit

Permalink
Add dedicated tests for the max local version sentinel (#8869)
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed Nov 6, 2024
1 parent bba1d4e commit e673e74
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions crates/uv-pep440/src/version/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1149,6 +1149,39 @@ fn ordering() {
}
}

#[test]
fn local_sentinel_version() {
let sentinel = Version::new([1, 0]).with_local(LocalVersion::Max);

// Ensure that the "max local version" sentinel is less than the following versions.
let versions = &["1.0.post0", "1.1"];

for greater in versions {
let greater = greater.parse::<Version>().unwrap();
assert_eq!(
sentinel.cmp(&greater),
Ordering::Less,
"less: {:?}\ngreater: {:?}",
greater.as_bloated_debug(),
sentinel.as_bloated_debug(),
);
}

// Ensure that the "max local version" sentinel is greater than the following versions.
let versions = &["1.0", "1.0.a0", "1.0+local"];

for less in versions {
let less = less.parse::<Version>().unwrap();
assert_eq!(
sentinel.cmp(&less),
Ordering::Greater,
"less: {:?}\ngreater: {:?}",
sentinel.as_bloated_debug(),
less.as_bloated_debug()
);
}
}

#[test]
fn min_version() {
// Ensure that the `.min` suffix precedes all other suffixes.
Expand Down

0 comments on commit e673e74

Please sign in to comment.