From 4ac1d9c5cf48185f2aed4bd0689f39df02dc6fa2 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Fri, 16 Sep 2011 00:15:02 +0100 Subject: [PATCH] Added round tests --- test/core/core_func_common.cpp | 38 ++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/test/core/core_func_common.cpp b/test/core/core_func_common.cpp index 3eb81267..0ec771fe 100644 --- a/test/core/core_func_common.cpp +++ b/test/core/core_func_common.cpp @@ -121,6 +121,43 @@ int test_mix() return Error; } +int test_round() +{ + int Error = 0; + + { + float A = glm::round(0.0f); + Error += A == 0.0f ? 0 : 1; + float B = glm::round(0.5f); + Error += B == 1.0f ? 0 : 1; + float C = glm::round(1.0f); + Error += C == 1.0f ? 0 : 1; + float D = glm::round(0.1f); + Error += D == 0.0f ? 0 : 1; + float E = glm::round(0.9f); + Error += E == 1.0f ? 0 : 1; + float F = glm::round(1.9f); + Error += F == 2.0f ? 0 : 1; + } + + { + float A = glm::round(-0.0f); + Error += A == 0.0f ? 0 : 1; + float B = glm::round(-0.5f); + Error += B == -1.0f ? 0 : 1; + float C = glm::round(-1.0f); + Error += C == -1.0f ? 0 : 1; + float D = glm::round(-0.1f); + Error += D == 0.0f ? 0 : 1; + float E = glm::round(-0.9f); + Error += E == -1.0f ? 0 : 1; + float F = glm::round(-1.9f); + Error += F == -2.0f ? 0 : 1; + } + + return Error; +} + int main() { int Error = 0; @@ -128,6 +165,7 @@ int main() Error += test_floatBitsToInt(); Error += test_floatBitsToUint(); Error += test_mix(); + Error += test_round(); return Error; }