Added tests for issue #72

This commit is contained in:
Christophe Riccio 2013-05-05 21:36:22 +02:00
parent c795562f67
commit 56564badb5
3 changed files with 94 additions and 6 deletions

View File

@ -106,8 +106,8 @@ namespace glm
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/any.xml">GLSL any man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.7 Vector Relational Functions</a>
template <template <typename> class vecType>
bool any(vecType<bool> const & v);
template <precision P, template <typename, precision> class vecType>
bool any(vecType<bool, P> const & v);
/// Returns true if all components of x are true.
///
@ -115,8 +115,8 @@ namespace glm
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/all.xml">GLSL all man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.7 Vector Relational Functions</a>
template <template <typename> class vecType>
bool all(vecType<bool> const & v);
template <precision P, template <typename, precision> class vecType>
bool all(vecType<bool, P> const & v);
/// Returns the component-wise logical complement of x.
/// /!\ Because of language incompatibilities between C++ and GLSL, GLM defines the function not but not_ instead.
@ -125,8 +125,8 @@ namespace glm
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/not.xml">GLSL not man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.7 Vector Relational Functions</a>
template <template <typename> class vecType>
vecType<bool> not_(vecType<bool> const & v);
template <precision P, template <typename, precision> class vecType>
vecType<bool, P> not_(vecType<bool, P> const & v);
/// @}
}//namespace glm

View File

@ -1,3 +1,4 @@
glmCreateTestGTC(core_type_cast)
glmCreateTestGTC(core_type_float)
glmCreateTestGTC(core_type_half)
glmCreateTestGTC(core_type_int)

View File

@ -0,0 +1,87 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2013-05-06
// Updated : 2013-05-06
// Licence : This source is under MIT License
// File : test/core/type_cast.cpp
///////////////////////////////////////////////////////////////////////////////////////////////////
#include <glm/glm.hpp>
int test_vec2_cast()
{
glm::vec2 A(1.0f, 2.0f);
glm::lowp_vec2 B(A);
glm::mediump_vec2 C(A);
glm::highp_vec2 D(A);
glm::vec2 E = static_cast<glm::vec2>(A);
glm::lowp_vec2 F = static_cast<glm::lowp_vec2>(A);
glm::mediump_vec2 G = static_cast<glm::mediump_vec2>(A);
glm::highp_vec2 H = static_cast<glm::highp_vec2>(A);
int Error(0);
Error += glm::all(glm::equal(A, E)) ? 0 : 1;
Error += glm::all(glm::equal(B, F)) ? 0 : 1;
Error += glm::all(glm::equal(C, G)) ? 0 : 1;
Error += glm::all(glm::equal(D, H)) ? 0 : 1;
return Error;
}
int test_vec3_cast()
{
glm::vec3 A(1.0f, 2.0f, 3.0f);
glm::lowp_vec3 B(A);
glm::mediump_vec3 C(A);
glm::highp_vec3 D(A);
glm::vec3 E = static_cast<glm::vec3>(A);
glm::lowp_vec3 F = static_cast<glm::lowp_vec3>(A);
glm::mediump_vec3 G = static_cast<glm::mediump_vec3>(A);
glm::highp_vec3 H = static_cast<glm::highp_vec3>(A);
int Error(0);
Error += glm::all(glm::equal(A, E)) ? 0 : 1;
Error += glm::all(glm::equal(B, F)) ? 0 : 1;
Error += glm::all(glm::equal(C, G)) ? 0 : 1;
Error += glm::all(glm::equal(D, H)) ? 0 : 1;
return Error;
}
int test_vec4_cast()
{
glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f);
glm::lowp_vec4 B(A);
glm::mediump_vec4 C(A);
glm::highp_vec4 D(A);
glm::vec4 E = static_cast<glm::vec4>(A);
glm::lowp_vec4 F = static_cast<glm::lowp_vec4>(A);
glm::mediump_vec4 G = static_cast<glm::mediump_vec4>(A);
glm::highp_vec4 H = static_cast<glm::highp_vec4>(A);
int Error(0);
Error += glm::all(glm::equal(A, E)) ? 0 : 1;
Error += glm::all(glm::equal(B, F)) ? 0 : 1;
Error += glm::all(glm::equal(C, G)) ? 0 : 1;
Error += glm::all(glm::equal(D, H)) ? 0 : 1;
return Error;
}
int main()
{
int Error = 0;
Error += test_vec2_cast();
Error += test_vec3_cast();
Error += test_vec4_cast();
return Error;
}