From: Scott Worley Date: Mon, 17 Jul 2023 20:31:05 +0000 (-0700) Subject: Test with multiple players X-Git-Url: http://git.scottworley.com/pluta-lesnura/commitdiff_plain/7d0aa2d61de043373796dd07a4d8467e1463ef95?ds=sidebyside Test with multiple players --- diff --git a/src/lib.rs b/src/lib.rs index c73c146..59a47a9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -490,8 +490,15 @@ mod tests { #[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()); + } } }