Browse Source

Added initial constexpr tests #783

Groove 7 years ago
parent
commit
f889ac0bfe

+ 0 - 3
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;
 }
 

+ 11 - 0
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;
 }

+ 11 - 0
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();

+ 11 - 3
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;
 }

+ 11 - 0
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;
 }