From 6c981b07c1ab6ba619f1c10528691a3f820da566 Mon Sep 17 00:00:00 2001 From: Groove Date: Sat, 28 Jul 2018 19:55:36 +0200 Subject: [PATCH] Fixed error: comparing floating point with == or != is unsafe --- test/core/core_type_cast.cpp | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/test/core/core_type_cast.cpp b/test/core/core_type_cast.cpp index b1c02910..7ff1901e 100644 --- a/test/core/core_type_cast.cpp +++ b/test/core/core_type_cast.cpp @@ -1,3 +1,5 @@ +#include +#include #include #include #include @@ -27,10 +29,10 @@ int test_vec2_cast() int Error(0); - Error += glm::all(glm::equal(A, E)) ? 0 : 1; - Error += glm::all(glm::equal(B, F)) ? 0 : 1; - Error += glm::all(glm::equal(C, G)) ? 0 : 1; - Error += glm::all(glm::equal(D, H)) ? 0 : 1; + Error += glm::all(glm::equal(A, E, glm::epsilon())) ? 0 : 1; + Error += glm::all(glm::equal(B, F, glm::epsilon())) ? 0 : 1; + Error += glm::all(glm::equal(C, G, glm::epsilon())) ? 0 : 1; + Error += glm::all(glm::equal(D, H, glm::epsilon())) ? 0 : 1; return Error; } @@ -49,10 +51,10 @@ int test_vec3_cast() int Error(0); - Error += glm::all(glm::equal(A, E)) ? 0 : 1; - Error += glm::all(glm::equal(B, F)) ? 0 : 1; - Error += glm::all(glm::equal(C, G)) ? 0 : 1; - Error += glm::all(glm::equal(D, H)) ? 0 : 1; + Error += glm::all(glm::equal(A, E, glm::epsilon())) ? 0 : 1; + Error += glm::all(glm::equal(B, F, glm::epsilon())) ? 0 : 1; + Error += glm::all(glm::equal(C, G, glm::epsilon())) ? 0 : 1; + Error += glm::all(glm::equal(D, H, glm::epsilon())) ? 0 : 1; return Error; } @@ -71,10 +73,10 @@ int test_vec4_cast() int Error(0); - Error += glm::all(glm::equal(A, E)) ? 0 : 1; - Error += glm::all(glm::equal(B, F)) ? 0 : 1; - Error += glm::all(glm::equal(C, G)) ? 0 : 1; - Error += glm::all(glm::equal(D, H)) ? 0 : 1; + Error += glm::all(glm::equal(A, E, glm::epsilon())) ? 0 : 1; + Error += glm::all(glm::equal(B, F, glm::epsilon())) ? 0 : 1; + Error += glm::all(glm::equal(C, G, glm::epsilon())) ? 0 : 1; + Error += glm::all(glm::equal(D, H, glm::epsilon())) ? 0 : 1; return Error; }