Browse Source

Merge branch '0.9.8'

Christophe Riccio 9 years ago
parent
commit
c7e81fb3f7
3 changed files with 24 additions and 25 deletions
  1. 2 1
      test/core/core_func_exponential.cpp
  2. 2 6
      test/gtc/gtc_noise.cpp
  3. 20 18
      test/gtc/gtc_random.cpp

+ 2 - 1
test/core/core_func_exponential.cpp

@@ -98,7 +98,7 @@ int test_inversesqrt()
 	glm::uint ulp(0);
 	float diff(0.0f);
 
-	for(float f = 0.001f; f < 10.f; f *= 1.001f)
+	for(float f = 0.001f; f < 10.f; f *= 1.01f)
 	{
 		glm::lowp_fvec1 u(f);
 		glm::lowp_fvec1 lowp_v = glm::inversesqrt(u);
@@ -106,6 +106,7 @@ int test_inversesqrt()
 
 		ulp = glm::max(glm::float_distance(lowp_v.x, defaultp_v), ulp);
 		diff = glm::abs(lowp_v.x - defaultp_v);
+		Error += diff > 0.1f ? 1 : 0;
 	}
 
 	return Error;

+ 2 - 6
test/gtc/gtc_noise.cpp

@@ -4,10 +4,10 @@
 #if GLM_LANG & GLM_LANG_CXX11_FLAG
 #include <gli/gli.hpp>
 
