forked from gentoo-utils/gentoo-utils
check if a OR b has leading zeros, and if so, strip and do ascii cmp
This commit is contained in:
@@ -293,7 +293,9 @@ impl Ord for VersionNumbers {
|
||||
|
||||
loop {
|
||||
match (a.next(), b.next()) {
|
||||
(Some(a), Some(b)) if a.get().starts_with("0") => {
|
||||
(Some(a), Some(b))
|
||||
if a.get().starts_with("0") || b.get().starts_with("0") =>
|
||||
{
|
||||
let a = a.get().trim_end_matches("0");
|
||||
let b = b.get().trim_end_matches("0");
|
||||
|
||||
@@ -765,4 +767,16 @@ mod test {
|
||||
|
||||
assert_cmp_display!(a, b, Ordering::Less);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_version_cmp_where_b_has_leading_zeros() {
|
||||
let a = Version::parser()
|
||||
.parse_finished(InputIter::new("1.2"))
|
||||
.unwrap();
|
||||
let b = Version::parser()
|
||||
.parse_finished(InputIter::new("1.054"))
|
||||
.unwrap();
|
||||
|
||||
assert_cmp_display!(a, b, Ordering::Greater);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user