From 36558fe1811d48c57dddb27d8501e7bb7334df30 Mon Sep 17 00:00:00 2001 From: ulises-jeremias Date: Sat, 6 Jan 2024 02:09:34 -0300 Subject: [PATCH] Refactor perlin2d and perlin3d test functions to use float64 tolerance --- noise/perlin2d_test.v | 9 +++++---- noise/perlin3d_test.v | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/noise/perlin2d_test.v b/noise/perlin2d_test.v index 1b4ef4c88..410bd4327 100644 --- a/noise/perlin2d_test.v +++ b/noise/perlin2d_test.v @@ -1,14 +1,15 @@ module noise -import math { abs } import rand - -const single_perlin = f64(0.4948387311305851) +import vsl.float.float64 fn test_perlin2d() { rand.seed([u32(3155200429), u32(3208395956)]) mut gen := Perlin{} gen.randomize() - assert abs(gen.perlin2d(0.125, 0.125) - noise.single_perlin) < 1.0e-6 + result := gen.perlin2d(0.125, 0.125) + expected := 0.4948387311305851 + + assert float64.tolerance(result, expected, 1.0e-6) } diff --git a/noise/perlin3d_test.v b/noise/perlin3d_test.v index 6a34998a7..ceb3061e5 100644 --- a/noise/perlin3d_test.v +++ b/noise/perlin3d_test.v @@ -1,14 +1,15 @@ module noise -import math { abs } import rand - -const single_perlin_3d = f64(0.3713334855776509) +import vsl.float.float64 fn test_perlin3d() { rand.seed([u32(3155200429), u32(3208395956)]) mut gen := Perlin{} gen.randomize() - assert abs(gen.perlin3d(0.125, 0.125, 0.125) - noise.single_perlin_3d) < 1.0e-6 + result := gen.perlin3d(0.125, 0.125, 0.125) + expected := 0.3713334855776509 + + assert float64.tolerance(result, expected, 1.0e-6) }