From af3388f9f2fe5a79f9650f4f886c9ee6b2fe441b Mon Sep 17 00:00:00 2001 From: Max Bradbury Date: Wed, 29 Apr 2020 09:28:20 +0100 Subject: [PATCH] test out-of-bounds pixels --- src/image.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/image.rs b/src/image.rs index dce465f..7f5b02e 100644 --- a/src/image.rs +++ b/src/image.rs @@ -93,4 +93,28 @@ mod test { assert_eq!(output, expected); } + + /// lots of Bitsy games have editor errors where pixels can be placed out of bounds + /// check that these extraneous pixels are stripped out + #[test] + fn test_image_out_of_bounds() { + let output = Image::from( + include_str!("test-resources/image-oob").to_string() + ); + + let expected = Image { + pixels: vec![ + 1,1,1,1,1,1,1,1, + 1,1,0,0,1,1,1,1, + 1,0,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1, + 0,0,0,0,0,0,0,0, + ] + }; + + assert_eq!(output, expected); + } }