Adding latest + tests
This commit is contained in:
@@ -3,7 +3,7 @@ use clap::{App, Arg};
|
||||
pub fn main() {
|
||||
let matches = App::new("Emojifier")
|
||||
.version("1.0")
|
||||
.author("Daniel T. <dtomlinson@panaetius.co.uk")
|
||||
.author("Daniel T. <dtomlinson@panaetius.co.uk>")
|
||||
.about("Applies Emoji effects to text")
|
||||
.arg(
|
||||
Arg::new("input")
|
||||
@@ -13,8 +13,18 @@ pub fn main() {
|
||||
)
|
||||
.arg(
|
||||
Arg::new("hands")
|
||||
.short('H')
|
||||
.long("hands")
|
||||
.takes_value(false)
|
||||
.about("TURNS 👏 YOUR 👏 TEXT 👏 INTO 👏 THIS"),
|
||||
)
|
||||
.get_matches();
|
||||
|
||||
if let Some(input) = matches.value_of("input") {
|
||||
println!("{}", crate::hands::handify(input));
|
||||
}
|
||||
|
||||
if matches.is_present("hands") {
|
||||
println!("{}", true)
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
@@ -1 +1,2 @@
|
||||
pub mod entrypoint;
|
||||
pub mod entrypoint;
|
||||
pub mod hands;
|
||||
|
||||
Reference in New Issue
Block a user