Trait ValidateResult
pub trait ValidateResult
Compare two objects, but with a few special quirks. Intended mainly for unit testing.
Required Methods
fn validate_result(&self, lossy_result: &Self, options: ValidationOptions, context: impl Fn() -> String) -> ValidationResultCompare self with the other. Exceptional behaviour:
- Any two NaN values are considered equal, regardless of bit representation.
- If a
lossyis specified, any two values that differ only by a small amount will be considered equal. - If
nan_to_zerois true, and self is NaN/Infinite and the other value is zero, they are considered equal (because some compression methods replace nan with zero)
This does not work the other way around! This method is not symmetrical!
Provided Methods
fn assert_equals_result(&self, result: &Self)Compare self with the other. Panics if not equal.
Exceptional behaviour: This does not work the other way around! This method is not symmetrical! Returns whether the result is correct for this image. For lossy compression methods, uses approximate equality. Intended for unit testing.
Warning: If you use
SpecificChannels, the comparison might be inaccurate for images with mixed compression methods. This is to be used withAnyChannelsmainly.fn assert_approx_equals_result(&self, result: &Self)Like
Self::assert_equals_result, but uses approximate (lossy) comparison for floating point values. Panics if they are not approximately equal.This is the single definitive helper for "a bunch of floats are approximately equal" checks in tests: it applies the same adaptive tolerance (
0.06 * (|a| + |b|), floored at0.1) that whole-image lossy comparison uses. Works onf32/f16, on slices/Vecs of them, and on the whole image types.
Implementors
impl ValidateResult for FlatSamplesimpl ValidateResult for NoneMoreimpl ValidateResult for Sampleimpl ValidateResult for f16impl ValidateResult for f32impl ValidateResult for u32impl<A> ValidateResult for Vec<A> where A: ValidateResult,impl<A, B, C> ValidateResult for (A, B, C) where A: Clone + ValidateResult, B: Clone + ValidateResult, C: Clone + ValidateResult,impl<A, B, C, D> ValidateResult for (A, B, C, D) where A: Clone + ValidateResult, B: Clone + ValidateResult, C: Clone + ValidateResult, D: Clone + ValidateResult,impl<A: Array> ValidateResult for SmallVec<A> where A::Item: ValidateResult,impl<C> ValidateResult for Image<C> where C: ValidateResult,impl<Inner, T> ValidateResult for Recursive<Inner, T> where Inner: ValidateResult, T: ValidateResult,impl<Px> ValidateResult for PixelVec<Px> where Px: ValidateResult,impl<Px, Desc> ValidateResult for Layer<SpecificChannels<Px, Desc>> where SpecificChannels<Px, Desc>: ValidateResult,impl<Pxs, Chans> ValidateResult for SpecificChannels<Pxs, Chans> where Pxs: ValidateResult, Chans: Eq,impl<S> ValidateResult for AnyChannel<S> where S: ValidateResult,impl<S> ValidateResult for AnyChannels<S> where S: ValidateResult,impl<S> ValidateResult for Layer<AnyChannels<S>> where AnyChannel<S>: ValidateResult, S: for<'a> WritableSamples<'a>,impl<S> ValidateResult for Levels<S> where S: ValidateResult,impl<S> ValidateResult for Option<S> where S: ValidateResult,impl<T> ValidateResult for &[T] where T: ValidateResult,