MCPcopy Create free account
hub / github.com/ImageOptim/libimagequant / pal_test

Function pal_test

src/pal.rs:417–442  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

415
416#[test]
417fn pal_test() {
418 let mut p = PalF::new();
419 let gamma = gamma_lut(0.45455);
420 for i in 0..=255u8 {
421 let rgba = RGBA::new(i, i, i, 100 + i / 2);
422 p.push(f_pixel::from_rgba(&gamma, rgba), PalPop::new(1.));
423 assert_eq!(i as usize + 1, p.len());
424 assert_eq!(i as usize + 1, p.pop_as_slice().len());
425 assert_eq!(i as usize + 1, p.as_slice().len());
426 assert_eq!(i as usize + 1, p.colors.len());
427 assert_eq!(i as usize + 1, p.pops.len());
428 assert_eq!(i as usize + 1, p.iter_mut().count());
429 }
430
431 let mut int_pal = Palette {
432 count: 0,
433 entries: [RGBA::default(); MAX_COLORS],
434 };
435 p.init_int_palette(&mut int_pal, 0.45455, 0);
436
437 for i in 0..=255u8 {
438 let rgba = p.as_slice()[i as usize].to_rgb(0.45455);
439 assert_eq!(rgba, RGBA::new(i, i, i, 100 + i / 2));
440 assert_eq!(int_pal[i as usize], RGBA::new(i, i, i, 100 + i / 2));
441 }
442}
443
444#[test]
445#[cfg(feature = "large_palettes")]

Callers

nothing calls this directly

Calls 6

newFunction · 0.85
gamma_lutFunction · 0.85
pushMethod · 0.80
init_int_paletteMethod · 0.80
to_rgbMethod · 0.80
as_sliceMethod · 0.45

Tested by

no test coverage detected