Adding hands functionality

This commit is contained in:
2020-11-16 21:28:11 +00:00
parent 226c936e72
commit 56ca52fd1b
5 changed files with 229 additions and 15 deletions

View File

@@ -1,25 +1,19 @@
pub fn handify(input: &str) -> String {
let input = input.to_uppercase();
let input = input.trim().to_owned();
let input = input.replace(" ", " 👏 ");
println!("{:?}", input.split_whitespace().collect::<Vec<&str>>());
for i in input.split_whitespace().collect::<Vec<&str>>() {
println!("{:?}", i);
}
let input = format!("👏 {} 👏", input);
input
}
#[test]
fn handify_test_no_trailing_spaces() {
let input = "hello world";
assert_eq!(handify(input), "HELLO 👏 WORLD");
assert_eq!(handify(input), "👏 HELLO 👏 WORLD 👏");
}
#[test]
// NOTE: Failing because of trailing whitespace
fn handify_test_with_trailing_spaces() {
let input = " hello world ";
assert_eq!(handify(input), "👏 HELLO 👏 WORLD 👏")
}
// TODO: trim leading + tailing white space
// TODO: handle an empty string