aboutsummaryrefslogtreecommitdiff
path: root/vendor/weezl/tests/implicit_reset.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2024-01-08 00:21:28 +0300
committerValentin Popov <valentin@popov.link>2024-01-08 00:21:28 +0300
commit1b6a04ca5504955c571d1c97504fb45ea0befee4 (patch)
tree7579f518b23313e8a9748a88ab6173d5e030b227 /vendor/weezl/tests/implicit_reset.rs
parent5ecd8cf2cba827454317368b68571df0d13d7842 (diff)
downloadfparkan-1b6a04ca5504955c571d1c97504fb45ea0befee4.tar.xz
fparkan-1b6a04ca5504955c571d1c97504fb45ea0befee4.zip
Initial vendor packages
Signed-off-by: Valentin Popov <valentin@popov.link>
Diffstat (limited to 'vendor/weezl/tests/implicit_reset.rs')
-rw-r--r--vendor/weezl/tests/implicit_reset.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/vendor/weezl/tests/implicit_reset.rs b/vendor/weezl/tests/implicit_reset.rs
new file mode 100644
index 0000000..69dd8a8
--- /dev/null
+++ b/vendor/weezl/tests/implicit_reset.rs
@@ -0,0 +1,21 @@
+use std::{env, fs};
+use weezl::{decode, encode, BitOrder};
+
+#[test]
+fn read_from_mangled() {
+ let file = env::args().next().unwrap();
+ let data = fs::read(file).unwrap();
+
+ // For simplicity, encode 7-bit data.
+ let data: Vec<_> = data.iter().copied().map(|b| b & 0x7f).collect();
+
+ let mut encoder = encode::Encoder::new(BitOrder::Lsb, 7);
+ let mut buffer = Vec::with_capacity(2 * data.len() + 40);
+ let _ = encoder.into_stream(&mut buffer).encode_all(&*data);
+
+ let mut decoder = decode::Decoder::new(BitOrder::Lsb, 7);
+ let mut compare = vec![];
+ let result = decoder.into_stream(&mut compare).decode_all(&buffer[1..]);
+ assert!(result.status.is_ok(), "{:?}", result.status);
+ assert!(data == &*compare, "{:?}\n{:?}", data, compare);
+}