34 lines
813 B
Rust
34 lines
813 B
Rust
#[must_use]
|
|
pub fn handify(input: &str) -> String {
|
|
let input = input.to_uppercase();
|
|
let input = input.trim().to_owned();
|
|
let mut input = input.replace(" ", " \u{1f44f} ");
|
|
if !input.is_empty() {
|
|
input = format!("\u{1f44f} {} \u{1f44f}", input);
|
|
}
|
|
input
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod test {
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn handify_test_no_trailing_spaces() {
|
|
let input = "hello world";
|
|
assert_eq!(handify(input), "\u{1f44f} HELLO \u{1f44f} WORLD \u{1f44f}");
|
|
}
|
|
|
|
#[test]
|
|
fn handify_test_with_trailing_spaces() {
|
|
let input = " hello world ";
|
|
assert_eq!(handify(input), "\u{1f44f} HELLO \u{1f44f} WORLD \u{1f44f}")
|
|
}
|
|
|
|
#[test]
|
|
fn handify_test_empty_string() {
|
|
let input = "";
|
|
assert_eq!(handify(input), "");
|
|
}
|
|
}
|