From 27b3eefc1b791ed432b7722e582aa025475c3da1 Mon Sep 17 00:00:00 2001 From: Allister Isaiah Harvey <41553768+a-isaiahharvey@users.noreply.github.com> Date: Mon, 11 Mar 2024 13:17:20 -0400 Subject: [PATCH] fixed issue where morse doesn't convert add space when decrypting --- src/ciphers/morse_code.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/ciphers/morse_code.rs b/src/ciphers/morse_code.rs index 7efc204..6d5f88a 100644 --- a/src/ciphers/morse_code.rs +++ b/src/ciphers/morse_code.rs @@ -127,6 +127,10 @@ pub fn decrypt(text: &str) -> String { decrypted_text.push(*key); } } + + if *split == "/" { + decrypted_text.push(' '); + } } decrypted_text @@ -148,4 +152,12 @@ mod tests { let decrypted = decrypt(&encrypted); assert_eq!(text, decrypted); } + + #[test] + pub fn test_hello_world() { + let text = "hello world!"; + let encrypted = encrypt(text); + let decrypted = decrypt(&encrypted); + assert_eq!(text, decrypted); + } }