]> git.scottworley.com Git - pluta-lesnura/commitdiff
Test with multiple players
authorScott Worley <scottworley@scottworley.com>
Mon, 17 Jul 2023 20:31:05 +0000 (13:31 -0700)
committerScott Worley <scottworley@scottworley.com>
Mon, 17 Jul 2023 20:31:05 +0000 (13:31 -0700)
src/lib.rs

index c73c146dceef08cb2142ec86418cd76f5d847980..59a47a9d0eb9056c49bb2ae83a97b282c326f12f 100644 (file)
@@ -490,8 +490,15 @@ mod tests {
 
     #[test]
     fn test_game() {
 
     #[test]
     fn test_game() {
-        let mut game = Game::default();
-        game.add_player();
-        assert!(play(game, vec![Player(Box::new(random_player))]).is_ok());
+        for num_players in 1..10 {
+            let players: Vec<_> = std::iter::from_fn(|| Some(Player(Box::new(random_player))))
+                .take(num_players)
+                .collect();
+            let mut game = Game::default();
+            for _ in 0..num_players {
+                game.add_player();
+            }
+            assert!(play(game, players).is_ok());
+        }
     }
 }
     }
 }