Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dns2utf8 committed Feb 25, 2018
1 parent 47e82af commit c90f0c3
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1276,6 +1276,13 @@ mod tests {

#[test]
fn test_new() {
if cfg!(feature = "v3") {
let u = Uuid::new(UuidVersion::Md5);
assert!(u.is_some(), "{:?}", u);
assert_eq!(u.unwrap().get_version().unwrap(), UuidVersion::Md5);
} else {
assert_eq!(Uuid::new(UuidVersion::Md5), None);
}
if cfg!(feature = "v4") {
let uuid1 = Uuid::new(UuidVersion::Random).unwrap();
let s = uuid1.simple().to_string();
Expand All @@ -1285,12 +1292,17 @@ mod tests {
} else {
assert!(Uuid::new(UuidVersion::Random).is_none());
}
if cfg!(feature = "v5") {
let u = Uuid::new(UuidVersion::Sha1);
assert!(u.is_some(), "{:?}", u);
assert_eq!(u.unwrap().get_version().unwrap(), UuidVersion::Sha1);
} else {
assert_eq!(Uuid::new(UuidVersion::Sha1), None);
}

// Test unsupported versions
assert_eq!(Uuid::new(UuidVersion::Mac), None);
assert_eq!(Uuid::new(UuidVersion::Dce), None);
assert_eq!(Uuid::new(UuidVersion::Md5), None);
assert_eq!(Uuid::new(UuidVersion::Sha1), None);
}

#[cfg(feature = "v1")]
Expand Down

0 comments on commit c90f0c3

Please sign in to comment.