Skip to content

Commit

Permalink
Add test for Version parsing (#1825)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rua authored Feb 14, 2022
1 parent 2bc0ea4 commit c527319
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions vulkano/src/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,37 @@ mod tests {
};
assert!(v2 > v1);
}

#[test]
fn version_parse() {
assert!(matches!(
"1.1.1".parse::<Version>(),
Ok(Version {
major: 1,
minor: 1,
patch: 1,
})
));
assert!(matches!(
"1.1".parse::<Version>(),
Ok(Version {
major: 1,
minor: 1,
patch: 0,
})
));
assert!(matches!(
"1".parse::<Version>(),
Ok(Version {
major: 1,
minor: 0,
patch: 0,
})
));

assert!("".parse::<Version>().is_err());
assert!("1.1.1.1".parse::<Version>().is_err());
assert!("foobar".parse::<Version>().is_err());
assert!("1.bar".parse::<Version>().is_err());
}
}

0 comments on commit c527319

Please sign in to comment.