Merge branch 'simple-enum' of git.hitchhiker-linux.org:jeang3nie/version-rs into simple-enum

This commit is contained in:
Nathan Fisher 2024-02-03 00:50:17 -05:00
commit b40178ede2

View File

@ -211,7 +211,7 @@ impl PartialOrd for Version {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use std::num::NonZeroU16; use std::{num::NonZeroU16, str::FromStr};
#[test] #[test]
fn from_str() { fn from_str() {
@ -272,4 +272,19 @@ mod tests {
let version: Version = s.parse().unwrap(); let version: Version = s.parse().unwrap();
assert_eq!(s, version.to_string()); assert_eq!(s, version.to_string());
} }
#[test]
fn cmp() {
let astr = "3.14.0-x86_64";
let bstr = "3.14.0_alpha1-x86_64";
let cstr = "3.14_alpha1-amd64";
let dstr = "3.14.0_beta3-x86_64";
let estr = "3.14.0_git_c3poxxx.1705881493-x86_64";
let fstr = "3.14.0_git_r2d2xxx.1705900000-x86_64";
assert!(Version::from_str(astr).unwrap() > Version::from_str(bstr).unwrap());
assert!(Version::from_str(cstr).unwrap() == Version::from_str(bstr).unwrap());
assert!(Version::from_str(cstr).unwrap() < Version::from_str(dstr).unwrap());
assert!(Version::from_str(dstr).unwrap() > Version::from_str(estr).unwrap());
assert!(Version::from_str(fstr).unwrap() > Version::from_str(estr).unwrap());
}
} }