Renamed equalEpsilon function into epsilonEqual and added tests

This commit is contained in:
Christophe Riccio
2012-11-05 19:43:23 +01:00
parent 9d9a625493
commit 415c970188
5 changed files with 47 additions and 47 deletions

View File

@@ -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;
}

View File

@@ -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;
}
{

View File

@@ -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);
}