Fixed roundEven implementation, tests are now passing

This commit is contained in:
Christophe Riccio
2011-10-20 18:13:07 +01:00
parent 774bd01b92
commit 6c00ffa1b4
2 changed files with 46 additions and 37 deletions

View File

@@ -167,70 +167,76 @@ int test_roundEven()
int Error = 0;
{
float A = glm::round(0.0f);
float A = glm::roundEven(-1.5f);
Error += A == -2.0f ? 0 : 1;
Error += 0;
}
{
float A = glm::roundEven(0.0f);
Error += A == 0.0f ? 0 : 1;
float B = glm::round(0.5f);
float B = glm::roundEven(0.5f);
Error += B == 0.0f ? 0 : 1;
float C = glm::round(1.0f);
float C = glm::roundEven(1.0f);
Error += C == 1.0f ? 0 : 1;
float D = glm::round(0.1f);
float D = glm::roundEven(0.1f);
Error += D == 0.0f ? 0 : 1;
float E = glm::round(0.9f);
float E = glm::roundEven(0.9f);
Error += E == 1.0f ? 0 : 1;
float F = glm::round(1.5f);
float F = glm::roundEven(1.5f);
Error += F == 2.0f ? 0 : 1;
float G = glm::round(1.9f);
float G = glm::roundEven(1.9f);
Error += G == 2.0f ? 0 : 1;
}
{
float A = glm::round(-0.0f);
float A = glm::roundEven(-0.0f);
Error += A == 0.0f ? 0 : 1;
float B = glm::round(-0.5f);
float B = glm::roundEven(-0.5f);
Error += B == -0.0f ? 0 : 1;
float C = glm::round(-1.0f);
float C = glm::roundEven(-1.0f);
Error += C == -1.0f ? 0 : 1;
float D = glm::round(-0.1f);
float D = glm::roundEven(-0.1f);
Error += D == 0.0f ? 0 : 1;
float E = glm::round(-0.9f);
float E = glm::roundEven(-0.9f);
Error += E == -1.0f ? 0 : 1;
float F = glm::round(-1.5f);
float F = glm::roundEven(-1.5f);
Error += F == -2.0f ? 0 : 1;
float G = glm::round(-1.9f);
float G = glm::roundEven(-1.9f);
Error += G == -2.0f ? 0 : 1;
}
{
float A = glm::round(1.5f);
float A = glm::roundEven(1.5f);
Error += A == 2.0f ? 0 : 1;
float B = glm::round(2.5f);
float B = glm::roundEven(2.5f);
Error += B == 2.0f ? 0 : 1;
float C = glm::round(3.5f);
float C = glm::roundEven(3.5f);
Error += C == 4.0f ? 0 : 1;
float D = glm::round(4.5f);
float D = glm::roundEven(4.5f);
Error += D == 4.0f ? 0 : 1;
float E = glm::round(5.5f);
float E = glm::roundEven(5.5f);
Error += E == 6.0f ? 0 : 1;
float F = glm::round(6.5f);
float F = glm::roundEven(6.5f);
Error += F == 6.0f ? 0 : 1;
float G = glm::round(7.5f);
float G = glm::roundEven(7.5f);
Error += G == 8.0f ? 0 : 1;
}
{
float A = glm::round(-1.5f);
float A = glm::roundEven(-1.5f);
Error += A == -2.0f ? 0 : 1;
float B = glm::round(-2.5f);
float B = glm::roundEven(-2.5f);
Error += B == -2.0f ? 0 : 1;
float C = glm::round(-3.5f);
float C = glm::roundEven(-3.5f);
Error += C == -4.0f ? 0 : 1;
float D = glm::round(-4.5f);
float D = glm::roundEven(-4.5f);
Error += D == -4.0f ? 0 : 1;
float E = glm::round(-5.5f);
float E = glm::roundEven(-5.5f);
Error += E == -6.0f ? 0 : 1;
float F = glm::round(-6.5f);
float F = glm::roundEven(-6.5f);
Error += F == -6.0f ? 0 : 1;
float G = glm::round(-7.5f);
float G = glm::roundEven(-7.5f);
Error += G == -8.0f ? 0 : 1;
}