Browse Source

Added more constexpr tests #783

Groove 7 years ago
parent
commit
f95abf2c27

+ 2 - 0
test/core/core_type_vec2.cpp

@@ -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;

+ 2 - 0
test/core/core_type_vec3.cpp

@@ -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;

+ 2 - 11
test/core/core_type_vec4.cpp

@@ -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);
@@ -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;

+ 12 - 1
test/gtc/gtc_quaternion.cpp

@@ -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)));
@@ -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;
@@ -323,6 +333,7 @@ int main()
 	Error += test_quat_euler();
 	Error += test_quat_slerp();
 	Error += test_size();
+	Error += test_constexpr();
 
 	return Error;
 }