Add tests for SemVer parsing
This commit is contained in:
parent
8009575765
commit
825592175a
@ -85,3 +85,34 @@ impl PartialOrd for SemVer {
|
||||
Some(self.cmp(other))
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::num::NonZeroU16;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn from_str() {
|
||||
let mut s: SemVer = "1.2.3".parse().unwrap();
|
||||
assert_eq!(
|
||||
s,
|
||||
SemVer {
|
||||
major: 1,
|
||||
minor: 2,
|
||||
patch: 3,
|
||||
pre: PreRelease::None,
|
||||
}
|
||||
);
|
||||
s = "0.3.0_alpha4".parse().unwrap();
|
||||
assert_eq!(
|
||||
s,
|
||||
SemVer {
|
||||
major: 0,
|
||||
minor: 3,
|
||||
patch: 0,
|
||||
pre: PreRelease::Alpha(Some(NonZeroU16::new(4).unwrap())),
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user