28 lines
651 B
Rust
28 lines
651 B
Rust
pub fn handify(input: &str) -> String {
|
|
let input = input.to_uppercase();
|
|
let input = input.trim().to_owned();
|
|
let mut input = input.replace(" ", " 👏 ");
|
|
if !input.is_empty() {
|
|
input = format!("👏 {} 👏", input);
|
|
}
|
|
input
|
|
}
|
|
|
|
#[test]
|
|
fn handify_test_no_trailing_spaces() {
|
|
let input = "hello world";
|
|
assert_eq!(handify(input), "👏 HELLO 👏 WORLD 👏");
|
|
}
|
|
|
|
#[test]
|
|
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), "");
|
|
}
|