diff options
| author | alf9310 <alf9310@rit.edu> | 2025-11-09 17:37:23 -0500 |
|---|---|---|
| committer | alf9310 <alf9310@rit.edu> | 2025-11-09 17:37:23 -0500 |
| commit | 096ff7a891c350da000f18f01ffb4a1f9cde0899 (patch) | |
| tree | 50132ffbfb2f5572ce4e52c0c06cc4abbb3508c8 /dungeon/tests | |
| parent | dungeon_generation: added stair generation and fixed room center vs rabdom po... (diff) | |
| download | DungeonCrawl-096ff7a891c350da000f18f01ffb4a1f9cde0899.tar.gz DungeonCrawl-096ff7a891c350da000f18f01ffb4a1f9cde0899.tar.bz2 DungeonCrawl-096ff7a891c350da000f18f01ffb4a1f9cde0899.zip | |
dungeon_generation: added Hallway vs Room tiles
Diffstat (limited to 'dungeon/tests')
| -rw-r--r-- | dungeon/tests/bsp_tests.rs | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/dungeon/tests/bsp_tests.rs b/dungeon/tests/bsp_tests.rs index 6bd0153..16a8a77 100644 --- a/dungeon/tests/bsp_tests.rs +++ b/dungeon/tests/bsp_tests.rs @@ -22,8 +22,26 @@ mod tests { // Ensure player start is within bounds assert!(player_start.x() < map::MAP_SIZE); assert!(player_start.y() < map::MAP_SIZE); - // Ensure player start is an air tile + // Ensure player start is a room tile let idx = player_start.idx(); - assert_eq!(tiles[idx], map::Tile::Air); + assert_eq!(tiles[idx], map::Tile::Room); + } + + /// Test that BSP-generated floors have at least two rooms + #[test] + fn test_bsp_2_or_more_rooms() { + let seed = 12345u64; + let (tiles, _player_start) = bsp::generate(seed); + // Ensure we have at least two rooms + let mut room_count = 0; + let mut visited = vec![false; tiles.len()]; + for (i, &tile) in tiles.iter().enumerate() { + if tile == map::Tile::Room && !visited[i] { + room_count += 1; + // Mark all connected tiles as visited + visited[i] = true; + } + } + assert!(room_count >= 2); } } |