Create a unit test for test parse player_settings from striing and fix the aaa_mode
match
This commit is contained in:
parent
5a1e37c3c2
commit
6b299b9fb8
2 changed files with 27 additions and 1 deletions
|
@ -75,7 +75,7 @@ impl FromStr for PlayerSettings {
|
|||
match key {
|
||||
"repeat" => repeat = value == "true",
|
||||
"shuffle" => shuffle = Shuffle::from_str(value)?,
|
||||
"aa_mode" => aa_mode = AAAMode::from_str(value)?,
|
||||
"aaa_mode" => aa_mode = AAAMode::from_str(value)?,
|
||||
"vol_left" => volume.left = value.parse().map_err(|e: ParseIntError| CmusError::UnknownError(e.to_string()))?,
|
||||
"vol_right" => volume.right = value.parse().map_err(|e: ParseIntError| CmusError::UnknownError(e.to_string()))?,
|
||||
_ => {}
|
||||
|
@ -124,6 +124,19 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_parse_player_settings_from_str() {
|
||||
let setting_sample = include_str!(
|
||||
"../../tests/samples/player_settings_mode-artist_vol-46_repeat-false_repeat_current-false_shuffle-tracks.txt");
|
||||
|
||||
let settings = PlayerSettings::from_str(setting_sample);
|
||||
|
||||
assert_eq!(settings, Ok(PlayerSettings {
|
||||
repeat: false,
|
||||
shuffle: Shuffle::Tracks,
|
||||
aa_mode: AAAMode::Artist,
|
||||
volume: Volume {
|
||||
left: 46,
|
||||
right: 46,
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
set aaa_mode artist
|
||||
set continue true
|
||||
set play_library true
|
||||
set play_sorted true
|
||||
set replaygain disabled
|
||||
set replaygain_limit true
|
||||
set replaygain_preamp 0.000000
|
||||
set repeat false
|
||||
set repeat_current false
|
||||
set shuffle tracks
|
||||
set softvol false
|
||||
set vol_left 46
|
||||
set vol_right 46
|
Loading…
Reference in a new issue