Renamed equalEpsilon function into epsilonEqual and added tests

This commit is contained in:
Christophe Riccio
2012-11-05 19:39:22 +01:00
parent a350a26e3b
commit 9d9a625493
8 changed files with 77 additions and 35 deletions

View File

@@ -14,7 +14,7 @@ int main()
{
int Error(0);
return Error;
}

View File

@@ -8,13 +8,55 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
#include <glm/glm.hpp>
#include <glm/gtc/half_float.hpp>
#include <glm/gtc/epsilon.hpp>
#include <glm/gtc/constants.hpp>
template <typename T>
int test_equal()
{
int Error(0);
{
T A = glm::epsilon<T>();
T B = glm::epsilon<T>();
Error += glm::epsilonEqual(A, B, glm::epsilon<T>()) ? 0 : 1;
}
{
T A(0);
T B = T(0) + glm::epsilon<T>();
Error += glm::epsilonEqual(A, B, glm::epsilon<T>()) ? 0 : 1;
}
{
T A(0);
T B = T(0) - glm::epsilon<T>();
Error += glm::epsilonEqual(A, B, glm::epsilon<T>()) ? 0 : 1;
}
{
T A = T(0) + glm::epsilon<T>();
T B = T(0);
Error += glm::epsilonEqual(A, B, glm::epsilon<T>()) ? 0 : 1;
}
{
T A = T(0) - glm::epsilon<T>();
T B = T(0);
Error += glm::epsilonEqual(A, B, glm::epsilon<T>()) ? 0 : 1;
}
return Error;
}
int main()
{
int Error(0);
Error += test_equal<glm::half>();
Error += test_equal<float>();
Error += test_equal<double>();
return Error;
}