Adding latest + tests

This commit is contained in:
2020-11-16 18:43:30 +00:00
parent ac978bcb43
commit 3ed6b9422d
3 changed files with 35 additions and 2 deletions

22
src/hands.rs Normal file
View File

@@ -0,0 +1,22 @@
pub fn handify(input: &str) -> String {
let input = input.to_uppercase();
let input = input.replace(" ", " 👏 ");
println!("{:?}", input.split_whitespace().collect::<Vec<&str>>());
input
}
#[test]
fn handify_test_no_trailing_spaces() {
let 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