dedupe test images

This commit is contained in:
Max Bradbury 2020-04-06 07:55:10 +01:00
parent 7f6fa9df82
commit 2d2abcdd56
1 changed files with 27 additions and 33 deletions

View File

@ -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,
]
});