Added GLM_FORCE_SILENT_WARNINGS to silent GLM warnings when using language extensions but using W4 or Wpedantic warnings #814 #775

This commit is contained in:
Christophe Riccio
2018-09-18 22:35:28 +02:00
parent b2a7f1093c
commit 635ff4ef2d
11 changed files with 219 additions and 18 deletions

View File

@@ -1,7 +1,7 @@
#include <glm/ext/scalar_relational.hpp>
#include <cmath>
int test_equal_epsilon()
static int test_equal_epsilon()
{
# if GLM_CONFIG_CONSTEXP == GLM_ENABLE
static_assert(glm::equal(1.01f, 1.02f, 0.1f), "GLM: Failed constexpr");
@@ -16,7 +16,7 @@ int test_equal_epsilon()
return Error;
}
int test_notEqual_epsilon()
static int test_notEqual_epsilon()
{
# if GLM_CONFIG_CONSTEXP == GLM_ENABLE
static_assert(glm::notEqual(1.01f, 1.02f, 0.001f), "GLM: Failed constexpr");
@@ -31,8 +31,7 @@ int test_notEqual_epsilon()
return Error;
}
#if GLM_LANG & GLM_LANG_CXX11_FLAG
int test_equal_ulps()
static int test_equal_ulps()
{
int Error = 0;
@@ -51,7 +50,7 @@ int test_equal_ulps()
return Error;
}
int test_notEqual_ulps()
static int test_notEqual_ulps()
{
int Error = 0;
@@ -69,7 +68,6 @@ int test_notEqual_ulps()
return Error;
}
#endif
int main()
{
@@ -77,11 +75,9 @@ int main()
Error += test_equal_epsilon();
Error += test_notEqual_epsilon();
#if GLM_LANG & GLM_LANG_CXX11_FLAG
Error += test_equal_ulps();
Error += test_notEqual_ulps();
#endif
return Error;
}

View File

@@ -68,10 +68,71 @@ static int test_constexpr()
return 0;
}
template <typename T>
static int test_equal_ulps()
{
typedef glm::vec<4, T, glm::defaultp> vec4;
T const Zero(0);
T const One(1);
T const Two(2);
vec4 const Ones(1);
int Error = 0;
T const ULP1Plus = std::nextafter(One, Two);
Error += glm::all(glm::equal(Ones, vec4(ULP1Plus), 1)) ? 0 : 1;
T const ULP2Plus = std::nextafter(ULP1Plus, Two);
Error += !glm::all(glm::equal(Ones, vec4(ULP2Plus), 1)) ? 0 : 1;
T const ULP1Minus = std::nextafter(One, Zero);
Error += glm::all(glm::equal(Ones, vec4(ULP1Minus), 1)) ? 0 : 1;
T const ULP2Minus = std::nextafter(ULP1Minus, Zero);
Error += !glm::all(glm::equal(Ones, vec4(ULP2Minus), 1)) ? 0 : 1;
return Error;
}
template <typename T>
static int test_notEqual_ulps()
{
typedef glm::vec<4, T, glm::defaultp> vec4;
T const Zero(0);
T const One(1);
T const Two(2);
vec4 const Ones(1);
int Error = 0;
T const ULP1Plus = std::nextafter(One, Two);
Error += !glm::all(glm::notEqual(Ones, vec4(ULP1Plus), 1)) ? 0 : 1;
T const ULP2Plus = std::nextafter(ULP1Plus, Two);
Error += glm::all(glm::notEqual(Ones, vec4(ULP2Plus), 1)) ? 0 : 1;
T const ULP1Minus = std::nextafter(One, Zero);
Error += !glm::all(glm::notEqual(Ones, vec4(ULP1Minus), 1)) ? 0 : 1;
T const ULP2Minus = std::nextafter(ULP1Minus, Zero);
Error += glm::all(glm::notEqual(Ones, vec4(ULP2Minus), 1)) ? 0 : 1;
return Error;
}
int main()
{
int Error = 0;
Error += test_equal_ulps<float>();
Error += test_equal_ulps<double>();
Error += test_notEqual_ulps<float>();
Error += test_notEqual_ulps<double>();
Error += test_equal<glm::vec1>();
Error += test_equal<glm::lowp_vec1>();
Error += test_equal<glm::mediump_vec1>();