From bc3edb0c0337ca0fbf0398ba721aba55a09022e1 Mon Sep 17 00:00:00 2001
From: Guillaume Pasquet <dev@etenil.net>
Date: Fri, 3 Jan 2020 16:21:29 +0000
Subject: Change tests to not use #[should_panic] for travis

---
 src/world.rs | 44 +++++++++++++++++++++++++-------------------
 1 file changed, 25 insertions(+), 19 deletions(-)

(limited to 'src/world.rs')

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]
-- 
cgit v1.2.3