exercism/rust/flower-field/tests/flower_field.rs

199 lines
3.3 KiB
Rust

use flower_field::*;
#[test]
fn no_rows() {
let input = &[];
let expected: &[&str] = &[];
let actual = annotate(input);
assert_eq!(actual, expected);
}
#[test]
#[ignore]
fn no_columns() {
let input = &[""];
let expected = &[""];
let actual = annotate(input);
assert_eq!(actual, expected);
}
#[test]
#[ignore]
fn no_flowers() {
#[rustfmt::skip]
let (input, expected) = (&[
" ",
" ",
" ",
], &[
" ",
" ",
" ",
]);
let actual = annotate(input);
assert_eq!(actual, expected);
}
#[test]
#[ignore]
fn garden_full_of_flowers() {
#[rustfmt::skip]
let (input, expected) = (&[
"***",
"***",
"***",
], &[
"***",
"***",
"***",
]);
let actual = annotate(input);
assert_eq!(actual, expected);
}
#[test]
#[ignore]
fn flower_surrounded_by_spaces() {
#[rustfmt::skip]
let (input, expected) = (&[
" ",
" * ",
" ",
], &[
"111",
"1*1",
"111",
]);
let actual = annotate(input);
assert_eq!(actual, expected);
}
#[test]
#[ignore]
fn space_surrounded_by_flowers() {
#[rustfmt::skip]
let (input, expected) = (&[
"***",
"* *",
"***",
], &[
"***",
"*8*",
"***",
]);
let actual = annotate(input);
assert_eq!(actual, expected);
}
#[test]
#[ignore]
fn horizontal_line() {
let input = &[" * * "];
let expected = &["1*2*1"];
let actual = annotate(input);
assert_eq!(actual, expected);
}
#[test]
#[ignore]
fn horizontal_line_flowers_at_edges() {
let input = &["* *"];
let expected = &["*1 1*"];
let actual = annotate(input);
assert_eq!(actual, expected);
}
#[test]
#[ignore]
fn vertical_line() {
#[rustfmt::skip]
let (input, expected) = (&[
" ",
"*",
" ",
"*",
" ",
], &[
"1",
"*",
"2",
"*",
"1",
]);
let actual = annotate(input);
assert_eq!(actual, expected);
}
#[test]
#[ignore]
fn vertical_line_flowers_at_edges() {
#[rustfmt::skip]
let (input, expected) = (&[
"*",
" ",
" ",
" ",
"*",
], &[
"*",
"1",
" ",
"1",
"*",
]);
let actual = annotate(input);
assert_eq!(actual, expected);
}
#[test]
#[ignore]
fn cross() {
#[rustfmt::skip]
let (input, expected) = (&[
" * ",
" * ",
"*****",
" * ",
" * ",
], &[
" 2*2 ",
"25*52",
"*****",
"25*52",
" 2*2 ",
]);
let actual = annotate(input);
assert_eq!(actual, expected);
}
#[test]
#[ignore]
fn large_garden() {
#[rustfmt::skip]
let (input, expected) = (&[
" * * ",
" * ",
" * ",
" * *",
" * * ",
" ",
], &[
"1*22*1",
"12*322",
" 123*2",
"112*4*",
"1*22*2",
"111111",
]);
let actual = annotate(input);
assert_eq!(actual, expected);
}
#[test]
#[ignore]
fn multiple_adjacent_flowers() {
let input = &[" ** "];
let expected = &["1**1"];
let actual = annotate(input);
assert_eq!(actual, expected);
}