From 24775b101489e0cc0550e4fbec22845c85cf7d0f Mon Sep 17 00:00:00 2001 From: Ivan Smirnov Date: Wed, 29 Dec 2021 22:39:14 +0300 Subject: [PATCH] (Remove temporary tests from crate root) --- src/lib.rs | 48 ------------------------------------------------ 1 file changed, 48 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 6406f6d..5a49b4d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -26,51 +26,3 @@ pub use crate::decode::{qoi_decode_header, qoi_decode_to_vec}; pub use crate::encode::{encode_size_required, qoi_encode_to_buf, qoi_encode_to_vec}; pub use crate::error::{Error, Result}; pub use crate::header::Header; - -#[cfg(test)] -mod tests { - use std::fs::File; - use std::path::PathBuf; - - use crate::{consts::QOI_MAGIC, qoi_decode_to_vec, qoi_encode_to_vec}; - - fn read_png(rel_path: &str) -> (u32, u32, u8, Vec) { - let get_path = || -> Option { - Some(PathBuf::from(file!()).parent()?.parent()?.join(rel_path)) - }; - let decoder = png::Decoder::new(File::open(get_path().unwrap()).unwrap()); - let mut reader = decoder.read_info().unwrap(); - let mut buf = vec![0; reader.output_buffer_size()]; - let info = reader.next_frame(&mut buf).unwrap(); - let bytes = &buf[..info.buffer_size()]; - (info.width, info.height, info.color_type.samples() as u8, bytes.to_vec()) - } - - #[test] - fn kodim_01() { - let (w, h, c, v) = read_png("assets/kodim01.png"); - let q = qoi_encode_to_vec(&v, w, h, c, 0).unwrap(); - std::fs::write("kodim01.qoi", q.as_slice()).unwrap(); - } - - #[test] - fn wikipedia() { - let (w, h, c, v) = read_png("assets/en.wikipedia.org.png"); - let q = qoi_encode_to_vec(&v, w, h, c, 0).unwrap(); - std::fs::write("wikipedia.qoi", q.as_slice()).unwrap(); - } - - #[test] - fn roundtrip_3() { - let three_raw = include_bytes!("../assets/three.raw").to_vec(); - let (w, h, c) = (572, 354, 3); - let three_qoi = qoi_encode_to_vec(&three_raw, w, h, c, 0).unwrap(); - let (header, three_rtp) = qoi_decode_to_vec(&three_qoi, c).unwrap(); - assert_eq!(header.magic, QOI_MAGIC); - assert_eq!(header.width, w); - assert_eq!(header.height, h); - assert_eq!(header.channels, c); - assert_eq!(three_rtp.len(), (w as usize) * (h as usize) * 3); - assert_eq!(three_raw, three_rtp.as_slice()); - } -}