diff --git a/test/ext/ext_matrix_relational.cpp b/test/ext/ext_matrix_relational.cpp index 7a169f9f..a6887369 100644 --- a/test/ext/ext_matrix_relational.cpp +++ b/test/ext/ext_matrix_relational.cpp @@ -1,23 +1,59 @@ #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include #include -int test_equal() +template +static int test_equal() { + typedef typename matType::value_type valType; + + valType const Epsilon(0.001f); + valType const One(1); + valType const Two(2); + int Error = 0; - Error += glm::all(glm::equal(glm::mat4x3(1), glm::mat4x3(1), 0.001f)) ? 0 : 1; - Error += glm::all(glm::equal(glm::mat4x3(1), glm::mat4x3(2), glm::vec4(0.001f))) ? 1 : 0; + Error += glm::all(glm::equal(matType(One), matType(One), Epsilon)) ? 0 : 1; + Error += glm::all(glm::equal(matType(One), matType(Two), vecType(Epsilon))) ? 1 : 0; return Error; } -int test_notEqual() +template +static int test_notEqual() { + typedef typename matType::value_type valType; + + valType const Epsilon(0.001f); + valType const One(1); + valType const Two(2); + int Error = 0; - Error += !glm::any(glm::notEqual(glm::mat4x3(1), glm::mat4x3(1), 0.001f)) ? 0 : 1; - Error += !glm::any(glm::notEqual(glm::mat4x3(1), glm::mat4x3(2), glm::vec4(0.001f))) ? 1 : 0; + Error += !glm::any(glm::notEqual(matType(One), matType(One), Epsilon)) ? 0 : 1; + Error += !glm::any(glm::notEqual(matType(One), matType(Two), vecType(Epsilon))) ? 1 : 0; return Error; } @@ -26,8 +62,45 @@ int main() { int Error = 0; - Error += test_equal(); - Error += test_notEqual(); + 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(); return Error; } diff --git a/test/ext/ext_vector_relational.cpp b/test/ext/ext_vector_relational.cpp index cff62cfc..04808d89 100644 --- a/test/ext/ext_vector_relational.cpp +++ b/test/ext/ext_vector_relational.cpp @@ -1,38 +1,149 @@ #include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -int test_equal() +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(0.1f); + valType const Epsilon2(0.001f); + int Error = 0; - Error += glm::all(glm::equal(glm::vec2(1.01f), glm::vec2(1.02f), 0.1f)) ? 0 : 1; - Error += glm::all(glm::equal(glm::vec2(1.01f), glm::vec2(1.02f), glm::vec2(0.1f))) ? 0 : 1; + 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(glm::vec2(1.01f), glm::vec2(1.02f), 0.001f)) ? 0 : 1; - Error += !glm::any(glm::equal(glm::vec2(1.01f), glm::vec2(1.02f), glm::vec2(0.001f))) ? 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; } -int test_notEqual() +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(0.1f); + valType const Epsilon2(0.001f); + int Error = 0; - Error += glm::all(glm::notEqual(glm::vec2(1.01f), glm::vec2(1.02f), 0.001f)) ? 0 : 1; - Error += glm::all(glm::notEqual(glm::vec2(1.01f), glm::vec2(1.02f), glm::vec2(0.001f))) ? 0 : 1; + Error += glm::all(glm::notEqual(vecType(1.01f), vecType(1.02f), Epsilon2)) ? 0 : 1; + Error += glm::all(glm::notEqual(vecType(1.01f), vecType(1.02f), vecType(Epsilon2))) ? 0 : 1; - Error += !glm::any(glm::notEqual(glm::vec2(1.01f), glm::vec2(1.02f), 0.1f)) ? 0 : 1; - Error += !glm::any(glm::notEqual(glm::vec2(1.01f), glm::vec2(1.02f), glm::vec2(0.1f))) ? 0 : 1; + Error += !glm::any(glm::notEqual(vecType(1.01f), vecType(1.02f), Epsilon1)) ? 0 : 1; + Error += !glm::any(glm::notEqual(vecType(1.01f), vecType(1.02f), 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; +} + int main() { int Error = 0; - Error += test_equal(); - Error += test_notEqual(); + 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; }