From f889ac0bfeae70737d5c8024bce4111b2471695c Mon Sep 17 00:00:00 2001 From: Groove Date: Mon, 9 Jul 2018 21:55:19 +0200 Subject: [PATCH] Added initial constexpr tests #783 --- test/core/core_type_vec1.cpp | 3 --- test/core/core_type_vec2.cpp | 11 +++++++++++ test/core/core_type_vec3.cpp | 11 +++++++++++ test/core/core_type_vec4.cpp | 14 +++++++++++--- test/ext/ext_vec1.cpp | 11 +++++++++++ 5 files changed, 44 insertions(+), 6 deletions(-) diff --git a/test/core/core_type_vec1.cpp b/test/core/core_type_vec1.cpp index d82f84f3..cd2f1a49 100644 --- a/test/core/core_type_vec1.cpp +++ b/test/core/core_type_vec1.cpp @@ -107,9 +107,6 @@ int test_vec1_size() Error += glm::vec1::length() == 1 ? 0 : 1; Error += glm::dvec1::length() == 1 ? 0 : 1; - GLM_CONSTEXPR_CXX11 std::size_t Length = glm::vec1::length(); - Error += Length == 1 ? 0 : 1; - return Error; } diff --git a/test/core/core_type_vec2.cpp b/test/core/core_type_vec2.cpp index ae0e6d7d..42e73889 100644 --- a/test/core/core_type_vec2.cpp +++ b/test/core/core_type_vec2.cpp @@ -345,6 +345,16 @@ int test_operator_increment() return Error; } +int test_vec2_constexpr() +{ +#if GLM_HAS_CONSTEXPR_CXX11 + static_assert(glm::vec2::length() == 2, "GLM: Failed constexpr"); + static_assert(glm::vec2(1.0f).x > 0.0f, "GLM: Failed constexpr"); +#endif + + return 0; +} + int main() { int Error = 0; @@ -353,6 +363,7 @@ int main() Error += test_vec2_ctor(); Error += test_vec2_operators(); Error += test_operator_increment(); + Error += test_vec2_constexpr(); return Error; } diff --git a/test/core/core_type_vec3.cpp b/test/core/core_type_vec3.cpp index fa1c3c2a..3caa378c 100644 --- a/test/core/core_type_vec3.cpp +++ b/test/core/core_type_vec3.cpp @@ -558,6 +558,16 @@ int test_operator_increment() return Error; } +int test_vec3_constexpr() +{ +#if GLM_HAS_CONSTEXPR_CXX11 + static_assert(glm::vec3::length() == 3, "GLM: Failed constexpr"); + static_assert(glm::vec3(1.0f).x > 0.0f, "GLM: Failed constexpr"); +#endif + + return 0; +} + int main() { int Error = 0; @@ -569,6 +579,7 @@ int main() Error += test_vec3_swizzle3_2(); Error += test_vec3_swizzle3_3(); Error += test_operator_increment(); + Error += test_vec3_constexpr(); # if !GLM_HAS_ONLY_XYZW Error += test_vec3_swizzle_partial(); diff --git a/test/core/core_type_vec4.cpp b/test/core/core_type_vec4.cpp index 56a545d9..9d226a64 100644 --- a/test/core/core_type_vec4.cpp +++ b/test/core/core_type_vec4.cpp @@ -518,9 +518,6 @@ static int test_vec4_size() Error += glm::vec4::length() == 4 ? 0 : 1; Error += glm::dvec4::length() == 4 ? 0 : 1; - GLM_CONSTEXPR_CXX11 std::size_t Length = glm::vec4::length(); - Error += Length == 4 ? 0 : 1; - return Error; } @@ -723,6 +720,16 @@ static int test_inheritance() return Error; } +int test_vec4_constexpr() +{ +#if GLM_HAS_CONSTEXPR_CXX11 + static_assert(glm::vec4::length() == 4, "GLM: Failed constexpr"); + static_assert(glm::vec4(1.0f).x > 0.0f, "GLM: Failed constexpr"); +#endif + + return 0; +} + int main() { int Error = 0; @@ -788,6 +795,7 @@ int main() Error += test_operator_increment(); Error += heap::test(); Error += test_inheritance(); + Error += test_vec4_constexpr(); return Error; } diff --git a/test/ext/ext_vec1.cpp b/test/ext/ext_vec1.cpp index b89af87c..91b45cb8 100644 --- a/test/ext/ext_vec1.cpp +++ b/test/ext/ext_vec1.cpp @@ -132,6 +132,16 @@ static int test_bvec1_ctor() return Error; } +int test_vec1_constexpr() +{ +#if GLM_HAS_CONSTEXPR_CXX11 + static_assert(glm::vec1::length() == 1, "GLM: Failed constexpr"); + static_assert(glm::vec1(1.0f).x > 0.0f, "GLM: Failed constexpr"); +#endif + + return 0; +} + int main() { int Error = 0; @@ -141,6 +151,7 @@ int main() Error += test_bvec1_ctor(); Error += test_vec1_operators(); Error += test_vec1_operator_increment(); + Error += test_vec1_constexpr(); return Error; }