|
|
@ -38,16 +38,16 @@ where |
|
|
|
|
|
|
|
|
|
|
|
let output = wofi.wait_with_output().expect("Failed to read stdout"); |
|
|
|
let output = wofi.wait_with_output().expect("Failed to read stdout"); |
|
|
|
let choice = String::from_utf8_lossy(&output.stdout); |
|
|
|
let choice = String::from_utf8_lossy(&output.stdout); |
|
|
|
// FIXME: Remove trailing \n from choice.
|
|
|
|
let mut choice = String::from(choice); |
|
|
|
//println!("choice: {:?}", choice);
|
|
|
|
choice.pop(); // Remove trailing \n from choice.
|
|
|
|
map.get(&*choice).copied() |
|
|
|
map.get(&choice).copied() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#[test] |
|
|
|
#[test] |
|
|
|
|
|
|
|
#[ignore = "interactive test requiring user input"] |
|
|
|
fn test_wofi_select() { |
|
|
|
fn test_wofi_select() { |
|
|
|
let choices = vec!["a", "b", "c"]; |
|
|
|
let choices = vec!["a", "b", "c"]; |
|
|
|
let choice = wofi_select("Choose wisely", &choices); |
|
|
|
let choice = wofi_select("Choose wisely", &choices); |
|
|
|
println!("choice: {:?}", choice); |
|
|
|
|
|
|
|
assert!(choice.is_some()); |
|
|
|
assert!(choice.is_some()); |
|
|
|
assert!(choices.contains(choice.unwrap())); |
|
|
|
assert!(choices.contains(choice.unwrap())); |
|
|
|
} |
|
|
|
} |
|
|
|