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:
@ -44,4 +44,27 @@ impl<T> Lottery<T> {
|
|||||||
.unwrap_or_else(|i| i.saturating_sub(1))]
|
.unwrap_or_else(|i| i.saturating_sub(1))]
|
||||||
.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
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user