From 049fc15b914c28749bfe399906865c7459d28772 Mon Sep 17 00:00:00 2001 From: Joris Date: Sat, 20 Jan 2024 12:58:29 +0100 Subject: Test serialization --- src/util/serialization.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/util/serialization.rs b/src/util/serialization.rs index 61b3a83..189a41a 100644 --- a/src/util/serialization.rs +++ b/src/util/serialization.rs @@ -8,3 +8,21 @@ pub fn line_to_words(line: &str) -> Vec { pub fn words_to_line(words: &[String]) -> String { words.join(" | ") } + +#[cfg(test)] +mod tests { + + use super::*; + + #[test] + fn test_line_to_words() { + assert_eq!(line_to_words("a"), vec!("a")); + assert_eq!(line_to_words("a | b | c"), vec!("a", "b", "c")); + } + + #[test] + fn test_words_to_line() { + assert_eq!(words_to_line(&["a".to_string()]), "a"); + assert_eq!(words_to_line(&["a".to_string(), "b".to_string(), "c".to_string()]), "a | b | c"); + } +} -- cgit v1.2.3