From c8190c1a8931749ff6408a39d791ba99fc0266eb Mon Sep 17 00:00:00 2001 From: cc Date: Wed, 20 Aug 2025 18:08:40 -0700 Subject: Modularize Private Tests --- src/lib.rs | 68 ++++++++++++-------------------------------------------------- 1 file changed, 13 insertions(+), 55 deletions(-) (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs index 457eadc..ebec3fc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,7 @@ mod tiff; +pub const TEST_IMAGE_PATH: &str = "../test.tif"; + #[cfg(test)] mod tests { use super::*; @@ -18,30 +20,18 @@ mod tests { #[test] fn tiff_open_test() { tiff::ignore_warnings(); - if let Some(result) = tiff::open("../test.tif") { + if let Some(result) = tiff::open(TEST_IMAGE_PATH) { tiff::close(result); } else { assert!(false); } } - #[test] - fn tiff_height_test() { - tiff::ignore_warnings(); - if let Some(t_handle) = tiff::open("../test.tif") { - let height = tiff::get_height(t_handle); - assert!(height > 0); - tiff::close(t_handle); - } else { - assert!(false); - } - } - #[test] fn tiff_width_test() { tiff::ignore_warnings(); - if let Some(t_handle) = tiff::open("../test.tif") { - let width = tiff::get_width(t_handle); + if let Some(t_handle) = tiff::open(TEST_IMAGE_PATH) { + let width = tiff::get_image_width(t_handle); assert!(width > 0); tiff::close(t_handle); } else { @@ -50,31 +40,11 @@ mod tests { } #[test] - fn tiff_strip_count() { - tiff::ignore_warnings(); - if let Some(t_handle) = tiff::open("../test.tif") { - let strip_count = tiff::get_strip_count(t_handle); - assert!(strip_count > 0); - tiff::close(t_handle); - } else { - assert!(false); - } - } - - #[test] - fn tiff_data_depth() { + fn tiff_height_test() { tiff::ignore_warnings(); - if let Some(t_handle) = tiff::open("../test.tif") { - let strip_size = tiff::get_strip_size(t_handle); - let strip_count = tiff::get_strip_count(t_handle); - let strip_depth = strip_size * strip_count; - assert!(strip_depth > 0); - let image_width = tiff::get_width(t_handle); - let image_height = tiff::get_height(t_handle); - let image_depth = image_width * image_height; - assert!(image_depth > 0); - let strip_depth = strip_depth as f64; - let image_depth = image_depth as f64; + if let Some(t_handle) = tiff::open(TEST_IMAGE_PATH) { + let height = tiff::get_image_height(t_handle); + assert!(height > 0); tiff::close(t_handle); } else { assert!(false); @@ -82,11 +52,10 @@ mod tests { } #[test] - fn tiff_strip_size() { + fn tiff_channel_test() { tiff::ignore_warnings(); - if let Some(t_handle) = tiff::open("../test.tif") { - let strip_size = tiff::get_strip_size(t_handle); - assert!(strip_size > 0); + if let Some(t_handle) = tiff::open(TEST_IMAGE_PATH) { + let channels = tiff::get_image_channels(t_handle); tiff::close(t_handle); } else { assert!(false); @@ -96,22 +65,11 @@ mod tests { #[test] fn tiff_read() { tiff::ignore_warnings(); - if let Some(t_handle) = tiff::open("../test.tif") { + if let Some(t_handle) = tiff::open(TEST_IMAGE_PATH) { let data = tiff::read(t_handle); tiff::close(t_handle); } else { assert!(false); } } - - #[test] - fn tiff_strip_read() { - tiff::ignore_warnings(); - if let Some(t_handle) = tiff::open("../test.tif") { - let strip = tiff::read_strip(t_handle, 0); - tiff::close(t_handle); - } else { - assert!(false); - } - } } -- cgit v1.2.1