Lines
100 %
Functions
Branches
use super::*;
impl Hits {
pub(crate) fn entries(&self) -> Vec<(Rect, Target)> {
self.areas
.iter()
.map(|&(rect, target, _)| (rect, target))
.collect()
}
#[test]
fn the_area_drawn_last_is_on_top() {
let mut hits = Hits::default();
hits.push(Rect::new(0, 0, 10, 10), Target::Block);
hits.push(Rect::new(2, 2, 3, 1), Target::Field(1));
assert_eq!(
hits.hit_at(Position::new(3, 2)),
Some((Rect::new(2, 2, 3, 1), Target::Field(1), None))
);
hits.hit_at(Position::new(6, 2)),
Some((Rect::new(0, 0, 10, 10), Target::Block, None))
assert_eq!(hits.hit_at(Position::new(10, 2)), None);
fn an_empty_area_is_not_recorded() {
hits.push(Rect::new(1, 1, 0, 1), Target::Row(0));
assert!(hits.entries().is_empty());