From 8f7d37811679c457f18cd5e514b1521e9e965088 Mon Sep 17 00:00:00 2001 From: Liam Adams Date: Fri, 19 Jul 2019 18:28:31 +0100 Subject: [PATCH] Add testing of lxNorm. --- test/gtx/gtx_norm.cpp | 54 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/test/gtx/gtx_norm.cpp b/test/gtx/gtx_norm.cpp index 38cef8c2..7efaa6e7 100644 --- a/test/gtx/gtx_norm.cpp +++ b/test/gtx/gtx_norm.cpp @@ -1,9 +1,63 @@ #define GLM_ENABLE_EXPERIMENTAL #include +int test_lxNorm() +{ + int Error(0); + + { + unsigned int depth_1 = 1; + float normA = glm::lxNorm(glm::vec3(2, 3, 1), depth_1); + float normB = glm::l1Norm(glm::vec3(2, 3, 1)); + Error += glm::epsilonEqual(normA, normB, 0.00001f) ? 0 : 1; + Error += glm::epsilonEqual(normA, 6.f, 0.00001f) ? 0 : 1; + } + + { + unsigned int depth_1 = 1; + float normA = glm::lxNorm(glm::vec3(-1, -2, -3), depth_1); + float normB = glm::l1Norm(glm::vec3(-1, -2, -3)); + Error += glm::epsilonEqual(normA, normB, 0.00001f) ? 0 : 1; + Error += glm::epsilonEqual(normA, 6.f, 0.00001f) ? 0 : 1; + } + + { + unsigned int depth_2 = 2; + float normA = glm::lxNorm(glm::vec3(2, 3, 1), depth_2); + float normB = glm::l2Norm(glm::vec3(2, 3, 1)); + Error += glm::epsilonEqual(normA, normB, 0.00001f) ? 0 : 1; + Error += glm::epsilonEqual(normA, 3.741657387f, 0.00001f) ? 0 : 1; + } + + { + unsigned int depth_2 = 2; + float normA = glm::lxNorm(glm::vec3(-1, -2, -3), depth_2); + float normB = glm::l2Norm(glm::vec3(-1, -2, -3)); + Error += glm::epsilonEqual(normA, normB, 0.00001f) ? 0 : 1; + Error += glm::epsilonEqual(normA, 3.741657387f, 0.00001f) ? 0 : 1; + } + + { + unsigned int oddDepth = 3; + float norm = glm::lxNorm(glm::vec3(2, 3, 1), oddDepth); + Error += glm::epsilonEqual(norm, 3.301927249f, 0.00001f) ? 0 : 1; + } + + { + unsigned int oddDepth = 3; + float norm = glm::lxNorm(glm::vec3(-1, -2, -3), oddDepth); + Error += glm::epsilonEqual(norm, 3.301927249f, 0.00001f) ? 0 : 1; + } + + + return Error; +} + int main() { int Error(0); + Error += test_lxNorm(); + return Error; }