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

Function r_callback_test

src/lib.rs:203–230  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

201
202#[test]
203fn r_callback_test() {
204 use std::mem::MaybeUninit;
205 use std::sync::atomic::AtomicU16;
206 use std::sync::atomic::Ordering::SeqCst;
207 use std::sync::Arc;
208
209 let called = Arc::new(AtomicU16::new(0));
210 let called2 = called.clone();
211 let mut res = {
212 let a = new();
213 let get_row = move |output_row: &mut [MaybeUninit<RGBA>], y: usize| {
214 assert!((0..5).contains(&y));
215 assert_eq!(123, output_row.len());
216 for (n, out) in output_row.iter_mut().enumerate() {
217 let n = n as u8;
218 out.write(RGBA::new(n, n, n, n));
219 }
220 called2.fetch_add(1, SeqCst);
221 };
222 let mut img = unsafe {
223 Image::new_fn(&a, get_row, 123, 5, 0.).unwrap()
224 };
225 a.quantize(&mut img).unwrap()
226 };
227 let called = called.load(SeqCst);
228 assert!(called > 5 && called < 50);
229 assert_eq!(123, res.palette().len());
230}
231
232#[test]
233fn sizes() {

Callers

nothing calls this directly

Calls 5

newFunction · 0.85
iter_mutMethod · 0.80
writeMethod · 0.80
cloneMethod · 0.45
quantizeMethod · 0.45

Tested by

no test coverage detected