Skip to content

Commit

Permalink
chore: add test pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
progre committed Aug 5, 2024
1 parent d26a3de commit ad5760c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src-tauri/src/randomizer/randomize_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,15 @@ mod tests {
let opts = RandomizeOptions {
seed: i.to_string(),
shuffle_secret_roms: true,
need_glitches: false,
need_glitches: true,
absolutely_shuffle: false,
};
let source = create_source(&game_structure, &opts)?;
let (_, _) = shuffle(&source, &opts);
let (_, spoiler_log) = shuffle(&source, &opts);
assert_eq!(
spoiler_log.count_checkpoints(),
source.all_items().count() + source.events.len()
);
}

Ok(())
Expand Down
8 changes: 8 additions & 0 deletions src-tauri/src/randomizer/spoiler_log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,4 +231,12 @@ impl SpoilerLogRef<'_> {
.collect(),
}
}

pub fn count_checkpoints(&self) -> usize {
self.progression
.iter()
.map(|sphere| sphere.0.len())
.sum::<usize>()
+ self.maps.len()
}
}

0 comments on commit ad5760c

Please sign in to comment.