From f4843c246c5472572a74dfaeb59c22474435c6cc Mon Sep 17 00:00:00 2001 From: Nathan Fiedler Date: Sun, 22 Jan 2017 14:13:05 -0800 Subject: [PATCH] Test with some flexibility in image size The size of the image can vary from version to version (of ImageMagick) and platform to platform (i.e. MacOS and FreeBSD). As such, allow for a degree of variability in the resulting image size. cargo test passes --- tests/lib.rs | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/tests/lib.rs b/tests/lib.rs index 455bc65..c5cee7c 100644 --- a/tests/lib.rs +++ b/tests/lib.rs @@ -91,12 +91,10 @@ fn test_write_image_to_blob() { assert_eq!(512, wand.get_image_width()); assert_eq!(384, wand.get_image_height()); let blob = wand.write_image_blob("jpeg").unwrap(); - if cfg!(target_os = "macos") { - // yeah, don't know why... - assert_eq!(104061, blob.len()); - } else { - assert_eq!(104060, blob.len()); - } + let blob_len = blob.len(); + // There is a slight degree of variability from platform to platform, + // and version to version of ImageMagick. + assert!(blob_len > 103000 && blob_len < 105000); // should be able to read it back again assert!(wand.read_image_blob(&blob).is_ok()); assert_eq!(512, wand.get_image_width()); @@ -113,12 +111,10 @@ fn test_write_images_to_blob() { assert_eq!(512, wand.get_image_width()); assert_eq!(384, wand.get_image_height()); let blob = wand.write_images_blob("jpeg").unwrap(); - if cfg!(target_os = "macos") { - // yeah, don't know why... - assert_eq!(104061, blob.len()); - } else { - assert_eq!(104060, blob.len()); - } + let blob_len = blob.len(); + // There is a slight degree of variability from platform to platform, + // and version to version of ImageMagick. + assert!(blob_len > 103000 && blob_len < 105000); // should be able to read it back again assert!(wand.read_image_blob(&blob).is_ok()); assert_eq!(512, wand.get_image_width());