mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Add a test for the loot table's validity
This commit is contained in:
parent
d0b7958309
commit
713d0c5e8a
@ -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
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user