aboutsummaryrefslogtreecommitdiffstats
path: root/src/frame.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2019-10-25 08:45:44 -0400
committerJesse Luehrs <doy@tozt.net>2019-10-25 08:45:44 -0400
commita5e7c90d0af6a0b6080f17df2910f69ef114b210 (patch)
tree08bd9578847e77c3aa34eec2e6ad45238759719a /src/frame.rs
parent37e6d9c37b2d8e49103ef61f0127bc8b15a51530 (diff)
downloadttyrec-a5e7c90d0af6a0b6080f17df2910f69ef114b210.tar.gz
ttyrec-a5e7c90d0af6a0b6080f17df2910f69ef114b210.zip
add some tests
Diffstat (limited to 'src/frame.rs')
-rw-r--r--src/frame.rs32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/frame.rs b/src/frame.rs
index 4b72378..7558470 100644
--- a/src/frame.rs
+++ b/src/frame.rs
@@ -27,3 +27,35 @@ impl std::convert::TryFrom<Frame> for Vec<u8> {
Ok(bytes)
}
}
+
+#[cfg(test)]
+mod test {
+ use super::*;
+ use std::convert::TryFrom as _;
+
+ #[test]
+ fn test_basic() {
+ let tests = vec![
+ (
+ Frame {
+ time: std::time::Duration::new(0, 0),
+ data: vec![],
+ },
+ vec![0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
+ ),
+ (
+ Frame {
+ time: std::time::Duration::new(38, 123_456_000),
+ data: b"\x1b[2Jfoobar".to_vec(),
+ },
+ vec![
+ 38, 0, 0, 0, 64, 226, 1, 0, 10, 0, 0, 0, 27, 91, 50, 74,
+ 102, 111, 111, 98, 97, 114,
+ ],
+ ),
+ ];
+ for (frame, bytes) in tests {
+ assert_eq!(Vec::<u8>::try_from(frame).unwrap(), bytes);
+ }
+ }
+}