aboutsummaryrefslogtreecommitdiff
path: root/src/primitive/bufferinfo.rs
diff options
context:
space:
mode:
authorMax Audron <audron@cocaine.farm>2021-01-21 14:57:22 +0100
committerMax Audron <audron@cocaine.farm>2021-01-21 14:57:22 +0100
commit2405fa686a53f1d895807b1658c38a5e7e7693a0 (patch)
treed40a9430a421d3ca4a28ce2ad98b51e3d731f265 /src/primitive/bufferinfo.rs
parentMerge branch 'client' (diff)
reorganize tests and add quassel features
Diffstat (limited to 'src/primitive/bufferinfo.rs')
-rw-r--r--src/primitive/bufferinfo.rs37
1 files changed, 35 insertions, 2 deletions
diff --git a/src/primitive/bufferinfo.rs b/src/primitive/bufferinfo.rs
index 9cbaa2d..1c4e206 100644
--- a/src/primitive/bufferinfo.rs
+++ b/src/primitive/bufferinfo.rs
@@ -5,8 +5,6 @@ use failure::Error;
use crate::{Deserialize, DeserializeUTF8};
use crate::{Serialize, SerializeUTF8};
-extern crate bytes;
-
/// The BufferInfo struct represents a BufferInfo as received in IRC
///
/// BufferInfo is, like all other struct based types, serialized sequentially.
@@ -79,3 +77,38 @@ impl From<i16> for BufferType {
}
}
}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn bufferinfo_serialize() {
+ let buffer = BufferInfo {
+ id: 1,
+ network_id: 1,
+ buffer_type: BufferType::Channel,
+ name: "#test".to_string(),
+ };
+
+ assert_eq!(
+ buffer.serialize().unwrap(),
+ [0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 5, 35, 116, 101, 115, 116]
+ )
+ }
+
+ #[test]
+ fn bufferinfo_deserialize() {
+ let buffer = BufferInfo {
+ id: 1,
+ network_id: 1,
+ buffer_type: BufferType::Channel,
+ name: "#test".to_string(),
+ };
+ let bytes = vec![
+ 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 5, 35, 116, 101, 115, 116,
+ ];
+
+ assert_eq!(BufferInfo::parse(&bytes).unwrap(), (23, buffer))
+ }
+}