forked from gentoo-utils/gentoo-utils
compare letters before suffixes, and having a letter is greater than none
This commit is contained in:
@@ -407,12 +407,6 @@ impl Ord for Version {
|
||||
Ordering::Equal => (),
|
||||
}
|
||||
|
||||
match self.suffixes.cmp(&other.suffixes) {
|
||||
Ordering::Less => return Ordering::Less,
|
||||
Ordering::Greater => return Ordering::Greater,
|
||||
Ordering::Equal => (),
|
||||
}
|
||||
|
||||
match (self.letter, other.letter) {
|
||||
(Some(a), Some(b)) if a < b => return Ordering::Less,
|
||||
(Some(a), Some(b)) if a > b => return Ordering::Greater,
|
||||
@@ -423,6 +417,12 @@ impl Ord for Version {
|
||||
_ => unreachable!(),
|
||||
}
|
||||
|
||||
match self.suffixes.cmp(&other.suffixes) {
|
||||
Ordering::Less => return Ordering::Less,
|
||||
Ordering::Greater => return Ordering::Greater,
|
||||
Ordering::Equal => (),
|
||||
}
|
||||
|
||||
match (&self.rev, &other.rev) {
|
||||
(Some(a), Some(b)) => match a
|
||||
.get()
|
||||
@@ -866,4 +866,19 @@ mod test {
|
||||
|
||||
assert_cmp_display!(a, b, Ordering::Greater);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_fuzzer_cases() {
|
||||
let control = Version::parser()
|
||||
.parse_finished(InputIter::new("1.2.0a_alpha1_beta2-r1-8"))
|
||||
.unwrap();
|
||||
|
||||
for (version_str, expected) in [("1.2.0", Ordering::Greater)] {
|
||||
let version = Version::parser()
|
||||
.parse_finished(InputIter::new(version_str))
|
||||
.unwrap();
|
||||
|
||||
assert_cmp_display!(control, version, expected);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user