diff options
author | cc <cc@localhost> | 2025-08-20 18:08:40 -0700 |
---|---|---|
committer | cc <cc@localhost> | 2025-08-20 18:08:49 -0700 |
commit | c8190c1a8931749ff6408a39d791ba99fc0266eb (patch) | |
tree | c5ebbf37b9480b02a6eacb0297da354f7a5581cc /src/lib.rs | |
parent | 079dc54c945f12380b7b935a0765dba76fac257f (diff) |
Modularize Private Tests
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 68 |
1 files changed, 13 insertions, 55 deletions
@@ -1,5 +1,7 @@ mod tiff; +pub const TEST_IMAGE_PATH: &str = "../test.tif"; + #[cfg(test)] mod tests { use super::*; @@ -18,7 +20,7 @@ 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); @@ -26,22 +28,10 @@ mod tests { } #[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); - } - } } |