mirror of
https://github.com/g-truc/glm.git
synced 2024-11-23 01:14:34 +00:00
Renamed equalEpsilon function into epsilonEqual and added tests
This commit is contained in:
parent
9d9a625493
commit
415c970188
@ -33,7 +33,7 @@ int test_modf()
|
||||
glm::vec4 A = glm::modf(X, I);
|
||||
|
||||
Error += I == glm::vec4(1.0f) ? 0 : 1;
|
||||
Error += glm::all(glm::equalEpsilon(A, glm::vec4(0.1f, 0.2f, 0.5f, 0.7f), 0.00001f)) ? 0 : 1;
|
||||
Error += glm::all(glm::epsilonEqual(A, glm::vec4(0.1f, 0.2f, 0.5f, 0.7f), 0.00001f)) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
@ -42,7 +42,7 @@ int test_modf()
|
||||
glm::dvec4 A = glm::modf(X, I);
|
||||
|
||||
Error += I == glm::dvec4(1.0) ? 0 : 1;
|
||||
Error += glm::all(glm::equalEpsilon(A, glm::dvec4(0.1, 0.2, 0.5, 0.7), 0.000000001)) ? 0 : 1;
|
||||
Error += glm::all(glm::epsilonEqual(A, glm::dvec4(0.1, 0.2, 0.5, 0.7), 0.000000001)) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
@ -216,67 +216,67 @@ int test_roundEven()
|
||||
|
||||
{
|
||||
float A = glm::roundEven(-1.5f);
|
||||
Error += glm::equalEpsilon(A, -2.0f, 0.0001f) ? 0 : 1;
|
||||
Error += glm::epsilonEqual(A, -2.0f, 0.0001f) ? 0 : 1;
|
||||
Error += 0;
|
||||
}
|
||||
{
|
||||
float A = glm::roundEven(1.5f);
|
||||
Error += glm::equalEpsilon(A, 2.0f, 0.0001f) ? 0 : 1;
|
||||
Error += glm::epsilonEqual(A, 2.0f, 0.0001f) ? 0 : 1;
|
||||
Error += 0;
|
||||
}
|
||||
|
||||
{
|
||||
float A = glm::roundEven(-3.5f);
|
||||
Error += glm::equalEpsilon(A, -4.0f, 0.0001f) ? 0 : 1;
|
||||
Error += glm::epsilonEqual(A, -4.0f, 0.0001f) ? 0 : 1;
|
||||
Error += 0;
|
||||
}
|
||||
{
|
||||
float A = glm::roundEven(3.5f);
|
||||
Error += glm::equalEpsilon(A, 4.0f, 0.0001f) ? 0 : 1;
|
||||
Error += glm::epsilonEqual(A, 4.0f, 0.0001f) ? 0 : 1;
|
||||
Error += 0;
|
||||
}
|
||||
|
||||
{
|
||||
float A = glm::roundEven(-2.5f);
|
||||
Error += glm::equalEpsilon(A, -2.0f, 0.0001f) ? 0 : 1;
|
||||
Error += glm::epsilonEqual(A, -2.0f, 0.0001f) ? 0 : 1;
|
||||
Error += 0;
|
||||
}
|
||||
{
|
||||
float A = glm::roundEven(2.5f);
|
||||
Error += glm::equalEpsilon(A, 2.0f, 0.0001f) ? 0 : 1;
|
||||
Error += glm::epsilonEqual(A, 2.0f, 0.0001f) ? 0 : 1;
|
||||
Error += 0;
|
||||
}
|
||||
|
||||
{
|
||||
float A = glm::roundEven(-2.4f);
|
||||
Error += glm::equalEpsilon(A, -2.0f, 0.0001f) ? 0 : 1;
|
||||
Error += glm::epsilonEqual(A, -2.0f, 0.0001f) ? 0 : 1;
|
||||
Error += 0;
|
||||
}
|
||||
{
|
||||
float A = glm::roundEven(2.4f);
|
||||
Error += glm::equalEpsilon(A, 2.0f, 0.0001f) ? 0 : 1;
|
||||
Error += glm::epsilonEqual(A, 2.0f, 0.0001f) ? 0 : 1;
|
||||
Error += 0;
|
||||
}
|
||||
|
||||
{
|
||||
float A = glm::roundEven(-2.6f);
|
||||
Error += glm::equalEpsilon(A, -3.0f, 0.0001f) ? 0 : 1;
|
||||
Error += glm::epsilonEqual(A, -3.0f, 0.0001f) ? 0 : 1;
|
||||
Error += 0;
|
||||
}
|
||||
{
|
||||
float A = glm::roundEven(2.6f);
|
||||
Error += glm::equalEpsilon(A, 3.0f, 0.0001f) ? 0 : 1;
|
||||
Error += glm::epsilonEqual(A, 3.0f, 0.0001f) ? 0 : 1;
|
||||
Error += 0;
|
||||
}
|
||||
|
||||
{
|
||||
float A = glm::roundEven(-2.0f);
|
||||
Error += glm::equalEpsilon(A, -2.0f, 0.0001f) ? 0 : 1;
|
||||
Error += glm::epsilonEqual(A, -2.0f, 0.0001f) ? 0 : 1;
|
||||
Error += 0;
|
||||
}
|
||||
{
|
||||
float A = glm::roundEven(2.0f);
|
||||
Error += glm::equalEpsilon(A, 2.0f, 0.0001f) ? 0 : 1;
|
||||
Error += glm::epsilonEqual(A, 2.0f, 0.0001f) ? 0 : 1;
|
||||
Error += 0;
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ int test_refract()
|
||||
glm::vec2 A(0.0f,-1.0f);
|
||||
glm::vec2 B(0.0f, 1.0f);
|
||||
glm::vec2 C = glm::refract(A, B, 0.5f);
|
||||
Error += glm::all(glm::equalEpsilon(C, glm::vec2(0.0, -1.0), 0.0001f)) ? 0 : 1;
|
||||
Error += glm::all(glm::epsilonEqual(C, glm::vec2(0.0, -1.0), 0.0001f)) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -32,7 +32,7 @@ int test_packUnorm2x16()
|
||||
glm::vec2 B(A[i]);
|
||||
glm::uint32 C = glm::packUnorm2x16(B);
|
||||
glm::vec2 D = glm::unpackUnorm2x16(C);
|
||||
Error += glm::all(glm::equalEpsilon(B, D, 1.0f / 65535.f)) ? 0 : 1;
|
||||
Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 65535.f)) ? 0 : 1;
|
||||
assert(!Error);
|
||||
}
|
||||
|
||||
@ -58,7 +58,7 @@ int test_packSnorm2x16()
|
||||
glm::vec2 B(A[i]);
|
||||
glm::uint32 C = glm::packSnorm2x16(B);
|
||||
glm::vec2 D = glm::unpackSnorm2x16(C);
|
||||
Error += glm::all(glm::equalEpsilon(B, D, 1.0f / 32767.0f * 2.0f)) ? 0 : 1;
|
||||
Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 32767.0f * 2.0f)) ? 0 : 1;
|
||||
assert(!Error);
|
||||
}
|
||||
|
||||
@ -78,7 +78,7 @@ int test_packUnorm4x8()
|
||||
glm::vec4 B(A[i]);
|
||||
glm::uint32 C = glm::packUnorm4x8(B);
|
||||
glm::vec4 D = glm::unpackUnorm4x8(C);
|
||||
Error += glm::all(glm::equalEpsilon(B, D, 1.0f / 255.f)) ? 0 : 1;
|
||||
Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 255.f)) ? 0 : 1;
|
||||
assert(!Error);
|
||||
}
|
||||
|
||||
@ -98,7 +98,7 @@ int test_packSnorm4x8()
|
||||
glm::vec4 B(A[i]);
|
||||
glm::uint32 C = glm::packSnorm4x8(B);
|
||||
glm::vec4 D = glm::unpackSnorm4x8(C);
|
||||
Error += glm::all(glm::equalEpsilon(B, D, 1.0f / 127.f)) ? 0 : 1;
|
||||
Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 127.f)) ? 0 : 1;
|
||||
assert(!Error);
|
||||
}
|
||||
|
||||
@ -125,7 +125,7 @@ int test_packHalf2x16()
|
||||
glm::uint C = glm::packHalf2x16(B);
|
||||
glm::vec2 D = glm::unpackHalf2x16(C);
|
||||
//Error += B == D ? 0 : 1;
|
||||
Error += glm::all(glm::equalEpsilon(B, D, 1.0f / 127.f)) ? 0 : 1;
|
||||
Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 127.f)) ? 0 : 1;
|
||||
assert(!Error);
|
||||
}
|
||||
|
||||
|
@ -19,25 +19,25 @@ int test_quat_angle()
|
||||
glm::quat Q = glm::angleAxis(45.0f, glm::vec3(0, 0, 1));
|
||||
glm::quat N = glm::normalize(Q);
|
||||
float L = glm::length(N);
|
||||
Error += glm::equalEpsilon(L, 1.0f, 0.01f) ? 0 : 1;
|
||||
Error += glm::epsilonEqual(L, 1.0f, 0.01f) ? 0 : 1;
|
||||
float A = glm::angle(N);
|
||||
Error += glm::equalEpsilon(A, 45.0f, 0.01f) ? 0 : 1;
|
||||
Error += glm::epsilonEqual(A, 45.0f, 0.01f) ? 0 : 1;
|
||||
}
|
||||
{
|
||||
glm::quat Q = glm::angleAxis(45.0f, glm::normalize(glm::vec3(0, 1, 1)));
|
||||
glm::quat N = glm::normalize(Q);
|
||||
float L = glm::length(N);
|
||||
Error += glm::equalEpsilon(L, 1.0f, 0.01f) ? 0 : 1;
|
||||
Error += glm::epsilonEqual(L, 1.0f, 0.01f) ? 0 : 1;
|
||||
float A = glm::angle(N);
|
||||
Error += glm::equalEpsilon(A, 45.0f, 0.01f) ? 0 : 1;
|
||||
Error += glm::epsilonEqual(A, 45.0f, 0.01f) ? 0 : 1;
|
||||
}
|
||||
{
|
||||
glm::quat Q = glm::angleAxis(45.0f, glm::normalize(glm::vec3(1, 2, 3)));
|
||||
glm::quat N = glm::normalize(Q);
|
||||
float L = glm::length(N);
|
||||
Error += glm::equalEpsilon(L, 1.0f, 0.01f) ? 0 : 1;
|
||||
Error += glm::epsilonEqual(L, 1.0f, 0.01f) ? 0 : 1;
|
||||
float A = glm::angle(N);
|
||||
Error += glm::equalEpsilon(A, 45.0f, 0.01f) ? 0 : 1;
|
||||
Error += glm::epsilonEqual(A, 45.0f, 0.01f) ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
@ -52,10 +52,10 @@ int test_quat_angleAxis()
|
||||
glm::quat C = glm::mix(A, B, 0.5f);
|
||||
glm::quat D = glm::angleAxis(45.0f, glm::vec3(0, 0, 1));
|
||||
|
||||
Error += glm::equalEpsilon(C.x, D.x, 0.01f) ? 0 : 1;
|
||||
Error += glm::equalEpsilon(C.y, D.y, 0.01f) ? 0 : 1;
|
||||
Error += glm::equalEpsilon(C.z, D.z, 0.01f) ? 0 : 1;
|
||||
Error += glm::equalEpsilon(C.w, D.w, 0.01f) ? 0 : 1;
|
||||
Error += glm::epsilonEqual(C.x, D.x, 0.01f) ? 0 : 1;
|
||||
Error += glm::epsilonEqual(C.y, D.y, 0.01f) ? 0 : 1;
|
||||
Error += glm::epsilonEqual(C.z, D.z, 0.01f) ? 0 : 1;
|
||||
Error += glm::epsilonEqual(C.w, D.w, 0.01f) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
@ -69,10 +69,10 @@ int test_quat_mix()
|
||||
glm::quat C = glm::mix(A, B, 0.5f);
|
||||
glm::quat D = glm::angleAxis(45.0f, glm::vec3(0, 0, 1));
|
||||
|
||||
Error += glm::equalEpsilon(C.x, D.x, 0.01f) ? 0 : 1;
|
||||
Error += glm::equalEpsilon(C.y, D.y, 0.01f) ? 0 : 1;
|
||||
Error += glm::equalEpsilon(C.z, D.z, 0.01f) ? 0 : 1;
|
||||
Error += glm::equalEpsilon(C.w, D.w, 0.01f) ? 0 : 1;
|
||||
Error += glm::epsilonEqual(C.x, D.x, 0.01f) ? 0 : 1;
|
||||
Error += glm::epsilonEqual(C.y, D.y, 0.01f) ? 0 : 1;
|
||||
Error += glm::epsilonEqual(C.z, D.z, 0.01f) ? 0 : 1;
|
||||
Error += glm::epsilonEqual(C.w, D.w, 0.01f) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
@ -95,19 +95,19 @@ int test_quat_normalize()
|
||||
glm::quat Q = glm::angleAxis(45.0f, glm::vec3(0, 0, 1));
|
||||
glm::quat N = glm::normalize(Q);
|
||||
float L = glm::length(N);
|
||||
Error += glm::equalEpsilon(L, 1.0f, 0.000001f) ? 0 : 1;
|
||||
Error += glm::epsilonEqual(L, 1.0f, 0.000001f) ? 0 : 1;
|
||||
}
|
||||
{
|
||||
glm::quat Q = glm::angleAxis(45.0f, glm::vec3(0, 0, 2));
|
||||
glm::quat N = glm::normalize(Q);
|
||||
float L = glm::length(N);
|
||||
Error += glm::equalEpsilon(L, 1.0f, 0.000001f) ? 0 : 1;
|
||||
Error += glm::epsilonEqual(L, 1.0f, 0.000001f) ? 0 : 1;
|
||||
}
|
||||
{
|
||||
glm::quat Q = glm::angleAxis(45.0f, glm::vec3(1, 2, 3));
|
||||
glm::quat N = glm::normalize(Q);
|
||||
float L = glm::length(N);
|
||||
Error += glm::equalEpsilon(L, 1.0f, 0.000001f) ? 0 : 1;
|
||||
Error += glm::epsilonEqual(L, 1.0f, 0.000001f) ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
|
@ -25,8 +25,8 @@ int test_linearRand()
|
||||
ResultDouble += glm::linearRand(-1.0, 1.0);
|
||||
}
|
||||
|
||||
Error += glm::equalEpsilon(ResultFloat, 0.0f, 0.0001f);
|
||||
Error += glm::equalEpsilon(ResultDouble, 0.0, 0.0001);
|
||||
Error += glm::epsilonEqual(ResultFloat, 0.0f, 0.0001f);
|
||||
Error += glm::epsilonEqual(ResultDouble, 0.0, 0.0001);
|
||||
assert(!Error);
|
||||
}
|
||||
|
||||
@ -49,8 +49,8 @@ int test_circularRand()
|
||||
ResultDouble += glm::length(glm::circularRand(Radius));
|
||||
}
|
||||
|
||||
Error += glm::equalEpsilon(ResultFloat, float(Max), 0.01f) ? 0 : 1;
|
||||
Error += glm::equalEpsilon(ResultDouble, double(Max) * double(Radius), 0.01) ? 0 : 1;
|
||||
Error += glm::epsilonEqual(ResultFloat, float(Max), 0.01f) ? 0 : 1;
|
||||
Error += glm::epsilonEqual(ResultDouble, double(Max) * double(Radius), 0.01) ? 0 : 1;
|
||||
assert(!Error);
|
||||
}
|
||||
|
||||
@ -80,12 +80,12 @@ int test_sphericalRand()
|
||||
ResultDoubleC += glm::length(glm::sphericalRand(3.0));
|
||||
}
|
||||
|
||||
Error += glm::equalEpsilon(ResultFloatA, float(Max), 0.01f) ? 0 : 1;
|
||||
Error += glm::equalEpsilon(ResultDoubleA, double(Max), 0.0001) ? 0 : 1;
|
||||
Error += glm::equalEpsilon(ResultFloatB, float(Max * 2), 0.01f) ? 0 : 1;
|
||||
Error += glm::equalEpsilon(ResultDoubleB, double(Max * 2), 0.0001) ? 0 : 1;
|
||||
Error += glm::equalEpsilon(ResultFloatC, float(Max * 3), 0.01f) ? 0 : 1;
|
||||
Error += glm::equalEpsilon(ResultDoubleC, double(Max * 3), 0.01) ? 0 : 1;
|
||||
Error += glm::epsilonEqual(ResultFloatA, float(Max), 0.01f) ? 0 : 1;
|
||||
Error += glm::epsilonEqual(ResultDoubleA, double(Max), 0.0001) ? 0 : 1;
|
||||
Error += glm::epsilonEqual(ResultFloatB, float(Max * 2), 0.01f) ? 0 : 1;
|
||||
Error += glm::epsilonEqual(ResultDoubleB, double(Max * 2), 0.0001) ? 0 : 1;
|
||||
Error += glm::epsilonEqual(ResultFloatC, float(Max * 3), 0.01f) ? 0 : 1;
|
||||
Error += glm::epsilonEqual(ResultDoubleC, double(Max * 3), 0.01) ? 0 : 1;
|
||||
assert(!Error);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user