-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ondisk: Add compat deserializer for FchConsoleOutMode.
Fixes <#132>.
- Loading branch information
Showing
2 changed files
with
111 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#[cfg(feature = "serde")] | ||
const CURRENT_CONFIG_STR: &str = "\"Disabled\""; | ||
|
||
#[cfg(feature = "serde")] | ||
const COMPAT_CONFIG_STR: &str = r#"0x00"#; | ||
|
||
#[cfg(feature = "serde")] | ||
const INVALID_CONFIG_STR: &str = "\"Disabledx\""; | ||
|
||
#[cfg(feature = "serde")] | ||
#[test] | ||
#[allow(non_snake_case)] | ||
fn test_current_FchConsoleOutMode() { | ||
let mode: amd_apcb::FchConsoleOutMode = | ||
serde_yaml::from_str(&CURRENT_CONFIG_STR) | ||
.expect("configuration be valid JSON"); | ||
assert_eq!(mode, amd_apcb::FchConsoleOutMode::Disabled); | ||
} | ||
|
||
#[cfg(feature = "serde")] | ||
#[test] | ||
#[allow(non_snake_case)] | ||
fn test_compat_FchConsoleOutMode() { | ||
let mode: amd_apcb::FchConsoleOutMode = | ||
serde_yaml::from_str(&COMPAT_CONFIG_STR) | ||
.expect("configuration be valid JSON"); | ||
assert_eq!(mode, amd_apcb::FchConsoleOutMode::Disabled); | ||
} | ||
|
||
#[cfg(feature = "serde")] | ||
#[test] | ||
#[allow(non_snake_case)] | ||
fn test_invalid_FchConsoleOutMode() { | ||
match serde_yaml::from_str::<amd_apcb::FchConsoleOutMode>( | ||
&INVALID_CONFIG_STR, | ||
) { | ||
Ok(_) => { | ||
panic!("unexpected success"); | ||
} | ||
Err(_) => {} | ||
}; | ||
} |