Adding hands functionality
This commit is contained in:
12
src/hands.rs
12
src/hands.rs
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user