From 4dce0e338d70eb22deb93e9780a89044771db266 Mon Sep 17 00:00:00 2001 From: Groove Date: Thu, 26 Jul 2018 23:33:10 +0200 Subject: [PATCH] Added vector relational tests --- glm/detail/compute_vector_relational.hpp | 5 +- test/core/core_func_vector_relational.cpp | 146 +++++++++++++++++++++- 2 files changed, 145 insertions(+), 6 deletions(-) diff --git a/glm/detail/compute_vector_relational.hpp b/glm/detail/compute_vector_relational.hpp index 20637a3c..167b6345 100644 --- a/glm/detail/compute_vector_relational.hpp +++ b/glm/detail/compute_vector_relational.hpp @@ -1,6 +1,6 @@ #pragma once -#include "compute_common.hpp" +//#include "compute_common.hpp" #include "setup.hpp" #include @@ -15,7 +15,7 @@ namespace detail return a == b; } }; - +/* template struct compute_equal { @@ -25,5 +25,6 @@ namespace detail //return std::memcmp(&a, &b, sizeof(T)) == 0; } }; +*/ }//namespace detail }//namespace glm diff --git a/test/core/core_func_vector_relational.cpp b/test/core/core_func_vector_relational.cpp index 55672b76..0a4e7e7c 100644 --- a/test/core/core_func_vector_relational.cpp +++ b/test/core/core_func_vector_relational.cpp @@ -6,7 +6,7 @@ static int test_not() { - int Error(0); + int Error = 0; { glm::bvec1 v(false); @@ -31,11 +31,149 @@ static int test_not() return Error; } -int main() +static int test_less() { - int Error(0); + int Error = 0; - Error += test_not(); + { + glm::vec2 const A(1, 2); + glm::vec2 const B(2, 3); + Error += glm::all(glm::lessThan(A, B)) ? 0: 1; + Error += glm::all(glm::lessThanEqual(A, B)) ? 0: 1; + } + + { + glm::vec3 const A(1, 2, 3); + glm::vec3 const B(2, 3, 4); + Error += glm::all(glm::lessThan(A, B)) ? 0: 1; + Error += glm::all(glm::lessThanEqual(A, B)) ? 0: 1; + } + + { + glm::vec4 const A(1, 2, 3, 4); + glm::vec4 const B(2, 3, 4, 5); + Error += glm::all(glm::lessThan(A, B)) ? 0: 1; + Error += glm::all(glm::lessThanEqual(A, B)) ? 0: 1; + } + + { + glm::ivec2 const A(1, 2); + glm::ivec2 const B(2, 3); + Error += glm::all(glm::lessThan(A, B)) ? 0: 1; + + glm::ivec2 const C(1, 3); + Error += glm::all(glm::lessThanEqual(A, C)) ? 0: 1; + } + + { + glm::ivec3 const A(1, 2, 3); + glm::ivec3 const B(2, 3, 4); + Error += glm::all(glm::lessThan(A, B)) ? 0: 1; + + glm::ivec3 const C(1, 3, 4); + Error += glm::all(glm::lessThanEqual(A, C)) ? 0: 1; + } + + { + glm::ivec4 const A(1, 2, 3, 4); + glm::ivec4 const B(2, 3, 4, 5); + Error += glm::all(glm::lessThan(A, B)) ? 0: 1; + + glm::ivec4 const C(1, 3, 4, 5); + Error += glm::all(glm::lessThanEqual(A, C)) ? 0: 1; + } + + return Error; +} + +static int test_greater() +{ + int Error = 0; + + { + glm::vec2 const A(1, 2); + glm::vec2 const B(2, 3); + Error += glm::all(glm::greaterThan(B, A)) ? 0: 1; + Error += glm::all(glm::greaterThanEqual(B, A)) ? 0: 1; + } + + { + glm::vec3 const A(1, 2, 3); + glm::vec3 const B(2, 3, 4); + Error += glm::all(glm::greaterThan(B, A)) ? 0: 1; + Error += glm::all(glm::greaterThanEqual(B, A)) ? 0: 1; + } + + { + glm::vec4 const A(1, 2, 3, 4); + glm::vec4 const B(2, 3, 4, 5); + Error += glm::all(glm::greaterThan(B, A)) ? 0: 1; + Error += glm::all(glm::greaterThanEqual(B, A)) ? 0: 1; + } + + { + glm::ivec2 const A(1, 2); + glm::ivec2 const B(2, 3); + Error += glm::all(glm::greaterThan(B, A)) ? 0: 1; + + glm::ivec2 const C(1, 3); + Error += glm::all(glm::greaterThanEqual(C, A)) ? 0: 1; + } + + { + glm::ivec3 const A(1, 2, 3); + glm::ivec3 const B(2, 3, 4); + Error += glm::all(glm::greaterThan(B, A)) ? 0: 1; + + glm::ivec3 const C(1, 3, 4); + Error += glm::all(glm::greaterThanEqual(C, A)) ? 0: 1; + } + + { + glm::ivec4 const A(1, 2, 3, 4); + glm::ivec4 const B(2, 3, 4, 5); + Error += glm::all(glm::greaterThan(B, A)) ? 0: 1; + + glm::ivec4 const C(1, 3, 4, 5); + Error += glm::all(glm::greaterThanEqual(C, A)) ? 0: 1; + } + + return Error; +} + +static int test_equal() +{ + int Error = 0; + + { + glm::ivec2 const A(1, 2); + glm::ivec2 const B(1, 2); + Error += glm::all(glm::equal(B, A)) ? 0: 1; + } + + { + glm::ivec3 const A(1, 2, 3); + glm::ivec3 const B(1, 2, 3); + Error += glm::all(glm::equal(B, A)) ? 0: 1; + } + + { + glm::ivec4 const A(1, 2, 3, 4); + glm::ivec4 const B(1, 2, 3, 4); + Error += glm::all(glm::equal(B, A)) ? 0: 1; + } + + return Error; +} + +int main() +{ + int Error = 0; + + Error += test_not(); + Error += test_less(); + Error += test_greater(); + Error += test_equal(); return Error; }