Extract method for checking palette invariants

This commit is contained in:
Gwilym Inzani 2024-09-25 11:44:16 +01:00
parent c834e2907d
commit edb628d0b2

View file

@ -228,8 +228,18 @@ mod test {
return false
};
for (i, palette) in palettes.into_iter().take(16).enumerate() {
let optimised_palette = &optimisation_results.optimised_palettes[optimisation_results.assignments[i]];
check_palette_invariants(palettes.iter().take(16), optimisation_results, transparent_colour)
}
}
fn check_palette_invariants<'a>(
palettes: impl Iterator<Item = &'a Palette16>,
optimisation_results: Palette16OptimisationResults,
transparent_colour: Colour,
) -> bool {
for (i, palette) in palettes.enumerate() {
let optimised_palette =
&optimisation_results.optimised_palettes[optimisation_results.assignments[i]];
if !palette.is_satisfied_by(optimised_palette) {
return false;
}
@ -241,7 +251,6 @@ mod test {
true
}
}
impl Arbitrary for Palette16 {
fn arbitrary(g: &mut quickcheck::Gen) -> Self {