diff --git a/src/test_utils.rs b/src/test_utils.rs index 5121b04..3526b49 100644 --- a/src/test_utils.rs +++ b/src/test_utils.rs @@ -9,6 +9,12 @@ fn test_normalize_str() { #[test] fn test_normalize_first_name() { + let out = normalize_first_name("jpp jpp".to_string()); + assert_eq!(out, "Jpp-Jpp"); + + let out = normalize_first_name("jean pierre".to_string()); + assert_eq!(out, "Jean-Pierre"); + let out = normalize_first_name("JEAN-PIERRE".to_string()); assert_eq!(out, "Jean-Pierre"); diff --git a/src/utils.rs b/src/utils.rs index 49bfe68..9651adc 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -70,10 +70,12 @@ pub fn capitalize(s: &str) -> String { } } +/// normalisation d'un prénom pub fn normalize_first_name(subject: String) -> String { subject + .trim() .to_lowercase() - .replace(' ', "") + .replace(' ', "-") .split('-') .map(capitalize) .collect::>()