Skip to content

Commit

Permalink
Nan is not supported with C++98
Browse files Browse the repository at this point in the history
  • Loading branch information
christophe-lunarg committed Dec 21, 2023
1 parent c8dab3d commit 980d16e
Showing 1 changed file with 38 additions and 31 deletions.
69 changes: 38 additions & 31 deletions test/ext/ext_scalar_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,35 +38,6 @@ static int test_min()
return Error;
}

template <typename T>
static int test_min_nan()
{
int Error = 0;

T const B = static_cast<T>(1);
T const N = static_cast<T>(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<T>(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<T>(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 <typename T>
static int test_max()
{
Expand Down Expand Up @@ -96,6 +67,36 @@ static int test_max()
return Error;
}

#if ((GLM_LANG & GLM_LANG_CXX11_FLAG) || (GLM_COMPILER & GLM_COMPILER_VC))
template <typename T>
static int test_min_nan()
{
int Error = 0;

T const B = static_cast<T>(1);
T const N = static_cast<T>(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<T>(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<T>(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 <typename T>
static int test_max_nan()
{
Expand Down Expand Up @@ -182,6 +183,7 @@ static int test_fmax()

return Error;
}
#endif//

static int test_clamp()
{
Expand Down Expand Up @@ -334,11 +336,15 @@ int main()

Error += test_min<float>();
Error += test_min<double>();
Error += test_min_nan<float>();
Error += test_min_nan<double>();


Error += test_max<float>();
Error += test_max<double>();

#if ((GLM_LANG & GLM_LANG_CXX11_FLAG) || (GLM_COMPILER & GLM_COMPILER_VC))
Error += test_min_nan<float>();
Error += test_min_nan<double>();

Error += test_max_nan<float>();
Error += test_max_nan<double>();

Expand All @@ -347,6 +353,7 @@ int main()

Error += test_fmax<float>();
Error += test_fmax<double>();
#endif//

Error += test_clamp();
Error += test_repeat();
Expand Down

0 comments on commit 980d16e

Please sign in to comment.