diff --git a/src/hands.rs b/src/hands.rs index 333ec1c..f03a88d 100644 --- a/src/hands.rs +++ b/src/hands.rs @@ -1,8 +1,10 @@ pub fn handify(input: &str) -> String { let input = input.to_uppercase(); let input = input.trim().to_owned(); - let input = input.replace(" ", " 👏 "); - let input = format!("👏 {} 👏", input); + let mut input = input.replace(" ", " 👏 "); + if !input.is_empty() { + input = format!("👏 {} 👏", input); + } input } @@ -17,3 +19,9 @@ fn handify_test_with_trailing_spaces() { let input = " hello world "; assert_eq!(handify(input), "👏 HELLO 👏 WORLD 👏") } + +#[test] +fn handify_test_empty_string() { + let input = ""; + assert_eq!(handify(input), ""); +}