aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Pasquet <dev@etenil.net>2020-01-03 16:21:29 +0000
committerGuillaume Pasquet <dev@etenil.net>2020-01-03 16:21:29 +0000
commitbc3edb0c0337ca0fbf0398ba721aba55a09022e1 (patch)
tree3fd7bbfb2eb5a19f58e3c828029bbd07ebc4bfb2
parent61efc432f5b6cbd3b580bdb330507661a3213222 (diff)
Change tests to not use #[should_panic] for travis
-rw-r--r--src/world.rs44
1 files changed, 25 insertions, 19 deletions
diff --git a/src/world.rs b/src/world.rs
index 507e6b8..af72513 100644
--- a/src/world.rs
+++ b/src/world.rs
@@ -310,7 +310,11 @@ impl Level {
corridor.tile(&mut grid)?;
}
- grid.set_tile(self.entrance.0, self.entrance.1, Tile::from(TileType::StairsUp));
+ grid.set_tile(
+ self.entrance.0,
+ self.entrance.1,
+ Tile::from(TileType::StairsUp),
+ );
grid.set_tile(self.exit.0, self.exit.1, Tile::from(TileType::StairsDown));
Ok(grid)
@@ -426,20 +430,18 @@ impl Generatable for Level {
let room = &self.rooms[rng.gen_range(0, self.rooms.len() - 1)];
// Create the enemy
- self.entities.push(Box::<Character>::new(
- Enemy::new(
- String::from("snake"),
- 2 * self.depth as i32,
- (2.0 * self.depth as f32 * 0.6).round() as i32,
- (20.0 * self.depth as f32 * 0.2).max(80.0).round() as i32,
- 0,
- (
- room.start.0 + rng.gen_range(0, room.width),
- room.start.1 + rng.gen_range(0, room.height),
- ),
- "s",
- )
- ));
+ self.entities.push(Box::<Character>::new(Enemy::new(
+ String::from("snake"),
+ 2 * self.depth as i32,
+ (2.0 * self.depth as f32 * 0.6).round() as i32,
+ (20.0 * self.depth as f32 * 0.2).max(80.0).round() as i32,
+ 0,
+ (
+ room.start.0 + rng.gen_range(0, room.width),
+ room.start.1 + rng.gen_range(0, room.height),
+ ),
+ "s",
+ )));
}
}
}
@@ -467,15 +469,19 @@ mod tests {
}
#[test]
- #[should_panic]
fn test_make_corridor_with_overlapping_points_should_panic() {
- Corridor::make((0, 0), (0, 0)).unwrap();
+ match Corridor::make((0, 0), (0, 0)) {
+ Ok(_) => assert!(false),
+ Err(_) => assert!(true),
+ };
}
#[test]
- #[should_panic]
fn test_make_corridor_with_misaligned_points_should_panic() {
- Corridor::make((3, 3), (5, 5)).unwrap();
+ match Corridor::make((3, 3), (5, 5)) {
+ Ok(_) => assert!(false),
+ Err(_) => assert!(true),
+ };
}
#[test]