Skip to content

Commit

Permalink
test: refine the room area test
Browse files Browse the repository at this point in the history
  • Loading branch information
khoover committed Oct 14, 2024
1 parent 494f7fd commit 619c188
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/local/room_coordinate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,21 +246,24 @@ mod test {

#[test]
fn index_room_area() {
let mut base: Box<[u8; ROOM_AREA]> = Box::new([0; ROOM_AREA]);
let mut base: Box<[u16; ROOM_AREA]> = Box::new([0; ROOM_AREA]);
for i in 0..ROOM_USIZE {
for j in 0..ROOM_USIZE {
base[i * ROOM_USIZE + j] = i as u8;
base[i * ROOM_USIZE + j] = i as u16 * 50;
}
}

for i in 0..ROOM_SIZE {
let coord = RoomCoordinate::new(i).unwrap();
assert!(base[coord].iter().copied().all(|val| val == i));
base[coord][0] += 1;
assert!(base[coord].iter().copied().all(|val| val == i as u16 * 50));
for j in 0..ROOM_USIZE {
base[coord][j] += j as u16;
}
}

for i in 0..ROOM_SIZE {
assert_eq!(base[i as usize * 50], i + 1);
}
assert_eq!(
(0..ROOM_AREA as u16).collect::<Vec<u16>>().as_slice(),
base.as_slice()
);
}
}

0 comments on commit 619c188

Please sign in to comment.