Add a test for the loot table's validity

This commit is contained in:
Piotr Korgól 2020-07-05 18:49:15 +02:00
parent d0b7958309
commit 713d0c5e8a

View File

@ -44,4 +44,27 @@ impl<T> Lottery<T> {
.unwrap_or_else(|i| i.saturating_sub(1))]
.1
}
pub fn iter(&self) -> impl Iterator<Item = &(f32, T)> { self.items.iter() }
}
#[cfg(test)]
mod tests {
use crate::{
assets,
comp::inventory::item::{lottery::Lottery, Item},
};
#[test]
fn test_loot_table() {
let test = assets::load_expect::<Lottery<_>>("common.loot_table");
let test = test;
for (_, item) in test.iter() {
assert!(
assets::load::<Item>(item).is_ok(),
"Invalid loot table item '{}'",
item
);
}
}
}