mirror of
https://github.com/Xevion/Pac-Man.git
synced 2025-12-10 20:07:53 -06:00
test: remove asset.rs tests, revamp constants tests
This commit is contained in:
@@ -1,14 +0,0 @@
|
|||||||
use pacman::asset::Asset;
|
|
||||||
use std::path::Path;
|
|
||||||
use strum::IntoEnumIterator;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_asset_paths_valid() {
|
|
||||||
let base_path = Path::new("assets/game/");
|
|
||||||
|
|
||||||
for asset in Asset::iter() {
|
|
||||||
let path = base_path.join(asset.path());
|
|
||||||
assert!(path.exists(), "Asset path does not exist: {:?}", path);
|
|
||||||
assert!(path.is_file(), "Asset path is not a file: {:?}", path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,27 +2,34 @@ use pacman::constants::*;
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_raw_board_structure() {
|
fn test_raw_board_structure() {
|
||||||
|
// Test board dimensions match expected size
|
||||||
assert_eq!(RAW_BOARD.len(), BOARD_CELL_SIZE.y as usize);
|
assert_eq!(RAW_BOARD.len(), BOARD_CELL_SIZE.y as usize);
|
||||||
|
|
||||||
for row in RAW_BOARD.iter() {
|
for row in RAW_BOARD.iter() {
|
||||||
assert_eq!(row.len(), BOARD_CELL_SIZE.x as usize);
|
assert_eq!(row.len(), BOARD_CELL_SIZE.x as usize);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test boundaries
|
// Test boundaries are properly walled
|
||||||
assert!(RAW_BOARD[0].chars().all(|c| c == '#'));
|
assert!(RAW_BOARD[0].chars().all(|c| c == '#'));
|
||||||
assert!(RAW_BOARD[RAW_BOARD.len() - 1].chars().all(|c| c == '#'));
|
assert!(RAW_BOARD[RAW_BOARD.len() - 1].chars().all(|c| c == '#'));
|
||||||
|
|
||||||
// Test tunnel row
|
|
||||||
let tunnel_row = RAW_BOARD[14];
|
|
||||||
assert_eq!(tunnel_row.chars().next().unwrap(), 'T');
|
|
||||||
assert_eq!(tunnel_row.chars().last().unwrap(), 'T');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_raw_board_content() {
|
fn test_raw_board_contains_required_elements() {
|
||||||
let power_pellet_count = RAW_BOARD.iter().flat_map(|row| row.chars()).filter(|&c| c == 'o').count();
|
// Test that essential game elements are present
|
||||||
assert_eq!(power_pellet_count, 4);
|
assert!(
|
||||||
|
RAW_BOARD.iter().any(|row| row.contains('X')),
|
||||||
assert!(RAW_BOARD.iter().any(|row| row.contains('X')));
|
"Board should contain Pac-Man start position"
|
||||||
assert!(RAW_BOARD.iter().any(|row| row.contains("==")));
|
);
|
||||||
|
assert!(
|
||||||
|
RAW_BOARD.iter().any(|row| row.contains("==")),
|
||||||
|
"Board should contain ghost house door"
|
||||||
|
);
|
||||||
|
assert!(
|
||||||
|
RAW_BOARD.iter().any(|row| row.chars().any(|c| c == 'T')),
|
||||||
|
"Board should contain tunnel entrances"
|
||||||
|
);
|
||||||
|
assert!(
|
||||||
|
RAW_BOARD.iter().any(|row| row.chars().any(|c| c == 'o')),
|
||||||
|
"Board should contain power pellets"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user