From 80342f9dc367bd34cc263ea3120735362159c34b Mon Sep 17 00:00:00 2001 From: Martin Date: Tue, 12 Dec 2023 20:28:15 +0100 Subject: [PATCH] [Tests] Fix tests checking 0.5 value in uint8 texture --- src/Tests/Aardvark.Rendering.Tests/Tests/Texture/Clear.fs | 4 ++-- src/Tests/Aardvark.Rendering.Tests/Tests/Utilities.fs | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Tests/Aardvark.Rendering.Tests/Tests/Texture/Clear.fs b/src/Tests/Aardvark.Rendering.Tests/Tests/Texture/Clear.fs index 1b4a3f92..714bfb9f 100644 --- a/src/Tests/Aardvark.Rendering.Tests/Tests/Texture/Clear.fs +++ b/src/Tests/Aardvark.Rendering.Tests/Tests/Texture/Clear.fs @@ -23,7 +23,7 @@ module TextureClear = let rgba8 (runtime : IRuntime) = let data = createAndClearColor runtime TextureFormat.Rgba8 <| C3f(0.5) - data.AsPixImage() |> PixImage.isColor (C4b(127uy).ToArray()) + data.AsPixImage() |> PixImage.isColorWithDist 1L (C4b(127uy).ToArray()) let rgba32i (runtime : IRuntime) = let data = createAndClearColor runtime TextureFormat.Rgba32i <| V4i(-1) @@ -135,7 +135,7 @@ module TextureClear = do let c = C4b(127uy) let pi = textures.[c3].Download().AsPixImage() - pi |> PixImage.isColor (c.ToArray()) + pi |> PixImage.isColorWithDist 1L (c.ToArray()) do let c = C3b.AliceBlue |> V4i diff --git a/src/Tests/Aardvark.Rendering.Tests/Tests/Utilities.fs b/src/Tests/Aardvark.Rendering.Tests/Tests/Utilities.fs index b0826532..ec670a08 100644 --- a/src/Tests/Aardvark.Rendering.Tests/Tests/Utilities.fs +++ b/src/Tests/Aardvark.Rendering.Tests/Tests/Utilities.fs @@ -230,6 +230,9 @@ module PixData = let isColor (color : 'T[]) (pi : PixImage<'T>) = isColorWithComparer Expect.equal color pi + let inline isColorWithDist (maxDist : int64) (color : 'T[]) (pi : PixImage<'T>) = + isColorWithComparer (fun x y -> Expect.isLessThanOrEqual (abs (int64 x - int64 y)) maxDist) color pi + let isColor32f (accuracy : Accuracy) (color : float32[]) (pi : PixImage) = let comp a b = Expect.floatClose accuracy (float a) (float b) isColorWithComparer comp color pi