From b2ba0c317da600630216956f6f4383088744af22 Mon Sep 17 00:00:00 2001 From: Groove Date: Sat, 28 Jul 2018 19:12:41 +0200 Subject: [PATCH] Fixed error: comparing floating point with == or != is unsafe --- test/core/core_type_vec3.cpp | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/test/core/core_type_vec3.cpp b/test/core/core_type_vec3.cpp index c3fad394..2e33ffe0 100644 --- a/test/core/core_type_vec3.cpp +++ b/test/core/core_type_vec3.cpp @@ -498,9 +498,9 @@ int test_vec3_swizzle_partial() # if GLM_SWIZZLE == GLM_SWIZZLE_OPERATOR { - glm::ivec3 const A(1, 2, 3); - glm::ivec3 B(A.xy, 3); - Error += A == B ? 0 : 1; + glm::vec3 const A(1, 2, 3); + glm::vec3 B(A.xy, 3); + Error += glm::all(glm::equal(A, B, glm::epsilon())) ? 0 : 1; } { @@ -561,13 +561,13 @@ static int test_swizzle() glm::vec3 G(A.xy, A.z); glm::vec3 H(A.xy(), A.z); - Error += glm::all(glm::equal(A, B)) ? 0 : 1; - Error += glm::all(glm::equal(A, C)) ? 0 : 1; - Error += glm::all(glm::equal(A, D)) ? 0 : 1; - Error += glm::all(glm::equal(A, E)) ? 0 : 1; - Error += glm::all(glm::equal(A, F)) ? 0 : 1; - Error += glm::all(glm::equal(A, G)) ? 0 : 1; - Error += glm::all(glm::equal(A, H)) ? 0 : 1; + Error += glm::all(glm::equal(A, B, glm::epsilon())) ? 0 : 1; + Error += glm::all(glm::equal(A, C, glm::epsilon())) ? 0 : 1; + Error += glm::all(glm::equal(A, D, glm::epsilon())) ? 0 : 1; + Error += glm::all(glm::equal(A, E, glm::epsilon())) ? 0 : 1; + Error += glm::all(glm::equal(A, F, glm::epsilon())) ? 0 : 1; + Error += glm::all(glm::equal(A, G, glm::epsilon())) ? 0 : 1; + Error += glm::all(glm::equal(A, H, glm::epsilon())) ? 0 : 1; } # endif//GLM_SWIZZLE == GLM_SWIZZLE_OPERATOR @@ -582,13 +582,13 @@ static int test_swizzle() glm::vec3 G(A.xy(), A.z); glm::vec3 H(A.xy(), A.z); - Error += glm::all(glm::equal(A, B)) ? 0 : 1; - Error += glm::all(glm::equal(A, C)) ? 0 : 1; - Error += glm::all(glm::equal(A, D)) ? 0 : 1; - Error += glm::all(glm::equal(A, E)) ? 0 : 1; - Error += glm::all(glm::equal(A, F)) ? 0 : 1; - Error += glm::all(glm::equal(A, G)) ? 0 : 1; - Error += glm::all(glm::equal(A, H)) ? 0 : 1; + Error += glm::all(glm::equal(A, B, glm::epsilon())) ? 0 : 1; + Error += glm::all(glm::equal(A, C, glm::epsilon())) ? 0 : 1; + Error += glm::all(glm::equal(A, D, glm::epsilon())) ? 0 : 1; + Error += glm::all(glm::equal(A, E, glm::epsilon())) ? 0 : 1; + Error += glm::all(glm::equal(A, F, glm::epsilon())) ? 0 : 1; + Error += glm::all(glm::equal(A, G, glm::epsilon())) ? 0 : 1; + Error += glm::all(glm::equal(A, H, glm::epsilon())) ? 0 : 1; } # endif//GLM_SWIZZLE == GLM_SWIZZLE_OPERATOR || GLM_SWIZZLE == GLM_SWIZZLE_FUNCTION