aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/util')
-rw-r--r--src/util/serialization.rs18
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");
+ }
+}