test configurations
This commit is contained in:
46
src/image.rs
46
src/image.rs
@@ -38,24 +38,34 @@ impl ToString for Image {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_image_from_string() {
|
||||
let output = Image::from(include_str!("test-resources/image").to_string());
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use crate::image::Image;
|
||||
|
||||
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, 1, 1,
|
||||
1, 1, 1, 1, 1, 1,
|
||||
],
|
||||
};
|
||||
#[test]
|
||||
fn test_image_from_string() {
|
||||
let output = Image::from(include_str!("test-resources/image").to_string());
|
||||
|
||||
assert_eq!(output, expected)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_image_to_string() {
|
||||
let output = crate::mock::image::chequers_1().to_string();
|
||||
let expected = include_str!("test-resources/image-chequers-1").to_string();
|
||||
assert_eq!(output, expected);
|
||||
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,
|
||||
1, 1, 1, 1, 1, 1, 1, 1,
|
||||
],
|
||||
};
|
||||
|
||||
assert_eq!(output, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_image_to_string() {
|
||||
let output = crate::mock::image::chequers_1().to_string();
|
||||
let expected = include_str!("test-resources/image-chequers-1").to_string();
|
||||
assert_eq!(output, expected);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user