Skip to content

Commit

Permalink
fix: eliminate all ROOM_SIZE-related literals
Browse files Browse the repository at this point in the history
Less buggy if we avoid literals and use the constant everywhere.
  • Loading branch information
khoover authored Oct 14, 2024
1 parent b27b803 commit fb107cd
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/local/room_coordinate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ mod test {
}
base.iter()
.copied()
.zip(1..51)
.zip(1..(ROOM_SIZE + 1))
.for_each(|(actual, expected)| assert_eq!(actual, expected));
}

Expand All @@ -254,13 +254,13 @@ mod test {
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 u16 * 50;
base[i * ROOM_USIZE + j] = i as u16 * ROOM_SIZE as u16;
}
}

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

0 comments on commit fb107cd

Please sign in to comment.