diff --git a/test/gtc/gtc_round.cpp b/test/gtc/gtc_round.cpp index 1162d00f..aa6cf1a1 100644 --- a/test/gtc/gtc_round.cpp +++ b/test/gtc/gtc_round.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -293,6 +294,86 @@ namespace ceilPowerOfTwo } }//namespace ceilPowerOfTwo +namespace floorMultiple +{ + template + struct type + { + genType Source; + genType Multiple; + genType Return; + genType Epsilon; + }; + + int test_float() + { + type const Data[] = + { + {3.4, 0.3, 3.3, 0.0001}, + {-1.4, 0.3, -1.5, 0.0001}, + }; + + int Error(0); + + for(std::size_t i = 0, n = sizeof(Data) / sizeof(type); i < n; ++i) + { + glm::float64 Result = glm::floorMultiple(Data[i].Source, Data[i].Multiple); + Error += glm::epsilonEqual(Data[i].Return, Result, Data[i].Epsilon) ? 0 : 1; + } + + return Error; + } + + int test() + { + int Error(0); + + Error += test_float(); + + return Error; + } +}//namespace floorMultiple + +namespace ceilMultiple +{ + template + struct type + { + genType Source; + genType Multiple; + genType Return; + genType Epsilon; + }; + + int test_float() + { + type const Data[] = + { + {3.4, 0.3, 3.6, 0.0001}, + {-1.4, 0.3, -1.2, 0.0001}, + }; + + int Error(0); + + for(std::size_t i = 0, n = sizeof(Data) / sizeof(type); i < n; ++i) + { + glm::float64 Result = glm::ceilMultiple(Data[i].Source, Data[i].Multiple); + Error += glm::epsilonEqual(Data[i].Return, Result, Data[i].Epsilon) ? 0 : 1; + } + + return Error; + } + + int test() + { + int Error(0); + + Error += test_float(); + + return Error; + } +}//namespace ceilMultiple + int main() { int Error(0); @@ -304,5 +385,8 @@ int main() Error += ceilPowerOfTwo::perf(); # endif//NDEBUG + Error += floorMultiple::test(); + Error += ceilMultiple::test(); + return Error; }