Adding latest + tests
This commit is contained in:
22
src/hands.rs
Normal file
22
src/hands.rs
Normal 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
|
||||
Reference in New Issue
Block a user