1
use super::*;
2

            
3
impl Hits {
4
437
    pub(crate) fn entries(&self) -> Vec<(Rect, Target)> {
5
437
        self.areas
6
437
            .iter()
7
11273
            .map(|&(rect, target, _)| (rect, target))
8
            .collect()
9
437
    }
10
}
11

            
12
#[test]
13
1
fn the_area_drawn_last_is_on_top() {
14
1
    let mut hits = Hits::default();
15
1
    hits.push(Rect::new(0, 0, 10, 10), Target::Block);
16
1
    hits.push(Rect::new(2, 2, 3, 1), Target::Field(1));
17
1
    assert_eq!(
18
1
        hits.hit_at(Position::new(3, 2)),
19
1
        Some((Rect::new(2, 2, 3, 1), Target::Field(1), None))
20
    );
21
1
    assert_eq!(
22
1
        hits.hit_at(Position::new(6, 2)),
23
1
        Some((Rect::new(0, 0, 10, 10), Target::Block, None))
24
    );
25
1
    assert_eq!(hits.hit_at(Position::new(10, 2)), None);
26
1
}
27

            
28
#[test]
29
1
fn an_empty_area_is_not_recorded() {
30
1
    let mut hits = Hits::default();
31
1
    hits.push(Rect::new(1, 1, 0, 1), Target::Row(0));
32
1
    assert!(hits.entries().is_empty());
33
1
}