diff --git a/src/semver.rs b/src/semver.rs index c39809f..9c30acb 100644 --- a/src/semver.rs +++ b/src/semver.rs @@ -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())), + } + ) + } +}