From d02b81b1fbbae47ac3de5e3afd3daa8eb65265db Mon Sep 17 00:00:00 2001 From: gered Date: Mon, 20 Mar 2023 12:06:10 -0400 Subject: [PATCH] extra tests for other unsupported png scenarios --- ggdt/src/graphics/bitmap/png.rs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/ggdt/src/graphics/bitmap/png.rs b/ggdt/src/graphics/bitmap/png.rs index 00591d5..7a93bc7 100644 --- a/ggdt/src/graphics/bitmap/png.rs +++ b/ggdt/src/graphics/bitmap/png.rs @@ -638,6 +638,38 @@ pub mod tests { Err(PngError::BadFile(..)) ); + assert_matches!( + IndexedBitmap::load_png_file(path_to_file(Path::new("unsupported_alpha_8bit.png")).as_path()), + Err(PngError::BadFile(..)) + ); + assert_matches!( + IndexedBitmap::load_png_file(path_to_file(Path::new("unsupported_greyscale_8bit.png")).as_path()), + Err(PngError::BadFile(..)) + ); + assert_matches!( + IndexedBitmap::load_png_file(path_to_file(Path::new("unsupported_indexed_16col.png")).as_path()), + Err(PngError::BadFile(..)) + ); + assert_matches!( + IndexedBitmap::load_png_file(path_to_file(Path::new("unsupported_rgb_16bit.png")).as_path()), + Err(PngError::BadFile(..)) + ); + assert_matches!( + IndexedBitmap::load_png_file(path_to_file(Path::new("unsupported_rgba_16bit.png")).as_path()), + Err(PngError::BadFile(..)) + ); + + // also test the extra formats that IndexedBitmap does not support which RgbaBitmap does + // (anything not 256-color indexed basically ...) + assert_matches!( + IndexedBitmap::load_png_file(path_to_file(Path::new("rgb.png")).as_path()), + Err(PngError::BadFile(..)) + ); + assert_matches!( + IndexedBitmap::load_png_file(path_to_file(Path::new("rgba.png")).as_path()), + Err(PngError::BadFile(..)) + ); + Ok(()) } } \ No newline at end of file