mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 00:01:34 +11:00
report mismatch counts
This commit is contained in:
parent
5fc302dec9
commit
11fc38d840
|
@ -1066,15 +1066,22 @@ mod tests {
|
|||
let number_of_levels = crate::level::Level::num_levels();
|
||||
let mut failed_levels = Vec::new();
|
||||
|
||||
#[derive(Debug)]
|
||||
#[allow(dead_code)]
|
||||
struct MismatchCount {
|
||||
given: i32,
|
||||
used: i32,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
enum CompleteSimulationResult {
|
||||
Success,
|
||||
ExplicitLoss,
|
||||
InputSequenceOver,
|
||||
MismatchedItems(HashMap<crate::level::Item, ()>),
|
||||
MismatchedItems(HashMap<crate::level::Item, MismatchCount>),
|
||||
}
|
||||
|
||||
fn check_level_has_valid_items(level: usize) -> HashMap<crate::level::Item, ()> {
|
||||
fn check_level_has_valid_items(level: usize) -> HashMap<crate::level::Item, MismatchCount> {
|
||||
let level = crate::level::Level::get_level(level);
|
||||
|
||||
let mut given_items = HashMap::new();
|
||||
|
@ -1092,8 +1099,15 @@ mod tests {
|
|||
let mut mismatched = HashMap::new();
|
||||
|
||||
for (&item, &count) in solution_items.iter() {
|
||||
if *given_items.entry(item).or_insert(0) < count {
|
||||
mismatched.insert(item, ());
|
||||
let given_count = given_items.get(&item).copied().unwrap_or(0);
|
||||
if given_count < count {
|
||||
mismatched.insert(
|
||||
item,
|
||||
MismatchCount {
|
||||
given: given_count,
|
||||
used: count,
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue