diff options
| author | Max Audron <audron@cocaine.farm> | 2021-01-21 14:57:22 +0100 |
|---|---|---|
| committer | Max Audron <audron@cocaine.farm> | 2021-01-21 14:57:22 +0100 |
| commit | 2405fa686a53f1d895807b1658c38a5e7e7693a0 (patch) | |
| tree | d40a9430a421d3ca4a28ce2ad98b51e3d731f265 /src/primitive/stringlist.rs | |
| parent | Merge branch 'client' (diff) | |
reorganize tests and add quassel features
Diffstat (limited to 'src/primitive/stringlist.rs')
| -rw-r--r-- | src/primitive/stringlist.rs | 26 |
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); +} |
