diff options
author | Joris | 2024-01-20 12:58:29 +0100 |
---|---|---|
committer | Joris | 2024-01-20 12:58:29 +0100 |
commit | 049fc15b914c28749bfe399906865c7459d28772 (patch) | |
tree | d3a15b9887c1a10c2be410d759edcf463e53aa10 /src | |
parent | 667dd6d8d207c2b8ae6b0d8778bce60d3a15a431 (diff) |
Test serialization
Diffstat (limited to 'src')
-rw-r--r-- | src/util/serialization.rs | 18 |
1 files changed, 18 insertions, 0 deletions
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<String> { 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"); + } +} |