2016-11-12 13:19:22 +00:00
|
|
|
#define GLM_ENABLE_EXPERIMENTAL
|
2017-08-21 18:40:37 +00:00
|
|
|
|
2015-10-07 20:32:12 +00:00
|
|
|
#include <glm/gtx/extended_min_max.hpp>
|
2017-08-20 16:42:48 +00:00
|
|
|
#include <glm/gtc/vec1.hpp>
|
2018-07-28 18:51:13 +00:00
|
|
|
#include <glm/gtc/constants.hpp>
|
|
|
|
#include <glm/ext/vector_relational.hpp>
|
2017-08-20 16:42:48 +00:00
|
|
|
|
|
|
|
// This file has divisions by zero to test isnan
|
|
|
|
#if GLM_COMPILER & GLM_COMPILER_VC
|
|
|
|
# pragma warning(disable : 4723)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
namespace fmin_
|
|
|
|
{
|
|
|
|
static int test()
|
|
|
|
{
|
|
|
|
int Error = 0;
|
|
|
|
|
|
|
|
float Zero_f = 0.0f;
|
|
|
|
glm::vec1 A0 = glm::fmin(glm::vec1(1), glm::vec1(Zero_f / 0.0f));
|
2018-07-28 18:51:13 +00:00
|
|
|
Error += glm::equal(A0.x, 1.0f, glm::epsilon<float>()) ? 0 : 1;
|
2017-08-20 16:42:48 +00:00
|
|
|
|
2017-08-21 18:40:37 +00:00
|
|
|
glm::vec1 A1 = glm::fmin(glm::vec1(Zero_f / 0.0f), glm::vec1(1));
|
2018-07-28 18:51:13 +00:00
|
|
|
Error += glm::equal(A1.x, 1.0f, glm::epsilon<float>()) ? 0 : 1;
|
2017-08-21 18:40:37 +00:00
|
|
|
|
2017-08-20 16:42:48 +00:00
|
|
|
glm::vec2 B0 = glm::fmin(glm::vec2(1), glm::vec2(1));
|
|
|
|
glm::vec2 B1 = glm::fmin(glm::vec2(1), 1.0f);
|
2018-07-28 18:51:13 +00:00
|
|
|
bool B2 = glm::all(glm::equal(B0, B1, glm::epsilon<float>()));
|
2017-08-20 16:42:48 +00:00
|
|
|
Error += B2 ? 0 : 1;
|
|
|
|
|
|
|
|
glm::vec3 C0 = glm::fmin(glm::vec3(1), glm::vec3(1));
|
|
|
|
glm::vec3 C1 = glm::fmin(glm::vec3(1), 1.0f);
|
2018-07-28 18:51:13 +00:00
|
|
|
bool C2 = glm::all(glm::equal(C0, C1, glm::epsilon<float>()));
|
2017-08-20 16:42:48 +00:00
|
|
|
Error += C2 ? 0 : 1;
|
|
|
|
|
|
|
|
glm::vec4 D0 = glm::fmin(glm::vec4(1), glm::vec4(1));
|
|
|
|
glm::vec4 D1 = glm::fmin(glm::vec4(1), 1.0f);
|
2018-07-28 18:51:13 +00:00
|
|
|
bool D2 = glm::all(glm::equal(D0, D1, glm::epsilon<float>()));
|
2017-08-20 16:42:48 +00:00
|
|
|
Error += D2 ? 0 : 1;
|
|
|
|
|
|
|
|
return Error;
|
|
|
|
}
|
|
|
|
}//namespace fmin_
|
|
|
|
|
|
|
|
namespace fmax_
|
|
|
|
{
|
|
|
|
static int test()
|
|
|
|
{
|
|
|
|
int Error = 0;
|
|
|
|
|
|
|
|
float Zero_f = 0.0f;
|
|
|
|
glm::vec1 A0 = glm::fmax(glm::vec1(1), glm::vec1(Zero_f / 0.0f));
|
2018-07-28 18:51:13 +00:00
|
|
|
Error += glm::equal(A0.x, 1.0f, glm::epsilon<float>()) ? 0 : 1;
|
2017-08-21 18:40:37 +00:00
|
|
|
|
|
|
|
glm::vec1 A1 = glm::fmax(glm::vec1(Zero_f / 0.0f), glm::vec1(1));
|
2018-07-28 18:51:13 +00:00
|
|
|
Error += glm::equal(A0.x, 1.0f, glm::epsilon<float>()) ? 0 : 1;
|
2017-08-20 16:42:48 +00:00
|
|
|
|
|
|
|
glm::vec2 B0 = glm::fmax(glm::vec2(1), glm::vec2(1));
|
|
|
|
glm::vec2 B1 = glm::fmax(glm::vec2(1), 1.0f);
|
2018-07-28 19:40:20 +00:00
|
|
|
bool B2 = glm::all(glm::equal(B0, B1, glm::epsilon<float>()));
|
2017-08-20 16:42:48 +00:00
|
|
|
Error += B2 ? 0 : 1;
|
|
|
|
|
|
|
|
glm::vec3 C0 = glm::fmax(glm::vec3(1), glm::vec3(1));
|
|
|
|
glm::vec3 C1 = glm::fmax(glm::vec3(1), 1.0f);
|
2018-07-28 19:40:20 +00:00
|
|
|
bool C2 = glm::all(glm::equal(C0, C1, glm::epsilon<float>()));
|
2017-08-20 16:42:48 +00:00
|
|
|
Error += C2 ? 0 : 1;
|
|
|
|
|
|
|
|
glm::vec4 D0 = glm::fmax(glm::vec4(1), glm::vec4(1));
|
|
|
|
glm::vec4 D1 = glm::fmax(glm::vec4(1), 1.0f);
|
2018-07-28 19:40:20 +00:00
|
|
|
bool D2 = glm::all(glm::equal(D0, D1, glm::epsilon<float>()));
|
2017-08-20 16:42:48 +00:00
|
|
|
Error += D2 ? 0 : 1;
|
|
|
|
|
|
|
|
return Error;
|
|
|
|
}
|
|
|
|
}//namespace fmax_
|
|
|
|
|
|
|
|
namespace fclamp_
|
|
|
|
{
|
|
|
|
static int test()
|
|
|
|
{
|
|
|
|
int Error = 0;
|
|
|
|
|
|
|
|
float Zero_f = 0.0f;
|
|
|
|
glm::vec1 A0 = glm::fclamp(glm::vec1(1), glm::vec1(Zero_f / 0.0f), glm::vec1(2.0f));
|
2018-07-28 18:51:13 +00:00
|
|
|
Error += glm::equal(A0.x, 1.0f, glm::epsilon<float>()) ? 0 : 1;
|
2017-08-20 16:42:48 +00:00
|
|
|
|
|
|
|
return Error;
|
|
|
|
}
|
|
|
|
}//namespace fclamp_
|
2013-10-27 18:25:03 +00:00
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
2017-08-20 16:42:48 +00:00
|
|
|
int Error = 0;
|
|
|
|
|
|
|
|
Error += fmin_::test();
|
|
|
|
Error += fmax_::test();
|
|
|
|
Error += fclamp_::test();
|
2013-10-27 18:25:03 +00:00
|
|
|
|
|
|
|
return Error;
|
|
|
|
}
|