From 619c1888bbe455ba1e097a0454ff9b37a5234c1e Mon Sep 17 00:00:00 2001 From: Ken Hoover Date: Sun, 13 Oct 2024 21:20:04 -0700 Subject: [PATCH] test: refine the room area test --- src/local/room_coordinate.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/local/room_coordinate.rs b/src/local/room_coordinate.rs index 9e3167ac..26bcb634 100644 --- a/src/local/room_coordinate.rs +++ b/src/local/room_coordinate.rs @@ -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::>().as_slice(), + base.as_slice() + ); } }