From 6c84fb2f1e3cc77dcf6ba9e6e9e1bbcd56571dd9 Mon Sep 17 00:00:00 2001 From: jake Date: Mon, 13 Apr 2020 01:01:41 -0700 Subject: [PATCH] add drop table init test --- src/ship/drops/mod.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/ship/drops/mod.rs b/src/ship/drops/mod.rs index b76d740..294eed4 100644 --- a/src/ship/drops/mod.rs +++ b/src/ship/drops/mod.rs @@ -174,3 +174,22 @@ impl DropTable { self.box_table.get_drop(map_area, object, &mut self.rng) } } + + +#[cfg(test)] +mod test { + use super::*; + use rand::seq::IteratorRandom; + + #[test] + fn test_initializing_drop_table() { + let mut rng = rand_chacha::ChaCha20Rng::from_entropy(); + let episode = vec![Episode::One, Episode::Two].into_iter().choose(&mut rng).unwrap(); + let difficulty = vec![Difficulty::Normal, Difficulty::Hard, Difficulty::VeryHard, Difficulty::Ultimate] + .into_iter().choose(&mut rng).unwrap(); + let section_id = vec![SectionID::Viridia, SectionID::Greenill, SectionID::Skyly, SectionID::Bluefull, SectionID::Purplenum, + SectionID::Pinkal, SectionID::Redria, SectionID::Oran, SectionID::Yellowboze, SectionID::Whitill] + .into_iter().choose(&mut rng).unwrap(); + DropTable::::new(episode, difficulty, section_id); + } +}