Add tests for RustOptimize
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
This commit is contained in:
parent
e6e2825bb0
commit
878eff1207
@ -875,7 +875,7 @@ fn default() -> StringOrBool {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
#[derive(Clone, Debug, Deserialize, PartialEq, Eq)]
|
||||
#[serde(untagged)]
|
||||
pub enum RustOptimize {
|
||||
#[serde(deserialize_with = "deserialize_and_validate_opt_level")]
|
||||
|
@ -178,3 +178,22 @@ fn get_toml(file: &Path) -> TomlConfig {
|
||||
}
|
||||
Config::parse_inner(&["check".to_owned()], get_toml);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rust_optimize() {
|
||||
let parse = |s| Config::parse_inner(&["check".to_owned()], |&_| toml::from_str(s).unwrap());
|
||||
|
||||
assert_eq!(parse("").rust_optimize.is_release(), true);
|
||||
assert_eq!(parse("rust.optimize = false").rust_optimize.is_release(), false);
|
||||
assert_eq!(parse("rust.optimize = true").rust_optimize.is_release(), true);
|
||||
assert_eq!(parse("rust.optimize = \"1\"").rust_optimize.get_opt_level(), Some("1".to_string()));
|
||||
assert_eq!(parse("rust.optimize = \"s\"").rust_optimize.get_opt_level(), Some("s".to_string()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic]
|
||||
fn invalid_rust_optimize() {
|
||||
Config::parse_inner(&["check".to_owned()], |&_| {
|
||||
toml::from_str("rust.optimize = \"a\"").unwrap()
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user