Skip to content

Commit

Permalink
Test for add_edges
Browse files Browse the repository at this point in the history
  • Loading branch information
alice-i-cecile committed Jan 8, 2025
1 parent 1b67f1d commit e0aaca9
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions crates/bevy_input_focus/src/directional_navigation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,25 @@ mod tests {
assert_eq!(map.get_neighbor(c, CompassOctant::West), None);
}

#[test]
fn edges() {
let mut world = World::new();
let a = world.spawn_empty().id();
let b = world.spawn_empty().id();
let c = world.spawn_empty().id();

let mut map = DirectionalNavigationMap::default();
map.add_edges(&[a, b, c], CompassOctant::East);

assert_eq!(map.get_neighbor(a, CompassOctant::East), Some(b));
assert_eq!(map.get_neighbor(b, CompassOctant::East), Some(c));
assert_eq!(map.get_neighbor(c, CompassOctant::East), None);

assert_eq!(map.get_neighbor(a, CompassOctant::West), None);
assert_eq!(map.get_neighbor(b, CompassOctant::West), Some(a));
assert_eq!(map.get_neighbor(c, CompassOctant::West), Some(b));
}

#[test]
fn looping_edges() {
let mut world = World::new();
Expand Down

0 comments on commit e0aaca9

Please sign in to comment.