From c4f52dc98f3e5c87e4a3077fad2b7fe611135aae Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Tue, 1 Nov 2016 09:14:28 +0100 Subject: [PATCH] Added test for quat type component length() static #565 --- test/gtc/gtc_quaternion.cpp | 17 ++++++++++++++++- test/gtx/gtx_dual_quaternion.cpp | 17 ++++++++++++++++- test/gtx/gtx_quaternion.cpp | 2 +- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/test/gtc/gtc_quaternion.cpp b/test/gtc/gtc_quaternion.cpp index 49ac157b5..db410fc43 100644 --- a/test/gtc/gtc_quaternion.cpp +++ b/test/gtc/gtc_quaternion.cpp @@ -291,9 +291,23 @@ int test_quat_ctr() return Error; } +int test_size() +{ + int Error = 0; + + Error += 16 == sizeof(glm::quat) ? 0 : 1; + Error += 32 == sizeof(glm::dquat) ? 0 : 1; + Error += glm::quat().length() == 4 ? 0 : 1; + Error += glm::dquat().length() == 4 ? 0 : 1; + Error += glm::quat::length() == 4 ? 0 : 1; + Error += glm::dquat::length() == 4 ? 0 : 1; + + return Error; +} + int main() { - int Error(0); + int Error = 0; Error += test_quat_ctr(); Error += test_quat_mul_vec(); @@ -307,6 +321,7 @@ int main() Error += test_quat_normalize(); Error += test_quat_euler(); Error += test_quat_slerp(); + Error += test_size(); return Error; } diff --git a/test/gtx/gtx_dual_quaternion.cpp b/test/gtx/gtx_dual_quaternion.cpp index b06bba359..73d400f00 100644 --- a/test/gtx/gtx_dual_quaternion.cpp +++ b/test/gtx/gtx_dual_quaternion.cpp @@ -174,15 +174,30 @@ int test_dual_quat_ctr() return Error; } +int test_size() +{ + int Error = 0; + + Error += 32 == sizeof(glm::dualquat) ? 0 : 1; + Error += 64 == sizeof(glm::ddualquat) ? 0 : 1; + Error += glm::dualquat().length() == 2 ? 0 : 1; + Error += glm::ddualquat().length() == 2 ? 0 : 1; + Error += glm::dualquat::length() == 2 ? 0 : 1; + Error += glm::ddualquat::length() == 2 ? 0 : 1; + + return Error; +} + int main() { - int Error(0); + int Error = 0; Error += test_dual_quat_ctr(); Error += test_dquat_type(); Error += test_scalars(); Error += test_inverse(); Error += test_mul(); + Error += test_size(); return Error; } diff --git a/test/gtx/gtx_quaternion.cpp b/test/gtx/gtx_quaternion.cpp index d3938fb17..12e12b2a3 100644 --- a/test/gtx/gtx_quaternion.cpp +++ b/test/gtx/gtx_quaternion.cpp @@ -91,7 +91,7 @@ int test_log() int main() { - int Error(0); + int Error = 0; Error += test_log(); Error += test_rotation();