Skip to content

Commit

Permalink
Added more constexpr tests #783
Browse files Browse the repository at this point in the history
  • Loading branch information
Groove committed Jul 9, 2018
1 parent d3a2542 commit f95abf2
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
2 changes: 2 additions & 0 deletions test/core/core_type_vec2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,8 @@ static int test_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");
static_assert(glm::vec2(1.0f, -1.0f).x > 0.0f, "GLM: Failed constexpr");
static_assert(glm::vec2(1.0f, -1.0f).y < 0.0f, "GLM: Failed constexpr");
#endif

return 0;
Expand Down
2 changes: 2 additions & 0 deletions test/core/core_type_vec3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,8 @@ static int test_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");
static_assert(glm::vec3(1.0f, -1.0f, -1.0f).x > 0.0f, "GLM: Failed constexpr");
static_assert(glm::vec3(1.0f, -1.0f, -1.0f).y < 0.0f, "GLM: Failed constexpr");
#endif

return 0;
Expand Down
13 changes: 2 additions & 11 deletions test/core/core_type_vec4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,6 @@ static int test_vec4_ctor()
}
#endif// GLM_HAS_UNRESTRICTED_UNIONS && defined(GLM_FORCE_SWIZZLE)

# if GLM_HAS_CONSTEXPR && GLM_ARCH == GLM_ARCH_PURE && !(GLM_COMPILER & GLM_COMPILER_VC) // Visual Studio bug?
{
constexpr glm::ivec4 v(1);

Error += v.x == 1 ? 0 : 1;
Error += v.y == 1 ? 0 : 1;
Error += v.z == 1 ? 0 : 1;
Error += v.w == 1 ? 0 : 1;
}
# endif

{
glm::vec4 A(1);
glm::vec4 B(1, 1, 1, 1);
Expand Down Expand Up @@ -725,6 +714,8 @@ static int test_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");
static_assert(glm::vec4(1.0f, -1.0f, -1.0f, -1.0f).x > 0.0f, "GLM: Failed constexpr");
static_assert(glm::vec4(1.0f, -1.0f, -1.0f, -1.0f).y < 0.0f, "GLM: Failed constexpr");
#endif

return 0;
Expand Down
13 changes: 12 additions & 1 deletion test/gtc/gtc_quaternion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ int test_quat_slerp()

int test_quat_mul()
{
int Error(0);
int Error = 0;

glm::quat temp1 = glm::normalize(glm::quat(1.0f, glm::vec3(0.0, 1.0, 0.0)));
glm::quat temp2 = glm::normalize(glm::quat(0.5f, glm::vec3(1.0, 0.0, 0.0)));
Expand Down Expand Up @@ -307,6 +307,16 @@ int test_size()
return Error;
}

static int test_constexpr()
{
#if GLM_HAS_CONSTEXPR_CXX11
static_assert(glm::quat::length() == 4, "GLM: Failed constexpr");
static_assert(glm::quat(1.0f, glm::vec3(0.0f)).w > 0.0f, "GLM: Failed constexpr");
#endif

return 0;
}

int main()
{
int Error = 0;
Expand All @@ -323,6 +333,7 @@ int main()
Error += test_quat_euler();
Error += test_quat_slerp();
Error += test_size();
Error += test_constexpr();

return Error;
}

0 comments on commit f95abf2

Please sign in to comment.