diff --git a/crates/gc-formats/src/texture.rs b/crates/gc-formats/src/texture.rs index a8c45c8..a321b99 100644 --- a/crates/gc-formats/src/texture.rs +++ b/crates/gc-formats/src/texture.rs @@ -273,12 +273,18 @@ mod tests { } #[test] - fn alpha_is_scaled_from_eight_bit_halves() { + fn alpha_runs_zero_to_0x80_and_scales_to_0xff() { assert_eq!(scale_alpha(0), 0); assert_eq!(scale_alpha(0x40), 0x80); - assert_eq!(scale_alpha(0x7f), 0xfe); + // 0x7F is 127/128, which is 253 and not 0xFE. This test was called + // `alpha_is_scaled_from_eight_bit_halves` and asserted 0xfe, pinning the + // `a * 2` implementation -- it had the bug in its name as well as its + // assertion. The rule is /128 * 255, not a doubling. + assert_eq!(scale_alpha(0x7f), 0xfd); assert_eq!(scale_alpha(0x80), 0xff); assert_eq!(scale_alpha(0xff), 0xff); + // A doubling cannot produce this, and the disc contains it. + assert_eq!(scale_alpha(0x7e), 0xfb); } /// A 2x1 image whose two texels select distinct CLUT entries.