Improved constexpr support

This commit is contained in:
Groove
2018-07-29 00:33:09 +02:00
parent 178314a67d
commit 472f2c13b7
11 changed files with 46 additions and 30 deletions

View File

@@ -31,6 +31,8 @@ static int test_vec1()
}
{
constexpr glm::ivec1 A(1);
static_assert(A[0] == 1, "GLM: Failed constexpr");
static_assert(glm::vec1(1.0f).x > 0.0f, "GLM: Failed constexpr");
static_assert(glm::vec1::length() == 1, "GLM: Failed constexpr");
}
@@ -85,6 +87,8 @@ static int test_vec2()
}
{
constexpr glm::ivec2 A(1);
static_assert(A[0] == 1, "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");
@@ -100,6 +104,13 @@ static int test_vec2()
static_assert(A1 == A2 || B1 == B2, "GLM: Failed constexpr");
}
{
constexpr glm::ivec2 A(1);
constexpr glm::ivec2 B = A + 1;
constexpr glm::ivec2 C(3);
static_assert(A + B == C, "GLM: Failed constexpr");
}
return Error;
}
@@ -161,6 +172,8 @@ static int test_vec3()
}
{
constexpr glm::ivec3 const A(1);
static_assert(A[0] == 1, "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");
@@ -215,6 +228,8 @@ static int test_vec4()
}
{
constexpr glm::ivec4 A(1);
static_assert(A[0] == 1, "GLM: Failed constexpr");
static_assert(glm::ivec4(1).x > 0, "GLM: Failed constexpr");
static_assert(glm::ivec4(1.0f, -1.0f, -1.0f, 1.0f).x > 0, "GLM: Failed constexpr");
static_assert(glm::ivec4(1.0f, -1.0f, -1.0f, 1.0f).y < 0, "GLM: Failed constexpr");
@@ -244,6 +259,7 @@ static int test_quat()
glm::quat constexpr Q = glm::identity<glm::quat>();
static_assert(Q.x - glm::quat(1.0f, glm::vec3(0.0f)).x <= glm::epsilon<float>(), "GLM: Failed constexpr");
static_assert(Q[0] == 0, "GLM: Failed constexpr");
}
return Error;