From 0ceaba1da92abbc1eb42fa125ae66971c22ea4ea Mon Sep 17 00:00:00 2001 From: Christophe Date: Thu, 21 Dec 2023 18:02:00 +0100 Subject: [PATCH] Nan is not supported with C++98 --- test/ext/ext_scalar_common.cpp | 69 +++++++++++++++++++--------------- 1 file changed, 38 insertions(+), 31 deletions(-) diff --git a/test/ext/ext_scalar_common.cpp b/test/ext/ext_scalar_common.cpp index 917a242e..0e24cf34 100644 --- a/test/ext/ext_scalar_common.cpp +++ b/test/ext/ext_scalar_common.cpp @@ -38,35 +38,6 @@ static int test_min() return Error; } -template -static int test_min_nan() -{ - int Error = 0; - - T const B = static_cast(1); - T const N = static_cast(GLM_NAN(T)); - Error += glm::isnan(glm::min(N, B)) ? 0 : 1; - Error += !glm::isnan(glm::min(B, N)) ? 0 : 1; - - T const C = static_cast(2); - Error += glm::isnan(glm::min(N, B, C)) ? 0 : 1; - Error += !glm::isnan(glm::min(B, N, C)) ? 0 : 1; - Error += !glm::isnan(glm::min(C, N, B)) ? 0 : 1; - Error += !glm::isnan(glm::min(C, B, N)) ? 0 : 1; - Error += !glm::isnan(glm::min(B, C, N)) ? 0 : 1; - Error += glm::isnan(glm::min(N, C, B)) ? 0 : 1; - - T const D = static_cast(3); - Error += !glm::isnan(glm::min(D, N, B, C)) ? 0 : 1; - Error += !glm::isnan(glm::min(B, D, N, C)) ? 0 : 1; - Error += !glm::isnan(glm::min(C, N, D, B)) ? 0 : 1; - Error += !glm::isnan(glm::min(C, B, D, N)) ? 0 : 1; - Error += !glm::isnan(glm::min(B, C, N, D)) ? 0 : 1; - Error += glm::isnan(glm::min(N, C, B, D)) ? 0 : 1; - - return Error; -} - template static int test_max() { @@ -96,6 +67,36 @@ static int test_max() return Error; } +#if ((GLM_LANG & GLM_LANG_CXX11_FLAG) || (GLM_COMPILER & GLM_COMPILER_VC)) +template +static int test_min_nan() +{ + int Error = 0; + + T const B = static_cast(1); + T const N = static_cast(GLM_NAN(T)); + Error += glm::isnan(glm::min(N, B)) ? 0 : 1; + Error += !glm::isnan(glm::min(B, N)) ? 0 : 1; + + T const C = static_cast(2); + Error += glm::isnan(glm::min(N, B, C)) ? 0 : 1; + Error += !glm::isnan(glm::min(B, N, C)) ? 0 : 1; + Error += !glm::isnan(glm::min(C, N, B)) ? 0 : 1; + Error += !glm::isnan(glm::min(C, B, N)) ? 0 : 1; + Error += !glm::isnan(glm::min(B, C, N)) ? 0 : 1; + Error += glm::isnan(glm::min(N, C, B)) ? 0 : 1; + + T const D = static_cast(3); + Error += !glm::isnan(glm::min(D, N, B, C)) ? 0 : 1; + Error += !glm::isnan(glm::min(B, D, N, C)) ? 0 : 1; + Error += !glm::isnan(glm::min(C, N, D, B)) ? 0 : 1; + Error += !glm::isnan(glm::min(C, B, D, N)) ? 0 : 1; + Error += !glm::isnan(glm::min(B, C, N, D)) ? 0 : 1; + Error += glm::isnan(glm::min(N, C, B, D)) ? 0 : 1; + + return Error; +} + template static int test_max_nan() { @@ -182,6 +183,7 @@ static int test_fmax() return Error; } +#endif// static int test_clamp() { @@ -334,11 +336,15 @@ int main() Error += test_min(); Error += test_min(); - Error += test_min_nan(); - Error += test_min_nan(); + Error += test_max(); Error += test_max(); + +#if ((GLM_LANG & GLM_LANG_CXX11_FLAG) || (GLM_COMPILER & GLM_COMPILER_VC)) + Error += test_min_nan(); + Error += test_min_nan(); + Error += test_max_nan(); Error += test_max_nan(); @@ -347,6 +353,7 @@ int main() Error += test_fmax(); Error += test_fmax(); +#endif// Error += test_clamp(); Error += test_repeat();