use small_morse::{encode, State}; #[test] fn case_independent() { let text_one = "The quick brown fox jumps over the lazy dog."; let text_two = " tHe qUICK brown FOX jUMps over thE LAzY dOg . "; let morse_code_one = encode(text_one).collect::>(); let morse_code_two = encode(text_two).collect::>(); assert_eq!(morse_code_one, morse_code_two); } #[test] fn correct_encoding() { let text = "Neat!"; let mut res = String::new(); for action in encode(text) { let s = if action.state == State::On { "-" } else { " " }; res += &s.repeat(action.duration as usize); } assert_eq!(res, "--- - - - --- --- --- - --- - --- ---"); }