MCPcopy Index your code
hub / github.com/ImageOptim/libimagequant / c_callback_test_c

Function c_callback_test_c

imagequant-sys/src/ffi.rs:759–781  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

757
758#[test]
759fn c_callback_test_c() {
760 use std::mem::MaybeUninit;
761
762 let mut called = 0;
763 let mut res = unsafe {
764 let mut a = liq_attr_create().unwrap();
765 unsafe extern "C" fn get_row(output_row: *mut MaybeUninit<RGBA>, y: c_int, width: c_int, user_data: AnySyncSendPtr) {
766 assert!((0..5).contains(&y));
767 assert_eq!(123, width);
768 for i in 0..width as isize {
769 let n = i as u8;
770 (*output_row.offset(i)).write(RGBA::new(n, n, n, n));
771 }
772 let user_data = user_data.0.cast::<i32>();
773 *user_data += 1;
774 }
775 let mut img = liq_image_create_custom(&a, get_row, AnySyncSendPtr(std::ptr::addr_of_mut!(called).cast::<c_void>()), 123, 5, 0.).unwrap();
776 liq_quantize_image(&mut a, &mut img).unwrap()
777 };
778 assert!(called > 5 && called < 50);
779 let pal = liq_get_palette(&mut res).unwrap();
780 assert_eq!(123, pal.count);
781}
782
783
784

Callers

nothing calls this directly

Calls 5

liq_attr_createFunction · 0.85
liq_image_create_customFunction · 0.85
AnySyncSendPtrClass · 0.85
liq_quantize_imageFunction · 0.85
liq_get_paletteFunction · 0.85

Tested by

no test coverage detected