From c83e38f9fb497c2bcfa1e6cd6a1d19263a9f5955 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Sun, 20 Nov 2016 22:53:13 +0100 Subject: [PATCH 1/2] Prevent TravisCI timeout, shorter test --- test/core/core_func_exponential.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/core/core_func_exponential.cpp b/test/core/core_func_exponential.cpp index 665d8df6..7096e9f9 100644 --- a/test/core/core_func_exponential.cpp +++ b/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; From 9755dea06287ccef7a0e0658f71e589c3d531945 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Sun, 20 Nov 2016 23:02:20 +0100 Subject: [PATCH 2/2] Quicker unit tests --- test/gtc/gtc_noise.cpp | 8 ++------ test/gtc/gtc_random.cpp | 38 ++++++++++++++++++++------------------ 2 files changed, 22 insertions(+), 24 deletions(-) diff --git a/test/gtc/gtc_noise.cpp b/test/gtc/gtc_noise.cpp index ec58693e..55555bc4 100644 --- a/test/gtc/gtc_noise.cpp +++ b/test/gtc/gtc_noise.cpp @@ -2,10 +2,10 @@ #include #include +std::size_t const Size = 64; + int test_simplex() { - std::size_t const Size = 256; - { std::vector ImageData(Size * Size * 3); @@ -62,8 +62,6 @@ int test_simplex() int test_perlin() { - std::size_t const Size = 256; - { std::vector ImageData(Size * Size * 3); @@ -120,8 +118,6 @@ int test_perlin() int test_perlin_pedioric() { - std::size_t const Size = 256; - { std::vector ImageData(Size * Size * 3); diff --git a/test/gtc/gtc_random.cpp b/test/gtc/gtc_random.cpp index 6c3b3d0e..d744ea5c 100644 --- a/test/gtc/gtc_random.cpp +++ b/test/gtc/gtc_random.cpp @@ -4,6 +4,8 @@ # include #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::max()); glm::u8vec2 AMax(std::numeric_limits::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::max()); glm::u16vec2 BMax(std::numeric_limits::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::max()); glm::u32vec2 CMax(std::numeric_limits::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::max()); glm::u64vec2 DMax(std::numeric_limits::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::max()); glm::i8vec2 AMax(std::numeric_limits::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::max()); glm::i16vec2 BMax(std::numeric_limits::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::max()); glm::i32vec2 CMax(std::numeric_limits::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::max()); glm::i64vec2 DMax(std::numeric_limits::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(Min)), glm::f32vec2(static_cast(Max)))); if(!glm::all(glm::lessThanEqual(A, glm::f32vec2(static_cast(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); }