+std::size_t const Size = 64;
+
 int test_simplex()
 {
-	std::size_t const Size = 256;
-
 	{
 		gli::texture2d Texture(gli::FORMAT_RGBA8_UNORM_PACK8, gli::texture2d::extent_type(Size), 1);
 		
@@ -55,8 +55,6 @@ int test_simplex()
 
 int test_perlin()
 {
-	std::size_t const Size = 256;
-
 	{
 		gli::texture2d Texture(gli::FORMAT_RGBA8_UNORM_PACK8, gli::texture2d::extent_type(Size), 1);
 
@@ -104,8 +102,6 @@ int test_perlin()
 
 int test_perlin_pedioric()
 {
-	std::size_t const Size = 256;
-
 	{
 		gli::texture2d Texture(gli::FORMAT_RGBA8_UNORM_PACK8, gli::texture2d::extent_type(Size), 1);
 

+ 20 - 18
test/gtc/gtc_random.cpp

@@ -4,6 +4,8 @@
 #	include <array>
 #endif
 
+std::size_t const TestSamples = 10000;
+
 int test_linearRand()
 {
 	int Error = 0;
@@ -15,7 +17,7 @@ int test_linearRand()
 		glm::u8vec2 AMin(std::numeric_limits<glm::u8>::max());
 		glm::u8vec2 AMax(std::numeric_limits<glm::u8>::min());
 		{
-			for(std::size_t i = 0; i < 100000; ++i)
+			for(std::size_t i = 0; i < TestSamples; ++i)
 			{
 				glm::u8vec2 A = glm::linearRand(glm::u8vec2(Min), glm::u8vec2(Max));
 				AMin = glm::min(AMin, A);
@@ -36,7 +38,7 @@ int test_linearRand()
 		glm::u16vec2 BMin(std::numeric_limits<glm::u16>::max());
 		glm::u16vec2 BMax(std::numeric_limits<glm::u16>::min());
 		{
-			for(std::size_t i = 0; i < 100000; ++i)
+			for(std::size_t i = 0; i < TestSamples; ++i)
 			{
 				glm::u16vec2 B = glm::linearRand(glm::u16vec2(Min), glm::u16vec2(Max));
 				BMin = glm::min(BMin, B);
@@ -57,7 +59,7 @@ int test_linearRand()
 		glm::u32vec2 CMin(std::numeric_limits<glm::u32>::max());
 		glm::u32vec2 CMax(std::numeric_limits<glm::u32>::min());
 		{
-			for(std::size_t i = 0; i < 100000; ++i)
+			for(std::size_t i = 0; i < TestSamples; ++i)
 			{
 				glm::u32vec2 C = glm::linearRand(glm::u32vec2(Min), glm::u32vec2(Max));
 				CMin = glm::min(CMin, C);
@@ -78,7 +80,7 @@ int test_linearRand()
 		glm::u64vec2 DMin(std::numeric_limits<glm::u64>::max());
 		glm::u64vec2 DMax(std::numeric_limits<glm::u64>::min());
 		{
-			for(std::size_t i = 0; i < 100000; ++i)
+			for(std::size_t i = 0; i < TestSamples; ++i)
 			{
 				glm::u64vec2 D = glm::linearRand(glm::u64vec2(Min), glm::u64vec2(Max));
 				DMin = glm::min(DMin, D);
@@ -101,7 +103,7 @@ int test_linearRand()
 		glm::i8vec2 AMin(std::numeric_limits<glm::i8>::max());
 		glm::i8vec2 AMax(std::numeric_limits<glm::i8>::min());
 		{
-			for(std::size_t i = 0; i < 100000; ++i)
+			for(std::size_t i = 0; i < TestSamples; ++i)
 			{
 				glm::i8vec2 A = glm::linearRand(glm::i8vec2(Min), glm::i8vec2(Max));
 				AMin = glm::min(AMin, A);
@@ -122,7 +124,7 @@ int test_linearRand()
 		glm::i16vec2 BMin(std::numeric_limits<glm::i16>::max());
 		glm::i16vec2 BMax(std::numeric_limits<glm::i16>::min());
 		{
-			for(std::size_t i = 0; i < 100000; ++i)
+			for(std::size_t i = 0; i < TestSamples; ++i)
 			{
 				glm::i16vec2 B = glm::linearRand(glm::i16vec2(Min), glm::i16vec2(Max));
 				BMin = glm::min(BMin, B);
@@ -143,7 +145,7 @@ int test_linearRand()
 		glm::i32vec2 CMin(std::numeric_limits<glm::i32>::max());
 		glm::i32vec2 CMax(std::numeric_limits<glm::i32>::min());
 		{
-			for(std::size_t i = 0; i < 100000; ++i)
+			for(std::size_t i = 0; i < TestSamples; ++i)
 			{
 				glm::i32vec2 C = glm::linearRand(glm::i32vec2(Min), glm::i32vec2(Max));
 				CMin = glm::min(CMin, C);
@@ -164,7 +166,7 @@ int test_linearRand()
 		glm::i64vec2 DMin(std::numeric_limits<glm::i64>::max());
 		glm::i64vec2 DMax(std::numeric_limits<glm::i64>::min());
 		{
-			for(std::size_t i = 0; i < 100000; ++i)
+			for(std::size_t i = 0; i < TestSamples; ++i)
 			{
 				glm::i64vec2 D = glm::linearRand(glm::i64vec2(Min), glm::i64vec2(Max));
 				DMin = glm::min(DMin, D);
@@ -183,7 +185,7 @@ int test_linearRand()
 		}
 	}
 
-	for(std::size_t i = 0; i < 100000; ++i)
+	for(std::size_t i = 0; i < TestSamples; ++i)
 	{
 		glm::f32vec2 const A(glm::linearRand(glm::f32vec2(static_cast<float>(Min)), glm::f32vec2(static_cast<float>(Max))));
 		if(!glm::all(glm::lessThanEqual(A, glm::f32vec2(static_cast<float>(Max)))))
@@ -202,7 +204,7 @@ int test_linearRand()
 	{
 		float ResultFloat = 0.0f;
 		double ResultDouble = 0.0f;
-		for(std::size_t i = 0; i < 100000; ++i)
+		for(std::size_t i = 0; i < TestSamples; ++i)
 		{
 			ResultFloat += glm::linearRand(-1.0f, 1.0f);
 			ResultDouble += glm::linearRand(-1.0, 1.0);
@@ -221,7 +223,7 @@ int test_circularRand()
 	int Error = 0;
 
 	{
-		std::size_t Max = 100000;
+		std::size_t Max = TestSamples;
 		float ResultFloat = 0.0f;
 		double ResultDouble = 0.0f;
 		double Radius = 2.0f;
@@ -245,7 +247,7 @@ int test_sphericalRand()
 	int Error = 0;
 
 	{
-		std::size_t Max = 100000;
+		std::size_t Max = TestSamples;
 		float ResultFloatA = 0.0f;
 		float ResultFloatB = 0.0f;
 		float ResultFloatC = 0.0f;
@@ -283,14 +285,14 @@ int test_diskRand()
 		float ResultFloat = 0.0f;
 		double ResultDouble = 0.0f;
 
-		for(std::size_t i = 0; i < 100000; ++i)
+		for(std::size_t i = 0; i < TestSamples; ++i)
 		{
 			ResultFloat += glm::length(glm::diskRand(2.0f));
 			ResultDouble += glm::length(glm::diskRand(2.0));
 		}
 
-		Error += ResultFloat < 200000.f ? 0 : 1;
-		Error += ResultDouble < 200000.0 ? 0 : 1;
+		Error += ResultFloat < float(TestSamples) * 2.f ? 0 : 1;
+		Error += ResultDouble < double(TestSamples) * 2.0 ? 0 : 1;
 		assert(!Error);
 	}
 
@@ -305,14 +307,14 @@ int test_ballRand()
 		float ResultFloat = 0.0f;
 		double ResultDouble = 0.0f;
 
-		for(std::size_t i = 0; i < 100000; ++i)
+		for(std::size_t i = 0; i < TestSamples; ++i)
 		{
 			ResultFloat += glm::length(glm::ballRand(2.0f));
 			ResultDouble += glm::length(glm::ballRand(2.0));
 		}
 
-		Error += ResultFloat < 200000.f ? 0 : 1;
-		Error += ResultDouble < 200000.0 ? 0 : 1;
+		Error += ResultFloat < float(TestSamples) * 2.f ? 0 : 1;
+		Error += ResultDouble < double(TestSamples) * 2.0 ? 0 : 1;
 		assert(!Error);
 	}