1
exercism fetch rust queen-attack

tests/queen-attack.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
extern crate queen_attack;

use queen_attack::*;

#[test]
fn chess_position_on_the_board_is_ok() {
    assert!(ChessPosition::new(2, 4).is_ok());
}

#[test]
#[ignore]
fn chess_position_off_the_board_is_err() {
    assert!(ChessPosition::new(-1, 2).is_err());
    assert!(ChessPosition::new(8, 2).is_err());
    assert!(ChessPosition::new(5, -1).is_err());
    assert!(ChessPosition::new(5, 8).is_err());
}

#[test]
#[ignore]
fn queen_is_created_with_a_ok_position() {
    Queen::new(ChessPosition::new(2, 4).unwrap());
}

#[test]
#[ignore]
fn queens_that_can_not_attack() {
    let white_queen = Queen::new(ChessPosition::new(2, 4).unwrap());
    let black_queen = Queen::new(ChessPosition::new(6, 6).unwrap());
    assert!(!white_queen.can_attack(&black_queen));
}

#[test]
#[ignore]
fn queens_on_the_same_rank_can_attack() {
    let white_queen = Queen::new(ChessPosition::new(2, 4).unwrap());
    let black_queen = Queen::new(ChessPosition::new(2, 6).unwrap());
    assert!(white_queen.can_attack(&black_queen));
}

#[test]
#[ignore]
fn queens_on_the_same_file_can_attack() {
    let white_queen = Queen::new(ChessPosition::new(4, 5).unwrap());
    let black_queen = Queen::new(ChessPosition::new(3, 5).unwrap());
    assert!(white_queen.can_attack(&black_queen));
}

#[test]
#[ignore]
fn queens_on_the_same_diagonal_can_attack_one() {
    let white_queen = Queen::new(ChessPosition::new(2, 2).unwrap());
    let black_queen = Queen::new(ChessPosition::new(0, 4).unwrap());
    assert!(white_queen.can_attack(&black_queen));
}

#[test]
#[ignore]
fn queens_on_the_same_diagonal_can_attack_two() {
    let white_queen = Queen::new(ChessPosition::new(2, 2).unwrap());
    let black_queen = Queen::new(ChessPosition::new(3, 1).unwrap());
    assert!(white_queen.can_attack(&black_queen));
}

#[test]
#[ignore]
fn queens_on_the_same_diagonal_can_attack_three() {
    let white_queen = Queen::new(ChessPosition::new(2, 2).unwrap());
    let black_queen = Queen::new(ChessPosition::new(1, 1).unwrap());
    assert!(white_queen.can_attack(&black_queen));
}

#[test]
#[ignore]
fn queens_on_the_same_diagonal_can_attack_four() {
    let white_queen = Queen::new(ChessPosition::new(2, 2).unwrap());
    let black_queen = Queen::new(ChessPosition::new(5, 5).unwrap());
    assert!(white_queen.can_attack(&black_queen));
}