aboutsummaryrefslogtreecommitdiff
path: root/src/primitive/stringlist.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/primitive/stringlist.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/primitive/stringlist.rs b/src/primitive/stringlist.rs
index e5d1a44..df6d281 100644
--- a/src/primitive/stringlist.rs
+++ b/src/primitive/stringlist.rs
@@ -47,3 +47,29 @@ impl Deserialize for StringList {
return Ok((pos, res));
}
}
+
+#[test]
+pub fn string_list_serialize() {
+ let mut test_list = StringList::new();
+ test_list.push("Configured".to_string());
+ assert_eq!(
+ test_list.serialize().unwrap(),
+ [
+ 0, 0, 0, 1, 0, 0, 0, 20, 0, 67, 0, 111, 0, 110, 0, 102, 0, 105, 0, 103, 0, 117, 0, 114,
+ 0, 101, 0, 100
+ ]
+ )
+}
+
+#[test]
+pub fn string_list_deserialize() {
+ let test_bytes: &[u8] = &[
+ 0, 0, 0, 1, 0, 0, 0, 20, 0, 67, 0, 111, 0, 110, 0, 102, 0, 105, 0, 103, 0, 117, 0, 114, 0,
+ 101, 0, 100, 0, 0, 0, 1,
+ ];
+ let mut test_list = StringList::new();
+ test_list.push("Configured".to_string());
+ let (len, res) = StringList::parse(test_bytes).unwrap();
+ assert_eq!(len, 28);
+ assert_eq!(test_list, res);
+}