2012-09-19 13:34:23 +00:00
|
|
|
#include <glm/gtc/epsilon.hpp>
|
2012-11-05 18:39:22 +00:00
|
|
|
#include <glm/gtc/constants.hpp>
|
2018-08-01 16:41:10 +00:00
|
|
|
#include <glm/gtc/quaternion.hpp>
|
2013-12-25 03:16:08 +00:00
|
|
|
#include <glm/vector_relational.hpp>
|
2012-09-19 13:34:23 +00:00
|
|
|
|
2024-01-20 09:11:13 +00:00
|
|
|
static int test_defined()
|
2012-11-15 14:37:28 +00:00
|
|
|
{
|
2024-02-08 21:26:26 +00:00
|
|
|
int Error = 0;
|
2012-11-15 14:37:28 +00:00
|
|
|
|
2024-02-08 21:26:26 +00:00
|
|
|
Error += glm::all(glm::epsilonEqual(glm::vec2(0.0f), glm::vec2(0.0f), glm::vec2(glm::epsilon<float>()))) ? 0 : 1;
|
|
|
|
Error += glm::all(glm::epsilonEqual(glm::vec3(0.0f), glm::vec3(0.0f), glm::vec3(glm::epsilon<float>()))) ? 0 : 1;
|
|
|
|
Error += glm::all(glm::epsilonEqual(glm::vec4(0.0f), glm::vec4(0.0f), glm::vec4(glm::epsilon<float>()))) ? 0 : 1;
|
|
|
|
|
|
|
|
Error += glm::all(glm::epsilonNotEqual(glm::vec2(1.0f), glm::vec2(2.0f), glm::vec2(glm::epsilon<float>()))) ? 0 : 1;
|
|
|
|
Error += glm::all(glm::epsilonNotEqual(glm::vec3(1.0f), glm::vec3(2.0f), glm::vec3(glm::epsilon<float>()))) ? 0 : 1;
|
|
|
|
Error += glm::all(glm::epsilonNotEqual(glm::vec4(1.0f), glm::vec4(2.0f), glm::vec4(glm::epsilon<float>()))) ? 0 : 1;
|
2012-12-22 13:30:46 +00:00
|
|
|
|
2024-02-08 21:26:26 +00:00
|
|
|
Error += glm::all(glm::epsilonEqual(glm::vec2(0.0f), glm::vec2(0.0f), glm::epsilon<float>())) ? 0 : 1;
|
|
|
|
Error += glm::all(glm::epsilonEqual(glm::vec3(0.0f), glm::vec3(0.0f), glm::epsilon<float>())) ? 0 : 1;
|
|
|
|
Error += glm::all(glm::epsilonEqual(glm::vec4(0.0f), glm::vec4(0.0f), glm::epsilon<float>())) ? 0 : 1;
|
|
|
|
Error += glm::all(glm::epsilonEqual(glm::quat(glm::vec3(0.0f)), glm::quat(glm::vec3(0.0f)), glm::epsilon<float>())) ? 0 : 1;
|
2012-11-15 14:37:28 +00:00
|
|
|
|
2024-02-08 21:26:26 +00:00
|
|
|
Error += glm::all(glm::epsilonNotEqual(glm::vec2(1.0f), glm::vec2(2.0f), glm::epsilon<float>())) ? 0 : 1;
|
|
|
|
Error += glm::all(glm::epsilonNotEqual(glm::vec3(1.0f), glm::vec3(2.0f), glm::epsilon<float>())) ? 0 : 1;
|
|
|
|
Error += glm::all(glm::epsilonNotEqual(glm::vec4(1.0f), glm::vec4(2.0f), glm::epsilon<float>())) ? 0 : 1;
|
|
|
|
Error += glm::all(glm::epsilonNotEqual(glm::quat(glm::vec3(0.0f)), glm::quat(glm::vec3(1.0f)), glm::epsilon<float>())) ? 0 : 1;
|
2012-11-15 14:37:28 +00:00
|
|
|
|
2024-02-08 21:26:26 +00:00
|
|
|
return Error;
|
2012-11-15 14:37:28 +00:00
|
|
|
}
|
|
|
|
|
2016-12-30 19:05:04 +00:00
|
|
|
template<typename T>
|
2024-01-20 09:11:13 +00:00
|
|
|
static int test_equal()
|
2012-09-19 13:34:23 +00:00
|
|
|
{
|
2024-02-08 21:26:26 +00:00
|
|
|
int Error = 0;
|
2012-11-05 18:39:22 +00:00
|
|
|
|
2012-11-05 23:44:48 +00:00
|
|
|
{
|
|
|
|
T A = glm::epsilon<T>();
|
|
|
|
T B = glm::epsilon<T>();
|
2012-11-06 01:26:31 +00:00
|
|
|
Error += glm::epsilonEqual(A, B, glm::epsilon<T>() * T(2)) ? 0 : 1;
|
2012-11-05 23:44:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
T A(0);
|
2013-09-07 22:22:17 +00:00
|
|
|
T B = static_cast<T>(0) + glm::epsilon<T>();
|
2012-11-06 01:26:31 +00:00
|
|
|
Error += glm::epsilonEqual(A, B, glm::epsilon<T>() * T(2)) ? 0 : 1;
|
2012-11-05 23:44:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
T A(0);
|
2013-09-07 22:22:17 +00:00
|
|
|
T B = static_cast<T>(0) - glm::epsilon<T>();
|
2012-11-06 01:26:31 +00:00
|
|
|
Error += glm::epsilonEqual(A, B, glm::epsilon<T>() * T(2)) ? 0 : 1;
|
2012-11-05 23:44:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2013-09-07 22:22:17 +00:00
|
|
|
T A = static_cast<T>(0) + glm::epsilon<T>();
|
|
|
|
T B = static_cast<T>(0);
|
2012-11-06 01:26:31 +00:00
|
|
|
Error += glm::epsilonEqual(A, B, glm::epsilon<T>() * T(2)) ? 0 : 1;
|
2012-11-05 23:44:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2013-09-07 22:22:17 +00:00
|
|
|
T A = static_cast<T>(0) - glm::epsilon<T>();
|
|
|
|
T B = static_cast<T>(0);
|
2012-11-06 01:26:31 +00:00
|
|
|
Error += glm::epsilonEqual(A, B, glm::epsilon<T>() * T(2)) ? 0 : 1;
|
2012-11-05 23:44:48 +00:00
|
|
|
}
|
|
|
|
|
2012-11-05 18:39:22 +00:00
|
|
|
return Error;
|
|
|
|
}
|
2012-09-19 13:34:23 +00:00
|
|
|
|
2012-11-05 18:39:22 +00:00
|
|
|
int main()
|
|
|
|
{
|
2024-02-08 21:26:26 +00:00
|
|
|
int Error = 0;
|
2012-09-19 13:34:23 +00:00
|
|
|
|
2012-11-15 14:37:28 +00:00
|
|
|
Error += test_defined();
|
2012-11-05 23:44:48 +00:00
|
|
|
Error += test_equal<float>();
|
|
|
|
Error += test_equal<double>();
|
2012-09-19 13:34:23 +00:00
|
|
|
|
|
|
|
return Error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|