aboutsummaryrefslogtreecommitdiff
path: root/vendor/weezl/tests/roundtrip.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2024-07-19 15:37:58 +0300
committerValentin Popov <valentin@popov.link>2024-07-19 15:37:58 +0300
commita990de90fe41456a23e58bd087d2f107d321f3a1 (patch)
tree15afc392522a9e85dc3332235e311b7d39352ea9 /vendor/weezl/tests/roundtrip.rs
parent3d48cd3f81164bbfc1a755dc1d4a9a02f98c8ddd (diff)
downloadfparkan-a990de90fe41456a23e58bd087d2f107d321f3a1.tar.xz
fparkan-a990de90fe41456a23e58bd087d2f107d321f3a1.zip
Deleted vendor folder
Diffstat (limited to 'vendor/weezl/tests/roundtrip.rs')
-rw-r--r--vendor/weezl/tests/roundtrip.rs66
1 files changed, 0 insertions, 66 deletions
diff --git a/vendor/weezl/tests/roundtrip.rs b/vendor/weezl/tests/roundtrip.rs
deleted file mode 100644
index f124fae..0000000
--- a/vendor/weezl/tests/roundtrip.rs
+++ /dev/null
@@ -1,66 +0,0 @@
-use std::{env, fs};
-use weezl::{decode, encode, BitOrder};
-
-#[derive(Clone, Copy, Debug)]
-enum Flavor {
- Gif,
- Tiff,
-}
-
-#[test]
-fn roundtrip_all() {
- let file = env::args().next().unwrap();
- let data = fs::read(file).unwrap();
-
- for &flavor in &[Flavor::Gif, Flavor::Tiff] {
- for &bit_order in &[BitOrder::Lsb, BitOrder::Msb] {
- for bit_width in 2..8 {
- let data: Vec<_> = data
- .iter()
- .copied()
- .map(|b| b & ((1 << bit_width) - 1))
- .collect();
-
- println!("Roundtrip test {:?} {:?} {}", flavor, bit_order, bit_width);
- assert_roundtrips(&*data, flavor, bit_width, bit_order);
- }
- }
- }
-}
-
-fn assert_roundtrips(data: &[u8], flavor: Flavor, bit_width: u8, bit_order: BitOrder) {
- let (c, d): (
- fn(BitOrder, u8) -> encode::Encoder,
- fn(BitOrder, u8) -> decode::Decoder,
- ) = match flavor {
- Flavor::Gif => (encode::Encoder::new, decode::Decoder::new),
- Flavor::Tiff => (
- encode::Encoder::with_tiff_size_switch,
- decode::Decoder::with_tiff_size_switch,
- ),
- };
- let mut encoder = c(bit_order, bit_width);
- let mut buffer = Vec::with_capacity(2 * data.len() + 40);
- let _ = encoder.into_stream(&mut buffer).encode_all(data);
-
- let mut decoder = d(bit_order, bit_width);
- let mut compare = vec![];
- let result = decoder
- .into_stream(&mut compare)
- .decode_all(buffer.as_slice());
- assert!(
- result.status.is_ok(),
- "{:?}, {}, {:?}",
- bit_order,
- bit_width,
- result.status
- );
- assert!(
- data == &*compare,
- "{:?}, {}\n{:?}\n{:?}",
- bit_order,
- bit_width,
- data,
- compare
- );
-}