From 2d2abcdd563fbe1551d0309f74515e68000f5049 Mon Sep 17 00:00:00 2001 From: Max Bradbury Date: Mon, 6 Apr 2020 07:55:10 +0100 Subject: [PATCH] dedupe test images --- src/main.rs | 60 ++++++++++++++++++++++++----------------------------- 1 file changed, 27 insertions(+), 33 deletions(-) diff --git a/src/main.rs b/src/main.rs index 39d2f9a..4bd8117 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,6 +4,30 @@ use std::collections::HashMap; const IMAGE_DIMENSION_SD: usize = 8; const IMAGE_DIMENSION_HD: usize = 16; +const TEST_IMAGE_CHEQUERS_1: Image = Image { + pixels: vec![ + 1,0,1,0,1,0,1,0, + 0,1,0,1,0,1,0,1, + 1,0,1,0,1,0,1,0, + 0,1,0,1,0,1,0,1, + 1,0,1,0,1,0,1,0, + 0,1,0,1,0,1,0,1, + 1,0,1,0,1,0,1,0, + 0,1,0,1,0,1,0,1, + ] +}; + +const TEST_IMAGE_CHEQUERS_2: Image = Image { pixels: vec![ + 0,1,0,1,0,1,0,1, + 1,0,1,0,1,0,1,0, + 0,1,0,1,0,1,0,1, + 1,0,1,0,1,0,1,0, + 0,1,0,1,0,1,0,1, + 1,0,1,0,1,0,1,0, + 0,1,0,1,0,1,0,1, + 1,0,1,0,1,0,1,0, +]}; + #[derive(Debug, Eq, PartialEq)] struct Colour { red: u8, @@ -154,19 +178,7 @@ fn image_to_string_opts(image: Image, hd: bool) -> String { #[test] fn test_image_to_string() { - let output = image_to_string(Image { - pixels: vec![ - 1,0,1,0,1,0,1,0, - 0,1,0,1,0,1,0,1, - 1,0,1,0,1,0,1,0, - 0,1,0,1,0,1,0,1, - 1,0,1,0,1,0,1,0, - 0,1,0,1,0,1,0,1, - 1,0,1,0,1,0,1,0, - 0,1,0,1,0,1,0,1, - ] - }); - + let output = image_to_string(TEST_IMAGE_CHEQUERS_1); let expected = "10101010\n01010101\n10101010\n01010101\n10101010\n01010101\n10101010\n01010101".to_string(); assert_eq!(output, expected); @@ -254,26 +266,8 @@ fn test_tile_to_string() { name: Some("chequers".to_string()), wall: false, animation_frames: vec![ - Image { pixels: vec![ - 1,0,1,0,1,0,1,0, - 0,1,0,1,0,1,0,1, - 1,0,1,0,1,0,1,0, - 0,1,0,1,0,1,0,1, - 1,0,1,0,1,0,1,0, - 0,1,0,1,0,1,0,1, - 1,0,1,0,1,0,1,0, - 0,1,0,1,0,1,0,1, - ]}, - Image { pixels: vec![ - 0,1,0,1,0,1,0,1, - 1,0,1,0,1,0,1,0, - 0,1,0,1,0,1,0,1, - 1,0,1,0,1,0,1,0, - 0,1,0,1,0,1,0,1, - 1,0,1,0,1,0,1,0, - 0,1,0,1,0,1,0,1, - 1,0,1,0,1,0,1,0, - ]}, + TEST_IMAGE_CHEQUERS_1, + TEST_IMAGE_CHEQUERS_2, ] });