#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include template static int test_equal() { typedef typename vecType::value_type valType; valType const A = static_cast(1.01f); valType const B = static_cast(1.02f); valType const Epsilon1 = static_cast(0.1f); valType const Epsilon2 = static_cast(0.001f); int Error = 0; Error += glm::all(glm::equal(vecType(A), vecType(B), Epsilon1)) ? 0 : 1; Error += glm::all(glm::equal(vecType(A), vecType(B), vecType(Epsilon1))) ? 0 : 1; Error += !glm::any(glm::equal(vecType(A), vecType(B), Epsilon2)) ? 0 : 1; Error += !glm::any(glm::equal(vecType(A), vecType(B), vecType(Epsilon2))) ? 0 : 1; return Error; } template static int test_notEqual() { typedef typename vecType::value_type valType; valType const A = static_cast(1.01f); valType const B = static_cast(1.02f); valType const Epsilon1 = static_cast(0.1f); valType const Epsilon2 = static_cast(0.001f); int Error = 0; Error += glm::all(glm::notEqual(vecType(A), vecType(B), Epsilon2)) ? 0 : 1; Error += glm::all(glm::notEqual(vecType(A), vecType(B), vecType(Epsilon2))) ? 0 : 1; Error += !glm::any(glm::notEqual(vecType(A), vecType(B), Epsilon1)) ? 0 : 1; Error += !glm::any(glm::notEqual(vecType(A), vecType(B), vecType(Epsilon1))) ? 0 : 1; return Error; } template static int test_constexpr() { # if GLM_CONFIG_CONSTEXP == GLM_ENABLE static_assert(glm::all(glm::equal(genType(static_cast(1.01f)), genType(static_cast(1.02f)), static_cast(0.1f))), "GLM: Failed constexpr"); # endif return 0; } template 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 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(); Error += test_equal_ulps(); Error += test_notEqual_ulps(); Error += test_notEqual_ulps(); Error += test_equal(); Error += test_equal(); Error += test_equal(); Error += test_equal(); Error += test_equal(); Error += test_equal(); Error += test_equal(); Error += test_equal(); Error += test_equal(); Error += test_equal(); Error += test_equal(); Error += test_equal(); Error += test_equal(); Error += test_equal(); Error += test_equal(); Error += test_equal(); Error += test_equal(); Error += test_equal(); Error += test_equal(); Error += test_equal(); Error += test_equal(); Error += test_equal(); Error += test_equal(); Error += test_equal(); Error += test_equal(); Error += test_equal(); Error += test_equal(); Error += test_equal(); Error += test_equal(); Error += test_equal(); Error += test_equal(); Error += test_equal(); Error += test_notEqual(); Error += test_notEqual(); Error += test_notEqual(); Error += test_notEqual(); Error += test_notEqual(); Error += test_notEqual(); Error += test_notEqual(); Error += test_notEqual(); Error += test_notEqual(); Error += test_notEqual(); Error += test_notEqual(); Error += test_notEqual(); Error += test_notEqual(); Error += test_notEqual(); Error += test_notEqual(); Error += test_notEqual(); Error += test_notEqual(); Error += test_notEqual(); Error += test_notEqual(); Error += test_notEqual(); Error += test_notEqual(); Error += test_notEqual(); Error += test_notEqual(); Error += test_notEqual(); Error += test_notEqual(); Error += test_notEqual(); Error += test_notEqual(); Error += test_notEqual(); Error += test_notEqual(); Error += test_notEqual(); Error += test_notEqual(); Error += test_notEqual(); Error += test_constexpr(); Error += test_constexpr(); Error += test_constexpr(); Error += test_constexpr(); return Error; }