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 0ceaba1 commit d6e2417
Showing 1 changed file with 38 additions and 35 deletions.
73 changes: 38 additions & 35 deletions test/ext/ext_vector_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,38 @@ static int test_min()
return Error;
}

template <typename vecType>
static int test_max()
{
typedef typename vecType::value_type T;

int Error = 0;

vecType const N(static_cast<T>(0));
vecType const B(static_cast<T>(1));
Error += glm::all(glm::equal(glm::max(N, B), B, glm::epsilon<T>())) ? 0 : 1;
Error += glm::all(glm::equal(glm::max(B, N), B, glm::epsilon<T>())) ? 0 : 1;

vecType const C(static_cast<T>(2));
Error += glm::all(glm::equal(glm::max(N, B, C), C, glm::epsilon<T>())) ? 0 : 1;
Error += glm::all(glm::equal(glm::max(B, N, C), C, glm::epsilon<T>())) ? 0 : 1;
Error += glm::all(glm::equal(glm::max(C, N, B), C, glm::epsilon<T>())) ? 0 : 1;
Error += glm::all(glm::equal(glm::max(C, B, N), C, glm::epsilon<T>())) ? 0 : 1;
Error += glm::all(glm::equal(glm::max(B, C, N), C, glm::epsilon<T>())) ? 0 : 1;
Error += glm::all(glm::equal(glm::max(N, C, B), C, glm::epsilon<T>())) ? 0 : 1;

vecType const D(static_cast<T>(3));
Error += glm::all(glm::equal(glm::max(D, N, B, C), D, glm::epsilon<T>())) ? 0 : 1;
Error += glm::all(glm::equal(glm::max(B, D, N, C), D, glm::epsilon<T>())) ? 0 : 1;
Error += glm::all(glm::equal(glm::max(C, N, D, B), D, glm::epsilon<T>())) ? 0 : 1;
Error += glm::all(glm::equal(glm::max(C, B, D, N), D, glm::epsilon<T>())) ? 0 : 1;
Error += glm::all(glm::equal(glm::max(B, C, N, D), D, glm::epsilon<T>())) ? 0 : 1;
Error += glm::all(glm::equal(glm::max(N, C, B, D), D, glm::epsilon<T>())) ? 0 : 1;

return Error;
}

#if ((GLM_LANG & GLM_LANG_CXX11_FLAG) || (GLM_COMPILER & GLM_COMPILER_VC))
template <typename vecType>
static int test_min_nan()
{
Expand Down Expand Up @@ -100,37 +132,6 @@ static int test_min_nan()
return Error;
}

template <typename vecType>
static int test_max()
{
typedef typename vecType::value_type T;

int Error = 0;

vecType const N(static_cast<T>(0));
vecType const B(static_cast<T>(1));
Error += glm::all(glm::equal(glm::max(N, B), B, glm::epsilon<T>())) ? 0 : 1;
Error += glm::all(glm::equal(glm::max(B, N), B, glm::epsilon<T>())) ? 0 : 1;

vecType const C(static_cast<T>(2));
Error += glm::all(glm::equal(glm::max(N, B, C), C, glm::epsilon<T>())) ? 0 : 1;
Error += glm::all(glm::equal(glm::max(B, N, C), C, glm::epsilon<T>())) ? 0 : 1;
Error += glm::all(glm::equal(glm::max(C, N, B), C, glm::epsilon<T>())) ? 0 : 1;
Error += glm::all(glm::equal(glm::max(C, B, N), C, glm::epsilon<T>())) ? 0 : 1;
Error += glm::all(glm::equal(glm::max(B, C, N), C, glm::epsilon<T>())) ? 0 : 1;
Error += glm::all(glm::equal(glm::max(N, C, B), C, glm::epsilon<T>())) ? 0 : 1;

vecType const D(static_cast<T>(3));
Error += glm::all(glm::equal(glm::max(D, N, B, C), D, glm::epsilon<T>())) ? 0 : 1;
Error += glm::all(glm::equal(glm::max(B, D, N, C), D, glm::epsilon<T>())) ? 0 : 1;
Error += glm::all(glm::equal(glm::max(C, N, D, B), D, glm::epsilon<T>())) ? 0 : 1;
Error += glm::all(glm::equal(glm::max(C, B, D, N), D, glm::epsilon<T>())) ? 0 : 1;
Error += glm::all(glm::equal(glm::max(B, C, N, D), D, glm::epsilon<T>())) ? 0 : 1;
Error += glm::all(glm::equal(glm::max(N, C, B, D), D, glm::epsilon<T>())) ? 0 : 1;

return Error;
}

template <typename vecType>
static int test_max_nan()
{
Expand Down Expand Up @@ -226,6 +227,7 @@ static int test_fmax()

return Error;
}
#endif//

static int test_clamp()
{
Expand Down Expand Up @@ -339,19 +341,20 @@ int main()

Error += test_min<glm::vec3>();
Error += test_min<glm::vec2>();
Error += test_min_nan<glm::vec3>();
Error += test_min_nan<glm::vec2>();

Error += test_max<glm::vec3>();
Error += test_max<glm::vec2>();

#if ((GLM_LANG & GLM_LANG_CXX11_FLAG) || (GLM_COMPILER & GLM_COMPILER_VC))
Error += test_min_nan<glm::vec3>();
Error += test_min_nan<glm::vec2>();
Error += test_max_nan<glm::vec3>();
Error += test_max_nan<glm::vec2>();

Error += test_fmin<glm::vec3>();
Error += test_fmin<glm::vec2>();

Error += test_fmax<glm::vec3>();
Error += test_fmax<glm::vec2>();
#endif//

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

0 comments on commit d6e2417

Please sign in to comment.