[ADD] template project with correct name
This commit is contained in:
26
lib/glm/test/ext/CMakeLists.txt
Normal file
26
lib/glm/test/ext/CMakeLists.txt
Normal file
@@ -0,0 +1,26 @@
|
||||
glmCreateTestGTC(ext_matrix_relational)
|
||||
glmCreateTestGTC(ext_matrix_transform)
|
||||
glmCreateTestGTC(ext_matrix_common)
|
||||
glmCreateTestGTC(ext_quaternion_common)
|
||||
glmCreateTestGTC(ext_quaternion_exponential)
|
||||
glmCreateTestGTC(ext_quaternion_geometric)
|
||||
glmCreateTestGTC(ext_quaternion_relational)
|
||||
glmCreateTestGTC(ext_quaternion_transform)
|
||||
glmCreateTestGTC(ext_quaternion_trigonometric)
|
||||
glmCreateTestGTC(ext_quaternion_type)
|
||||
glmCreateTestGTC(ext_scalar_common)
|
||||
glmCreateTestGTC(ext_scalar_constants)
|
||||
glmCreateTestGTC(ext_scalar_int_sized)
|
||||
glmCreateTestGTC(ext_scalar_uint_sized)
|
||||
glmCreateTestGTC(ext_scalar_integer)
|
||||
glmCreateTestGTC(ext_scalar_ulp)
|
||||
glmCreateTestGTC(ext_scalar_relational)
|
||||
glmCreateTestGTC(ext_vec1)
|
||||
glmCreateTestGTC(ext_vector_bool1)
|
||||
glmCreateTestGTC(ext_vector_common)
|
||||
glmCreateTestGTC(ext_vector_iec559)
|
||||
glmCreateTestGTC(ext_vector_integer)
|
||||
glmCreateTestGTC(ext_vector_integer_sized)
|
||||
glmCreateTestGTC(ext_vector_relational)
|
||||
glmCreateTestGTC(ext_vector_ulp)
|
||||
|
||||
13
lib/glm/test/ext/ext_matrix_clip_space.cpp
Normal file
13
lib/glm/test/ext/ext_matrix_clip_space.cpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#include <glm/ext/matrix_relational.hpp>
|
||||
#include <glm/ext/matrix_clip_space.hpp>
|
||||
#include <glm/ext/matrix_float4x4.hpp>
|
||||
#include <glm/ext/vector_relational.hpp>
|
||||
#include <glm/ext/vector_float4.hpp>
|
||||
#include <glm/ext/vector_float3.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
return Error;
|
||||
}
|
||||
53
lib/glm/test/ext/ext_matrix_common.cpp
Normal file
53
lib/glm/test/ext/ext_matrix_common.cpp
Normal file
@@ -0,0 +1,53 @@
|
||||
#include <glm/ext/matrix_common.hpp>
|
||||
#include <glm/ext/matrix_double4x4.hpp>
|
||||
#include <glm/ext/matrix_float4x4.hpp>
|
||||
#include <glm/ext/matrix_relational.hpp>
|
||||
#include <glm/ext/vector_bool4.hpp>
|
||||
|
||||
static int test_mix()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
{
|
||||
glm::mat4 A(2);
|
||||
glm::mat4 B(4);
|
||||
glm::mat4 C = glm::mix(A, B, 0.5f);
|
||||
glm::bvec4 const D = glm::equal(C, glm::mat4(3), 1);
|
||||
Error += glm::all(D) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::mat4 A(2);
|
||||
glm::mat4 B(4);
|
||||
glm::mat4 C = glm::mix(A, B, 0.5);
|
||||
glm::bvec4 const D = glm::equal(C, glm::mat4(3), 1);
|
||||
Error += glm::all(D) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::dmat4 A(2);
|
||||
glm::dmat4 B(4);
|
||||
glm::dmat4 C = glm::mix(A, B, 0.5);
|
||||
glm::bvec4 const D = glm::equal(C, glm::dmat4(3), 1);
|
||||
Error += glm::all(D) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::dmat4 A(2);
|
||||
glm::dmat4 B(4);
|
||||
glm::dmat4 C = glm::mix(A, B, 0.5f);
|
||||
glm::bvec4 const D = glm::equal(C, glm::dmat4(3), 1);
|
||||
Error += glm::all(D) ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += test_mix();
|
||||
|
||||
return Error;
|
||||
}
|
||||
13
lib/glm/test/ext/ext_matrix_projection.cpp
Normal file
13
lib/glm/test/ext/ext_matrix_projection.cpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#include <glm/ext/matrix_relational.hpp>
|
||||
#include <glm/ext/matrix_projection.hpp>
|
||||
#include <glm/ext/matrix_float4x4.hpp>
|
||||
#include <glm/ext/vector_relational.hpp>
|
||||
#include <glm/ext/vector_float4.hpp>
|
||||
#include <glm/ext/vector_float3.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
return Error;
|
||||
}
|
||||
163
lib/glm/test/ext/ext_matrix_relational.cpp
Normal file
163
lib/glm/test/ext/ext_matrix_relational.cpp
Normal file
@@ -0,0 +1,163 @@
|
||||
#include <glm/ext/matrix_relational.hpp>
|
||||
#include <glm/ext/matrix_double2x2.hpp>
|
||||
#include <glm/ext/matrix_double2x3.hpp>
|
||||
#include <glm/ext/matrix_double2x4.hpp>
|
||||
#include <glm/ext/matrix_double3x2.hpp>
|
||||
#include <glm/ext/matrix_double3x3.hpp>
|
||||
#include <glm/ext/matrix_double3x4.hpp>
|
||||
#include <glm/ext/matrix_double4x2.hpp>
|
||||
#include <glm/ext/matrix_double4x3.hpp>
|
||||
#include <glm/ext/matrix_double4x4.hpp>
|
||||
#include <glm/ext/vector_double2.hpp>
|
||||
#include <glm/ext/vector_double3.hpp>
|
||||
#include <glm/ext/vector_double4.hpp>
|
||||
#include <glm/ext/matrix_float2x2.hpp>
|
||||
#include <glm/ext/matrix_float2x3.hpp>
|
||||
#include <glm/ext/matrix_float2x4.hpp>
|
||||
#include <glm/ext/matrix_float3x2.hpp>
|
||||
#include <glm/ext/matrix_float3x3.hpp>
|
||||
#include <glm/ext/matrix_float3x4.hpp>
|
||||
#include <glm/ext/matrix_float4x2.hpp>
|
||||
#include <glm/ext/matrix_float4x3.hpp>
|
||||
#include <glm/ext/matrix_float4x4.hpp>
|
||||
#include <glm/ext/vector_float2.hpp>
|
||||
#include <glm/ext/vector_float3.hpp>
|
||||
#include <glm/ext/vector_float4.hpp>
|
||||
#include <glm/ext/scalar_ulp.hpp>
|
||||
|
||||
template <typename matType, typename vecType>
|
||||
static int test_equal()
|
||||
{
|
||||
typedef typename matType::value_type valType;
|
||||
|
||||
valType const Epsilon = static_cast<valType>(0.001f);
|
||||
valType const One = static_cast<valType>(1);
|
||||
valType const Two = static_cast<valType>(2);
|
||||
|
||||
int Error = 0;
|
||||
|
||||
Error += glm::all(glm::equal(matType(One), matType(One), Epsilon)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(matType(One), matType(Two), vecType(Epsilon))) ? 1 : 0;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
template <typename matType, typename vecType>
|
||||
static int test_notEqual()
|
||||
{
|
||||
typedef typename matType::value_type valType;
|
||||
|
||||
valType const Epsilon = static_cast<valType>(0.001f);
|
||||
valType const One = static_cast<valType>(1);
|
||||
valType const Two = static_cast<valType>(2);
|
||||
|
||||
int Error = 0;
|
||||
|
||||
Error += !glm::any(glm::notEqual(matType(One), matType(One), Epsilon)) ? 0 : 1;
|
||||
Error += !glm::any(glm::notEqual(matType(One), matType(Two), vecType(Epsilon))) ? 1 : 0;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
static int test_equal_ulps()
|
||||
{
|
||||
typedef glm::mat<4, 4, T, glm::defaultp> mat4;
|
||||
|
||||
T const One(1);
|
||||
mat4 const Ones(1);
|
||||
|
||||
int Error = 0;
|
||||
|
||||
T const ULP1Plus = glm::nextFloat(One);
|
||||
Error += glm::all(glm::equal(Ones, mat4(ULP1Plus), 1)) ? 0 : 1;
|
||||
|
||||
T const ULP2Plus = glm::nextFloat(ULP1Plus);
|
||||
Error += !glm::all(glm::equal(Ones, mat4(ULP2Plus), 1)) ? 0 : 1;
|
||||
|
||||
T const ULP1Minus = glm::prevFloat(One);
|
||||
Error += glm::all(glm::equal(Ones, mat4(ULP1Minus), 1)) ? 0 : 1;
|
||||
|
||||
T const ULP2Minus = glm::prevFloat(ULP1Minus);
|
||||
Error += !glm::all(glm::equal(Ones, mat4(ULP2Minus), 1)) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static int test_notEqual_ulps()
|
||||
{
|
||||
typedef glm::mat<4, 4, T, glm::defaultp> mat4;
|
||||
|
||||
T const One(1);
|
||||
mat4 const Ones(1);
|
||||
|
||||
int Error = 0;
|
||||
|
||||
T const ULP1Plus = glm::nextFloat(One);
|
||||
Error += !glm::all(glm::notEqual(Ones, mat4(ULP1Plus), 1)) ? 0 : 1;
|
||||
|
||||
T const ULP2Plus = glm::nextFloat(ULP1Plus);
|
||||
Error += glm::all(glm::notEqual(Ones, mat4(ULP2Plus), 1)) ? 0 : 1;
|
||||
|
||||
T const ULP1Minus = glm::prevFloat(One);
|
||||
Error += !glm::all(glm::notEqual(Ones, mat4(ULP1Minus), 1)) ? 0 : 1;
|
||||
|
||||
T const ULP2Minus = glm::prevFloat(ULP1Minus);
|
||||
Error += glm::all(glm::notEqual(Ones, mat4(ULP2Minus), 1)) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += test_equal_ulps<float>();
|
||||
Error += test_equal_ulps<double>();
|
||||
Error += test_notEqual_ulps<float>();
|
||||
Error += test_notEqual_ulps<double>();
|
||||
|
||||
Error += test_equal<glm::mat2x2, glm::vec2>();
|
||||
Error += test_equal<glm::mat2x3, glm::vec2>();
|
||||
Error += test_equal<glm::mat2x4, glm::vec2>();
|
||||
Error += test_equal<glm::mat3x2, glm::vec3>();
|
||||
Error += test_equal<glm::mat3x3, glm::vec3>();
|
||||
Error += test_equal<glm::mat3x4, glm::vec3>();
|
||||
Error += test_equal<glm::mat4x2, glm::vec4>();
|
||||
Error += test_equal<glm::mat4x3, glm::vec4>();
|
||||
Error += test_equal<glm::mat4x4, glm::vec4>();
|
||||
|
||||
Error += test_equal<glm::dmat2x2, glm::dvec2>();
|
||||
Error += test_equal<glm::dmat2x3, glm::dvec2>();
|
||||
Error += test_equal<glm::dmat2x4, glm::dvec2>();
|
||||
Error += test_equal<glm::dmat3x2, glm::dvec3>();
|
||||
Error += test_equal<glm::dmat3x3, glm::dvec3>();
|
||||
Error += test_equal<glm::dmat3x4, glm::dvec3>();
|
||||
Error += test_equal<glm::dmat4x2, glm::dvec4>();
|
||||
Error += test_equal<glm::dmat4x3, glm::dvec4>();
|
||||
Error += test_equal<glm::dmat4x4, glm::dvec4>();
|
||||
|
||||
Error += test_notEqual<glm::mat2x2, glm::vec2>();
|
||||
Error += test_notEqual<glm::mat2x3, glm::vec2>();
|
||||
Error += test_notEqual<glm::mat2x4, glm::vec2>();
|
||||
Error += test_notEqual<glm::mat3x2, glm::vec3>();
|
||||
Error += test_notEqual<glm::mat3x3, glm::vec3>();
|
||||
Error += test_notEqual<glm::mat3x4, glm::vec3>();
|
||||
Error += test_notEqual<glm::mat4x2, glm::vec4>();
|
||||
Error += test_notEqual<glm::mat4x3, glm::vec4>();
|
||||
Error += test_notEqual<glm::mat4x4, glm::vec4>();
|
||||
|
||||
Error += test_notEqual<glm::dmat2x2, glm::dvec2>();
|
||||
Error += test_notEqual<glm::dmat2x3, glm::dvec2>();
|
||||
Error += test_notEqual<glm::dmat2x4, glm::dvec2>();
|
||||
Error += test_notEqual<glm::dmat3x2, glm::dvec3>();
|
||||
Error += test_notEqual<glm::dmat3x3, glm::dvec3>();
|
||||
Error += test_notEqual<glm::dmat3x4, glm::dvec3>();
|
||||
Error += test_notEqual<glm::dmat4x2, glm::dvec4>();
|
||||
Error += test_notEqual<glm::dmat4x3, glm::dvec4>();
|
||||
Error += test_notEqual<glm::dmat4x4, glm::dvec4>();
|
||||
|
||||
return Error;
|
||||
}
|
||||
61
lib/glm/test/ext/ext_matrix_transform.cpp
Normal file
61
lib/glm/test/ext/ext_matrix_transform.cpp
Normal file
@@ -0,0 +1,61 @@
|
||||
#include <glm/ext/matrix_relational.hpp>
|
||||
#include <glm/ext/matrix_transform.hpp>
|
||||
#include <glm/ext/matrix_float4x4.hpp>
|
||||
#include <glm/ext/vector_relational.hpp>
|
||||
#include <glm/ext/vector_float4.hpp>
|
||||
#include <glm/ext/vector_float3.hpp>
|
||||
|
||||
static int test_translate()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
glm::mat4 const M(1.0f);
|
||||
glm::vec3 const V(1.0f);
|
||||
|
||||
glm::mat4 const T = glm::translate(M, V);
|
||||
Error += glm::all(glm::equal(T[3], glm::vec4(1.0f), glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_scale()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
glm::mat4 const M(1.0f);
|
||||
glm::vec3 const V(2.0f);
|
||||
|
||||
glm::mat4 const S = glm::scale(M, V);
|
||||
glm::mat4 const R = glm::mat4(
|
||||
glm::vec4(2, 0, 0, 0),
|
||||
glm::vec4(0, 2, 0, 0),
|
||||
glm::vec4(0, 0, 2, 0),
|
||||
glm::vec4(0, 0, 0, 1));
|
||||
Error += glm::all(glm::equal(S, R, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_rotate()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
glm::vec4 const A(1.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
glm::mat4 const R = glm::rotate(glm::mat4(1.0f), glm::radians(90.f), glm::vec3(0, 0, 1));
|
||||
glm::vec4 const B = R * A;
|
||||
Error += glm::all(glm::equal(B, glm::vec4(0.0f, 1.0f, 0.0f, 1.0f), 0.0001f)) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += test_translate();
|
||||
Error += test_scale();
|
||||
Error += test_rotate();
|
||||
|
||||
return Error;
|
||||
}
|
||||
61
lib/glm/test/ext/ext_quaternion_common.cpp
Normal file
61
lib/glm/test/ext/ext_quaternion_common.cpp
Normal file
@@ -0,0 +1,61 @@
|
||||
#include <glm/ext/vector_float3.hpp>
|
||||
#include <glm/ext/quaternion_common.hpp>
|
||||
#include <glm/ext/quaternion_float.hpp>
|
||||
#include <glm/ext/quaternion_relational.hpp>
|
||||
#include <glm/ext/quaternion_trigonometric.hpp>
|
||||
#include <glm/ext/scalar_constants.hpp>
|
||||
#include <glm/ext/scalar_relational.hpp>
|
||||
|
||||
static int test_conjugate()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
glm::quat const A(glm::vec3(1, 0, 0), glm::vec3(0, 1, 0));
|
||||
glm::quat const C = glm::conjugate(A);
|
||||
Error += glm::any(glm::notEqual(A, C, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
glm::quat const B = glm::conjugate(C);
|
||||
Error += glm::all(glm::equal(A, B, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_mix()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
glm::quat const Q1(glm::vec3(1, 0, 0), glm::vec3(1, 0, 0));
|
||||
glm::quat const Q2(glm::vec3(1, 0, 0), glm::vec3(0, 1, 0));
|
||||
|
||||
{
|
||||
glm::quat const Q3 = glm::mix(Q1, Q2, 0.5f);
|
||||
float const F3 = glm::degrees(glm::angle(Q3));
|
||||
Error += glm::equal(F3, 45.0f, 0.001f) ? 0 : 1;
|
||||
|
||||
glm::quat const Q4 = glm::mix(Q2, Q1, 0.5f);
|
||||
float const F4 = glm::degrees(glm::angle(Q4));
|
||||
Error += glm::equal(F4, 45.0f, 0.001f) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::quat const Q3 = glm::slerp(Q1, Q2, 0.5f);
|
||||
float const F3 = glm::degrees(glm::angle(Q3));
|
||||
Error += glm::equal(F3, 45.0f, 0.001f) ? 0 : 1;
|
||||
|
||||
glm::quat const Q4 = glm::slerp(Q2, Q1, 0.5f);
|
||||
float const F4 = glm::degrees(glm::angle(Q4));
|
||||
Error += glm::equal(F4, 45.0f, 0.001f) ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += test_conjugate();
|
||||
Error += test_mix();
|
||||
|
||||
return Error;
|
||||
}
|
||||
87
lib/glm/test/ext/ext_quaternion_exponential.cpp
Normal file
87
lib/glm/test/ext/ext_quaternion_exponential.cpp
Normal file
@@ -0,0 +1,87 @@
|
||||
#include <glm/ext/quaternion_exponential.hpp>
|
||||
#include <glm/ext/quaternion_float.hpp>
|
||||
#include <glm/ext/quaternion_float_precision.hpp>
|
||||
#include <glm/ext/quaternion_double.hpp>
|
||||
#include <glm/ext/quaternion_double_precision.hpp>
|
||||
#include <glm/ext/quaternion_relational.hpp>
|
||||
#include <glm/ext/vector_float3.hpp>
|
||||
#include <glm/ext/vector_float3_precision.hpp>
|
||||
#include <glm/ext/vector_double3.hpp>
|
||||
#include <glm/ext/vector_double3_precision.hpp>
|
||||
#include <glm/ext/scalar_constants.hpp>
|
||||
|
||||
template <typename quaType, typename vecType>
|
||||
int test_log()
|
||||
{
|
||||
typedef typename quaType::value_type T;
|
||||
|
||||
T const Epsilon = static_cast<T>(0.001f);
|
||||
|
||||
int Error = 0;
|
||||
|
||||
quaType const Q(vecType(1, 0, 0), vecType(0, 1, 0));
|
||||
quaType const P = glm::log(Q);
|
||||
Error += glm::any(glm::notEqual(Q, P, Epsilon)) ? 0 : 1;
|
||||
|
||||
quaType const R = glm::exp(P);
|
||||
Error += glm::all(glm::equal(Q, R, Epsilon)) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
template <typename quaType, typename vecType>
|
||||
int test_pow()
|
||||
{
|
||||
typedef typename quaType::value_type T;
|
||||
|
||||
T const Epsilon = static_cast<T>(0.001f);
|
||||
|
||||
int Error = 0;
|
||||
|
||||
quaType const Q(vecType(1, 0, 0), vecType(0, 1, 0));
|
||||
|
||||
{
|
||||
T const One = static_cast<T>(1.0f);
|
||||
quaType const P = glm::pow(Q, One);
|
||||
Error += glm::all(glm::equal(Q, P, Epsilon)) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
T const Two = static_cast<T>(2.0f);
|
||||
quaType const P = glm::pow(Q, Two);
|
||||
quaType const R = Q * Q;
|
||||
Error += glm::all(glm::equal(P, R, Epsilon)) ? 0 : 1;
|
||||
|
||||
quaType const U = glm::sqrt(P);
|
||||
Error += glm::all(glm::equal(Q, U, Epsilon)) ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += test_log<glm::quat, glm::vec3>();
|
||||
Error += test_log<glm::lowp_quat, glm::lowp_vec3>();
|
||||
Error += test_log<glm::mediump_quat, glm::mediump_vec3>();
|
||||
Error += test_log<glm::highp_quat, glm::highp_vec3>();
|
||||
|
||||
Error += test_log<glm::dquat, glm::dvec3>();
|
||||
Error += test_log<glm::lowp_dquat, glm::lowp_dvec3>();
|
||||
Error += test_log<glm::mediump_dquat, glm::mediump_dvec3>();
|
||||
Error += test_log<glm::highp_dquat, glm::highp_dvec3>();
|
||||
|
||||
Error += test_pow<glm::quat, glm::vec3>();
|
||||
Error += test_pow<glm::lowp_quat, glm::lowp_vec3>();
|
||||
Error += test_pow<glm::mediump_quat, glm::mediump_vec3>();
|
||||
Error += test_pow<glm::highp_quat, glm::highp_vec3>();
|
||||
|
||||
Error += test_pow<glm::dquat, glm::dvec3>();
|
||||
Error += test_pow<glm::lowp_dquat, glm::lowp_dvec3>();
|
||||
Error += test_pow<glm::mediump_dquat, glm::mediump_dvec3>();
|
||||
Error += test_pow<glm::highp_dquat, glm::highp_dvec3>();
|
||||
|
||||
return Error;
|
||||
}
|
||||
88
lib/glm/test/ext/ext_quaternion_geometric.cpp
Normal file
88
lib/glm/test/ext/ext_quaternion_geometric.cpp
Normal file
@@ -0,0 +1,88 @@
|
||||
#include <glm/gtc/constants.hpp>
|
||||
#include <glm/ext/quaternion_geometric.hpp>
|
||||
#include <glm/ext/quaternion_float.hpp>
|
||||
#include <glm/ext/quaternion_trigonometric.hpp>
|
||||
#include <glm/ext/quaternion_float_precision.hpp>
|
||||
#include <glm/ext/quaternion_double.hpp>
|
||||
#include <glm/ext/quaternion_double_precision.hpp>
|
||||
#include <glm/ext/vector_float3.hpp>
|
||||
#include <glm/ext/vector_float3_precision.hpp>
|
||||
#include <glm/ext/vector_double3.hpp>
|
||||
#include <glm/ext/vector_double3_precision.hpp>
|
||||
#include <glm/ext/scalar_relational.hpp>
|
||||
|
||||
float const Epsilon = 0.001f;
|
||||
|
||||
static int test_length()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
{
|
||||
float const A = glm::length(glm::quat(1, 0, 0, 0));
|
||||
Error += glm::equal(A, 1.0f, Epsilon) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
float const A = glm::length(glm::quat(1, glm::vec3(0)));
|
||||
Error += glm::equal(A, 1.0f, Epsilon) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
float const A = glm::length(glm::quat(glm::vec3(1, 0, 0), glm::vec3(0, 1, 0)));
|
||||
Error += glm::equal(A, 1.0f, Epsilon) ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_normalize()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
{
|
||||
glm::quat const A = glm::quat(1, 0, 0, 0);
|
||||
glm::quat const N = glm::normalize(A);
|
||||
Error += glm::all(glm::equal(A, N, Epsilon)) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::quat const A = glm::quat(1, glm::vec3(0));
|
||||
glm::quat const N = glm::normalize(A);
|
||||
Error += glm::all(glm::equal(A, N, Epsilon)) ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_dot()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
{
|
||||
glm::quat const A = glm::quat(1, 0, 0, 0);
|
||||
glm::quat const B = glm::quat(1, 0, 0, 0);
|
||||
float const C = glm::dot(A, B);
|
||||
Error += glm::equal(C, 1.0f, Epsilon) ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_cross()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += test_length();
|
||||
Error += test_normalize();
|
||||
Error += test_dot();
|
||||
Error += test_cross();
|
||||
|
||||
return Error;
|
||||
}
|
||||
51
lib/glm/test/ext/ext_quaternion_relational.cpp
Normal file
51
lib/glm/test/ext/ext_quaternion_relational.cpp
Normal file
@@ -0,0 +1,51 @@
|
||||
#include <glm/gtc/constants.hpp>
|
||||
#include <glm/ext/quaternion_relational.hpp>
|
||||
#include <glm/ext/quaternion_float.hpp>
|
||||
#include <glm/ext/quaternion_float_precision.hpp>
|
||||
#include <glm/ext/quaternion_double.hpp>
|
||||
#include <glm/ext/quaternion_double_precision.hpp>
|
||||
#include <glm/ext/vector_float3.hpp>
|
||||
#include <glm/ext/vector_float3_precision.hpp>
|
||||
#include <glm/ext/vector_double3.hpp>
|
||||
#include <glm/ext/vector_double3_precision.hpp>
|
||||
|
||||
template <typename quaType>
|
||||
static int test_equal()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
quaType const Q(1, 0, 0, 0);
|
||||
quaType const P(1, 0, 0, 0);
|
||||
Error += glm::all(glm::equal(Q, P, glm::epsilon<float>())) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
template <typename quaType>
|
||||
static int test_notEqual()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
quaType const Q(1, 0, 0, 0);
|
||||
quaType const P(1, 0, 0, 0);
|
||||
Error += glm::any(glm::notEqual(Q, P, glm::epsilon<float>())) ? 1 : 0;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += test_equal<glm::quat>();
|
||||
Error += test_equal<glm::lowp_quat>();
|
||||
Error += test_equal<glm::mediump_quat>();
|
||||
Error += test_equal<glm::highp_quat>();
|
||||
|
||||
Error += test_notEqual<glm::quat>();
|
||||
Error += test_notEqual<glm::lowp_quat>();
|
||||
Error += test_notEqual<glm::mediump_quat>();
|
||||
Error += test_notEqual<glm::highp_quat>();
|
||||
|
||||
return Error;
|
||||
}
|
||||
45
lib/glm/test/ext/ext_quaternion_transform.cpp
Normal file
45
lib/glm/test/ext/ext_quaternion_transform.cpp
Normal file
@@ -0,0 +1,45 @@
|
||||
#include <glm/ext/quaternion_transform.hpp>
|
||||
#include <glm/ext/quaternion_float.hpp>
|
||||
#include <glm/ext/vector_relational.hpp>
|
||||
#include <glm/ext/scalar_constants.hpp>
|
||||
|
||||
#define GLM_ENABLE_EXPERIMENTAL
|
||||
#include <glm/gtx/quaternion.hpp>
|
||||
|
||||
static int test_lookAt()
|
||||
{
|
||||
int Error(0);
|
||||
|
||||
glm::vec3 eye(0.0f);
|
||||
glm::vec3 center(1.1f, -2.0f, 3.1416f);
|
||||
glm::vec3 up(-0.17f, 7.23f, -1.744f);
|
||||
|
||||
glm::quat test_quat = glm::quatLookAt(glm::normalize(center - eye), up);
|
||||
glm::quat test_mat = glm::conjugate(glm::quat_cast(glm::lookAt(eye, center, up)));
|
||||
|
||||
Error += static_cast<int>(glm::abs(glm::length(test_quat) - 1.0f) > glm::epsilon<float>());
|
||||
Error += static_cast<int>(glm::min(glm::length(test_quat + (-test_mat)), glm::length(test_quat + test_mat)) > glm::epsilon<float>());
|
||||
|
||||
// Test left-handed implementation
|
||||
glm::quat test_quatLH = glm::quatLookAtLH(glm::normalize(center - eye), up);
|
||||
glm::quat test_matLH = glm::conjugate(glm::quat_cast(glm::lookAtLH(eye, center, up)));
|
||||
Error += static_cast<int>(glm::abs(glm::length(test_quatLH) - 1.0f) > glm::epsilon<float>());
|
||||
Error += static_cast<int>(glm::min(glm::length(test_quatLH - test_matLH), glm::length(test_quatLH + test_matLH)) > glm::epsilon<float>());
|
||||
|
||||
// Test right-handed implementation
|
||||
glm::quat test_quatRH = glm::quatLookAtRH(glm::normalize(center - eye), up);
|
||||
glm::quat test_matRH = glm::conjugate(glm::quat_cast(glm::lookAtRH(eye, center, up)));
|
||||
Error += static_cast<int>(glm::abs(glm::length(test_quatRH) - 1.0f) > glm::epsilon<float>());
|
||||
Error += static_cast<int>(glm::min(glm::length(test_quatRH - test_matRH), glm::length(test_quatRH + test_matRH)) > glm::epsilon<float>());
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += test_lookAt();
|
||||
|
||||
return Error;
|
||||
}
|
||||
34
lib/glm/test/ext/ext_quaternion_trigonometric.cpp
Normal file
34
lib/glm/test/ext/ext_quaternion_trigonometric.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
#include <glm/ext/quaternion_trigonometric.hpp>
|
||||
#include <glm/ext/quaternion_float.hpp>
|
||||
#include <glm/ext/vector_relational.hpp>
|
||||
#include <glm/ext/scalar_relational.hpp>
|
||||
|
||||
float const Epsilon = 0.001f;
|
||||
|
||||
static int test_angle()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
{
|
||||
glm::quat const Q = glm::quat(glm::vec3(1, 0, 0), glm::vec3(0, 1, 0));
|
||||
float const A = glm::degrees(glm::angle(Q));
|
||||
Error += glm::equal(A, 90.0f, Epsilon) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
glm::quat const Q = glm::quat(glm::vec3(0, 1, 0), glm::vec3(1, 0, 0));
|
||||
float const A = glm::degrees(glm::angle(Q));
|
||||
Error += glm::equal(A, 90.0f, Epsilon) ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += test_angle();
|
||||
|
||||
return Error;
|
||||
}
|
||||
113
lib/glm/test/ext/ext_quaternion_type.cpp
Normal file
113
lib/glm/test/ext/ext_quaternion_type.cpp
Normal file
@@ -0,0 +1,113 @@
|
||||
#include <glm/gtc/constants.hpp>
|
||||
#include <glm/ext/quaternion_relational.hpp>
|
||||
#include <glm/ext/quaternion_float.hpp>
|
||||
#include <glm/ext/quaternion_float_precision.hpp>
|
||||
#include <glm/ext/quaternion_double.hpp>
|
||||
#include <glm/ext/quaternion_double_precision.hpp>
|
||||
#include <glm/ext/vector_float3.hpp>
|
||||
#include <vector>
|
||||
|
||||
static int test_ctr()
|
||||
{
|
||||
int Error(0);
|
||||
|
||||
# if GLM_HAS_TRIVIAL_QUERIES
|
||||
// Error += std::is_trivially_default_constructible<glm::quat>::value ? 0 : 1;
|
||||
// Error += std::is_trivially_default_constructible<glm::dquat>::value ? 0 : 1;
|
||||
// Error += std::is_trivially_copy_assignable<glm::quat>::value ? 0 : 1;
|
||||
// Error += std::is_trivially_copy_assignable<glm::dquat>::value ? 0 : 1;
|
||||
Error += std::is_trivially_copyable<glm::quat>::value ? 0 : 1;
|
||||
Error += std::is_trivially_copyable<glm::dquat>::value ? 0 : 1;
|
||||
|
||||
Error += std::is_copy_constructible<glm::quat>::value ? 0 : 1;
|
||||
Error += std::is_copy_constructible<glm::dquat>::value ? 0 : 1;
|
||||
# endif
|
||||
|
||||
# if GLM_HAS_INITIALIZER_LISTS
|
||||
{
|
||||
glm::quat A{0, 1, 2, 3};
|
||||
|
||||
std::vector<glm::quat> B{
|
||||
{0, 1, 2, 3},
|
||||
{0, 1, 2, 3}};
|
||||
}
|
||||
# endif//GLM_HAS_INITIALIZER_LISTS
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_two_axis_ctr()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
glm::quat const q1(glm::vec3(1, 0, 0), glm::vec3(0, 1, 0));
|
||||
glm::vec3 const v1 = q1 * glm::vec3(1, 0, 0);
|
||||
Error += glm::all(glm::equal(v1, glm::vec3(0, 1, 0), 0.0001f)) ? 0 : 1;
|
||||
|
||||
glm::quat const q2 = q1 * q1;
|
||||
glm::vec3 const v2 = q2 * glm::vec3(1, 0, 0);
|
||||
Error += glm::all(glm::equal(v2, glm::vec3(-1, 0, 0), 0.0001f)) ? 0 : 1;
|
||||
|
||||
glm::quat const q3(glm::vec3(1, 0, 0), glm::vec3(-1, 0, 0));
|
||||
glm::vec3 const v3 = q3 * glm::vec3(1, 0, 0);
|
||||
Error += glm::all(glm::equal(v3, glm::vec3(-1, 0, 0), 0.0001f)) ? 0 : 1;
|
||||
|
||||
glm::quat const q4(glm::vec3(0, 1, 0), glm::vec3(0, -1, 0));
|
||||
glm::vec3 const v4 = q4 * glm::vec3(0, 1, 0);
|
||||
Error += glm::all(glm::equal(v4, glm::vec3(0, -1, 0), 0.0001f)) ? 0 : 1;
|
||||
|
||||
glm::quat const q5(glm::vec3(0, 0, 1), glm::vec3(0, 0, -1));
|
||||
glm::vec3 const v5 = q5 * glm::vec3(0, 0, 1);
|
||||
Error += glm::all(glm::equal(v5, glm::vec3(0, 0, -1), 0.0001f)) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_size()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
std::size_t const A = sizeof(glm::quat);
|
||||
Error += 16 == A ? 0 : 1;
|
||||
std::size_t const B = sizeof(glm::dquat);
|
||||
Error += 32 == B ? 0 : 1;
|
||||
Error += glm::quat().length() == 4 ? 0 : 1;
|
||||
Error += glm::dquat().length() == 4 ? 0 : 1;
|
||||
Error += glm::quat::length() == 4 ? 0 : 1;
|
||||
Error += glm::dquat::length() == 4 ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_precision()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += sizeof(glm::lowp_quat) <= sizeof(glm::mediump_quat) ? 0 : 1;
|
||||
Error += sizeof(glm::mediump_quat) <= sizeof(glm::highp_quat) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_constexpr()
|
||||
{
|
||||
#if GLM_HAS_CONSTEXPR
|
||||
static_assert(glm::quat::length() == 4, "GLM: Failed constexpr");
|
||||
static_assert(glm::quat(1.0f, glm::vec3(0.0f)).w > 0.0f, "GLM: Failed constexpr");
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += test_ctr();
|
||||
Error += test_two_axis_ctr();
|
||||
Error += test_size();
|
||||
Error += test_precision();
|
||||
Error += test_constexpr();
|
||||
|
||||
return Error;
|
||||
}
|
||||
207
lib/glm/test/ext/ext_scalar_common.cpp
Normal file
207
lib/glm/test/ext/ext_scalar_common.cpp
Normal file
@@ -0,0 +1,207 @@
|
||||
#include <glm/ext/scalar_common.hpp>
|
||||
#include <glm/ext/scalar_constants.hpp>
|
||||
#include <glm/ext/scalar_relational.hpp>
|
||||
#include <glm/common.hpp>
|
||||
|
||||
#if ((GLM_LANG & GLM_LANG_CXX11_FLAG) || (GLM_COMPILER & GLM_COMPILER_VC))
|
||||
# define GLM_NAN(T) NAN
|
||||
#else
|
||||
# define GLM_NAN(T) (static_cast<T>(0.0f) / static_cast<T>(0.0f))
|
||||
#endif
|
||||
|
||||
template <typename T>
|
||||
static int test_min()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
T const N = static_cast<T>(0);
|
||||
T const B = static_cast<T>(1);
|
||||
Error += glm::equal(glm::min(N, B), N, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::min(B, N), N, glm::epsilon<T>()) ? 0 : 1;
|
||||
|
||||
T const C = static_cast<T>(2);
|
||||
Error += glm::equal(glm::min(N, B, C), N, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::min(B, N, C), N, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::min(C, N, B), N, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::min(C, B, N), N, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::min(B, C, N), N, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::min(N, C, B), N, glm::epsilon<T>()) ? 0 : 1;
|
||||
|
||||
T const D = static_cast<T>(3);
|
||||
Error += glm::equal(glm::min(D, N, B, C), N, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::min(B, D, N, C), N, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::min(C, N, D, B), N, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::min(C, B, D, N), N, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::min(B, C, N, D), N, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::min(N, C, B, D), N, glm::epsilon<T>()) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static int test_min_nan()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
T const B = static_cast<T>(1);
|
||||
T const N = static_cast<T>(GLM_NAN(T));
|
||||
Error += glm::isnan(glm::min(N, B)) ? 0 : 1;
|
||||
Error += !glm::isnan(glm::min(B, N)) ? 0 : 1;
|
||||
|
||||
T const C = static_cast<T>(2);
|
||||
Error += glm::isnan(glm::min(N, B, C)) ? 0 : 1;
|
||||
Error += !glm::isnan(glm::min(B, N, C)) ? 0 : 1;
|
||||
Error += !glm::isnan(glm::min(C, N, B)) ? 0 : 1;
|
||||
Error += !glm::isnan(glm::min(C, B, N)) ? 0 : 1;
|
||||
Error += !glm::isnan(glm::min(B, C, N)) ? 0 : 1;
|
||||
Error += glm::isnan(glm::min(N, C, B)) ? 0 : 1;
|
||||
|
||||
T const D = static_cast<T>(3);
|
||||
Error += !glm::isnan(glm::min(D, N, B, C)) ? 0 : 1;
|
||||
Error += !glm::isnan(glm::min(B, D, N, C)) ? 0 : 1;
|
||||
Error += !glm::isnan(glm::min(C, N, D, B)) ? 0 : 1;
|
||||
Error += !glm::isnan(glm::min(C, B, D, N)) ? 0 : 1;
|
||||
Error += !glm::isnan(glm::min(B, C, N, D)) ? 0 : 1;
|
||||
Error += glm::isnan(glm::min(N, C, B, D)) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static int test_max()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
T const N = static_cast<T>(0);
|
||||
T const B = static_cast<T>(1);
|
||||
Error += glm::equal(glm::max(N, B), B, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::max(B, N), B, glm::epsilon<T>()) ? 0 : 1;
|
||||
|
||||
T const C = static_cast<T>(2);
|
||||
Error += glm::equal(glm::max(N, B, C), C, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::max(B, N, C), C, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::max(C, N, B), C, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::max(C, B, N), C, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::max(B, C, N), C, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::max(N, C, B), C, glm::epsilon<T>()) ? 0 : 1;
|
||||
|
||||
T const D = static_cast<T>(3);
|
||||
Error += glm::equal(glm::max(D, N, B, C), D, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::max(B, D, N, C), D, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::max(C, N, D, B), D, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::max(C, B, D, N), D, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::max(B, C, N, D), D, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::max(N, C, B, D), D, glm::epsilon<T>()) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static int test_max_nan()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
T const B = static_cast<T>(1);
|
||||
T const N = static_cast<T>(GLM_NAN(T));
|
||||
Error += glm::isnan(glm::max(N, B)) ? 0 : 1;
|
||||
Error += !glm::isnan(glm::max(B, N)) ? 0 : 1;
|
||||
|
||||
T const C = static_cast<T>(2);
|
||||
Error += glm::isnan(glm::max(N, B, C)) ? 0 : 1;
|
||||
Error += !glm::isnan(glm::max(B, N, C)) ? 0 : 1;
|
||||
Error += !glm::isnan(glm::max(C, N, B)) ? 0 : 1;
|
||||
Error += !glm::isnan(glm::max(C, B, N)) ? 0 : 1;
|
||||
Error += !glm::isnan(glm::max(B, C, N)) ? 0 : 1;
|
||||
Error += glm::isnan(glm::max(N, C, B)) ? 0 : 1;
|
||||
|
||||
T const D = static_cast<T>(3);
|
||||
Error += !glm::isnan(glm::max(D, N, B, C)) ? 0 : 1;
|
||||
Error += !glm::isnan(glm::max(B, D, N, C)) ? 0 : 1;
|
||||
Error += !glm::isnan(glm::max(C, N, D, B)) ? 0 : 1;
|
||||
Error += !glm::isnan(glm::max(C, B, D, N)) ? 0 : 1;
|
||||
Error += !glm::isnan(glm::max(B, C, N, D)) ? 0 : 1;
|
||||
Error += glm::isnan(glm::max(N, C, B, D)) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static int test_fmin()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
T const B = static_cast<T>(1);
|
||||
T const N = static_cast<T>(GLM_NAN(T));
|
||||
Error += glm::equal(glm::fmin(N, B), B, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::fmin(B, N), B, glm::epsilon<T>()) ? 0 : 1;
|
||||
|
||||
T const C = static_cast<T>(2);
|
||||
Error += glm::equal(glm::fmin(N, B, C), B, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::fmin(B, N, C), B, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::fmin(C, N, B), B, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::fmin(C, B, N), B, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::fmin(B, C, N), B, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::fmin(N, C, B), B, glm::epsilon<T>()) ? 0 : 1;
|
||||
|
||||
T const D = static_cast<T>(3);
|
||||
Error += glm::equal(glm::fmin(D, N, B, C), B, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::fmin(B, D, N, C), B, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::fmin(C, N, D, B), B, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::fmin(C, B, D, N), B, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::fmin(B, C, N, D), B, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::fmin(N, C, B, D), B, glm::epsilon<T>()) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static int test_fmax()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
T const B = static_cast<T>(1);
|
||||
T const N = static_cast<T>(GLM_NAN(T));
|
||||
Error += glm::equal(glm::fmax(N, B), B, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::fmax(B, N), B, glm::epsilon<T>()) ? 0 : 1;
|
||||
|
||||
T const C = static_cast<T>(2);
|
||||
Error += glm::equal(glm::fmax(N, B, C), C, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::fmax(B, N, C), C, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::fmax(C, N, B), C, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::fmax(C, B, N), C, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::fmax(B, C, N), C, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::fmax(N, C, B), C, glm::epsilon<T>()) ? 0 : 1;
|
||||
|
||||
T const D = static_cast<T>(3);
|
||||
Error += glm::equal(glm::fmax(D, N, B, C), D, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::fmax(B, D, N, C), D, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::fmax(C, N, D, B), D, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::fmax(C, B, D, N), D, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::fmax(B, C, N, D), D, glm::epsilon<T>()) ? 0 : 1;
|
||||
Error += glm::equal(glm::fmax(N, C, B, D), D, glm::epsilon<T>()) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += test_min<float>();
|
||||
Error += test_min<double>();
|
||||
Error += test_min_nan<float>();
|
||||
Error += test_min_nan<double>();
|
||||
|
||||
Error += test_max<float>();
|
||||
Error += test_max<double>();
|
||||
Error += test_max_nan<float>();
|
||||
Error += test_max_nan<double>();
|
||||
|
||||
Error += test_fmin<float>();
|
||||
Error += test_fmin<double>();
|
||||
|
||||
Error += test_fmax<float>();
|
||||
Error += test_fmax<double>();
|
||||
|
||||
return Error;
|
||||
}
|
||||
36
lib/glm/test/ext/ext_scalar_constants.cpp
Normal file
36
lib/glm/test/ext/ext_scalar_constants.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
#include <glm/ext/scalar_constants.hpp>
|
||||
|
||||
template <typename valType>
|
||||
static int test_epsilon()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
valType const Test = glm::epsilon<valType>();
|
||||
Error += Test > static_cast<valType>(0) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
static int test_pi()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
valType const Test = glm::pi<valType>();
|
||||
Error += Test > static_cast<valType>(3.14) ? 0 : 1;
|
||||
Error += Test < static_cast<valType>(3.15) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += test_epsilon<float>();
|
||||
Error += test_epsilon<double>();
|
||||
Error += test_pi<float>();
|
||||
Error += test_pi<double>();
|
||||
|
||||
return Error;
|
||||
}
|
||||
43
lib/glm/test/ext/ext_scalar_int_sized.cpp
Normal file
43
lib/glm/test/ext/ext_scalar_int_sized.cpp
Normal file
@@ -0,0 +1,43 @@
|
||||
#include <glm/ext/scalar_int_sized.hpp>
|
||||
|
||||
#if GLM_HAS_STATIC_ASSERT
|
||||
static_assert(sizeof(glm::int8) == 1, "int8 size isn't 1 byte on this platform");
|
||||
static_assert(sizeof(glm::int16) == 2, "int16 size isn't 2 bytes on this platform");
|
||||
static_assert(sizeof(glm::int32) == 4, "int32 size isn't 4 bytes on this platform");
|
||||
static_assert(sizeof(glm::int64) == 8, "int64 size isn't 8 bytes on this platform");
|
||||
static_assert(sizeof(glm::int16) == sizeof(short), "signed short size isn't 4 bytes on this platform");
|
||||
static_assert(sizeof(glm::int32) == sizeof(int), "signed int size isn't 4 bytes on this platform");
|
||||
#endif
|
||||
|
||||
static int test_size()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += sizeof(glm::int8) == 1 ? 0 : 1;
|
||||
Error += sizeof(glm::int16) == 2 ? 0 : 1;
|
||||
Error += sizeof(glm::int32) == 4 ? 0 : 1;
|
||||
Error += sizeof(glm::int64) == 8 ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_comp()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += sizeof(glm::int8) < sizeof(glm::int16) ? 0 : 1;
|
||||
Error += sizeof(glm::int16) < sizeof(glm::int32) ? 0 : 1;
|
||||
Error += sizeof(glm::int32) < sizeof(glm::int64) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += test_size();
|
||||
Error += test_comp();
|
||||
|
||||
return Error;
|
||||
}
|
||||
686
lib/glm/test/ext/ext_scalar_integer.cpp
Normal file
686
lib/glm/test/ext/ext_scalar_integer.cpp
Normal file
@@ -0,0 +1,686 @@
|
||||
#include <glm/ext/scalar_integer.hpp>
|
||||
#include <glm/ext/scalar_int_sized.hpp>
|
||||
#include <glm/ext/scalar_uint_sized.hpp>
|
||||
#include <vector>
|
||||
#include <ctime>
|
||||
#include <cstdio>
|
||||
|
||||
#if GLM_LANG & GLM_LANG_CXX11_FLAG
|
||||
#include <chrono>
|
||||
|
||||
namespace isPowerOfTwo
|
||||
{
|
||||
template<typename genType>
|
||||
struct type
|
||||
{
|
||||
genType Value;
|
||||
bool Return;
|
||||
};
|
||||
|
||||
int test_int16()
|
||||
{
|
||||
type<glm::int16> const Data[] =
|
||||
{
|
||||
{0x0001, true},
|
||||
{0x0002, true},
|
||||
{0x0004, true},
|
||||
{0x0080, true},
|
||||
{0x0000, true},
|
||||
{0x0003, false}
|
||||
};
|
||||
|
||||
int Error = 0;
|
||||
|
||||
for(std::size_t i = 0, n = sizeof(Data) / sizeof(type<glm::int16>); i < n; ++i)
|
||||
{
|
||||
bool Result = glm::isPowerOfTwo(Data[i].Value);
|
||||
Error += Data[i].Return == Result ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_uint16()
|
||||
{
|
||||
type<glm::uint16> const Data[] =
|
||||
{
|
||||
{0x0001, true},
|
||||
{0x0002, true},
|
||||
{0x0004, true},
|
||||
{0x0000, true},
|
||||
{0x0000, true},
|
||||
{0x0003, false}
|
||||
};
|
||||
|
||||
int Error = 0;
|
||||
|
||||
for(std::size_t i = 0, n = sizeof(Data) / sizeof(type<glm::uint16>); i < n; ++i)
|
||||
{
|
||||
bool Result = glm::isPowerOfTwo(Data[i].Value);
|
||||
Error += Data[i].Return == Result ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_int32()
|
||||
{
|
||||
type<int> const Data[] =
|
||||
{
|
||||
{0x00000001, true},
|
||||
{0x00000002, true},
|
||||
{0x00000004, true},
|
||||
{0x0000000f, false},
|
||||
{0x00000000, true},
|
||||
{0x00000003, false}
|
||||
};
|
||||
|
||||
int Error = 0;
|
||||
|
||||
for(std::size_t i = 0, n = sizeof(Data) / sizeof(type<int>); i < n; ++i)
|
||||
{
|
||||
bool Result = glm::isPowerOfTwo(Data[i].Value);
|
||||
Error += Data[i].Return == Result ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_uint32()
|
||||
{
|
||||
type<glm::uint> const Data[] =
|
||||
{
|
||||
{0x00000001, true},
|
||||
{0x00000002, true},
|
||||
{0x00000004, true},
|
||||
{0x80000000, true},
|
||||
{0x00000000, true},
|
||||
{0x00000003, false}
|
||||
};
|
||||
|
||||
int Error = 0;
|
||||
|
||||
for(std::size_t i = 0, n = sizeof(Data) / sizeof(type<glm::uint>); i < n; ++i)
|
||||
{
|
||||
bool Result = glm::isPowerOfTwo(Data[i].Value);
|
||||
Error += Data[i].Return == Result ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += test_int16();
|
||||
Error += test_uint16();
|
||||
Error += test_int32();
|
||||
Error += test_uint32();
|
||||
|
||||
return Error;
|
||||
}
|
||||
}//isPowerOfTwo
|
||||
|
||||
namespace nextPowerOfTwo_advanced
|
||||
{
|
||||
template<typename genIUType>
|
||||
GLM_FUNC_QUALIFIER genIUType highestBitValue(genIUType Value)
|
||||
{
|
||||
genIUType tmp = Value;
|
||||
genIUType result = genIUType(0);
|
||||
while(tmp)
|
||||
{
|
||||
result = (tmp & (~tmp + 1)); // grab lowest bit
|
||||
tmp &= ~result; // clear lowest bit
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER genType nextPowerOfTwo_loop(genType value)
|
||||
{
|
||||
return glm::isPowerOfTwo(value) ? value : highestBitValue(value) << 1;
|
||||
}
|
||||
|
||||
template<typename genType>
|
||||
struct type
|
||||
{
|
||||
genType Value;
|
||||
genType Return;
|
||||
};
|
||||
|
||||
int test_int32()
|
||||
{
|
||||
type<glm::int32> const Data[] =
|
||||
{
|
||||
{0x0000ffff, 0x00010000},
|
||||
{-3, -4},
|
||||
{-8, -8},
|
||||
{0x00000001, 0x00000001},
|
||||
{0x00000002, 0x00000002},
|
||||
{0x00000004, 0x00000004},
|
||||
{0x00000007, 0x00000008},
|
||||
{0x0000fff0, 0x00010000},
|
||||
{0x0000f000, 0x00010000},
|
||||
{0x08000000, 0x08000000},
|
||||
{0x00000000, 0x00000000},
|
||||
{0x00000003, 0x00000004}
|
||||
};
|
||||
|
||||
int Error(0);
|
||||
|
||||
for(std::size_t i = 0, n = sizeof(Data) / sizeof(type<glm::int32>); i < n; ++i)
|
||||
{
|
||||
glm::int32 Result = glm::nextPowerOfTwo(Data[i].Value);
|
||||
Error += Data[i].Return == Result ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test_uint32()
|
||||
{
|
||||
type<glm::uint32> const Data[] =
|
||||
{
|
||||
{0x00000001, 0x00000001},
|
||||
{0x00000002, 0x00000002},
|
||||
{0x00000004, 0x00000004},
|
||||
{0x00000007, 0x00000008},
|
||||
{0x0000ffff, 0x00010000},
|
||||
{0x0000fff0, 0x00010000},
|
||||
{0x0000f000, 0x00010000},
|
||||
{0x80000000, 0x80000000},
|
||||
{0x00000000, 0x00000000},
|
||||
{0x00000003, 0x00000004}
|
||||
};
|
||||
|
||||
int Error(0);
|
||||
|
||||
for(std::size_t i = 0, n = sizeof(Data) / sizeof(type<glm::uint32>); i < n; ++i)
|
||||
{
|
||||
glm::uint32 Result = glm::nextPowerOfTwo(Data[i].Value);
|
||||
Error += Data[i].Return == Result ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int perf()
|
||||
{
|
||||
int Error(0);
|
||||
|
||||
std::vector<glm::uint> v;
|
||||
v.resize(100000000);
|
||||
|
||||
std::clock_t Timestramp0 = std::clock();
|
||||
|
||||
for(glm::uint32 i = 0, n = static_cast<glm::uint>(v.size()); i < n; ++i)
|
||||
v[i] = nextPowerOfTwo_loop(i);
|
||||
|
||||
std::clock_t Timestramp1 = std::clock();
|
||||
|
||||
for(glm::uint32 i = 0, n = static_cast<glm::uint>(v.size()); i < n; ++i)
|
||||
v[i] = glm::nextPowerOfTwo(i);
|
||||
|
||||
std::clock_t Timestramp2 = std::clock();
|
||||
|
||||
std::printf("nextPowerOfTwo_loop: %d clocks\n", static_cast<int>(Timestramp1 - Timestramp0));
|
||||
std::printf("glm::nextPowerOfTwo: %d clocks\n", static_cast<int>(Timestramp2 - Timestramp1));
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test()
|
||||
{
|
||||
int Error(0);
|
||||
|
||||
Error += test_int32();
|
||||
Error += test_uint32();
|
||||
|
||||
return Error;
|
||||
}
|
||||
}//namespace nextPowerOfTwo_advanced
|
||||
|
||||
namespace prevPowerOfTwo
|
||||
{
|
||||
template <typename T>
|
||||
int run()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
T const A = glm::prevPowerOfTwo(static_cast<T>(7));
|
||||
Error += A == static_cast<T>(4) ? 0 : 1;
|
||||
|
||||
T const B = glm::prevPowerOfTwo(static_cast<T>(15));
|
||||
Error += B == static_cast<T>(8) ? 0 : 1;
|
||||
|
||||
T const C = glm::prevPowerOfTwo(static_cast<T>(31));
|
||||
Error += C == static_cast<T>(16) ? 0 : 1;
|
||||
|
||||
T const D = glm::prevPowerOfTwo(static_cast<T>(32));
|
||||
Error += D == static_cast<T>(32) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += run<glm::int8>();
|
||||
Error += run<glm::int16>();
|
||||
Error += run<glm::int32>();
|
||||
Error += run<glm::int64>();
|
||||
|
||||
Error += run<glm::uint8>();
|
||||
Error += run<glm::uint16>();
|
||||
Error += run<glm::uint32>();
|
||||
Error += run<glm::uint64>();
|
||||
|
||||
return Error;
|
||||
}
|
||||
}//namespace prevPowerOfTwo
|
||||
|
||||
namespace nextPowerOfTwo
|
||||
{
|
||||
template <typename T>
|
||||
int run()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
T const A = glm::nextPowerOfTwo(static_cast<T>(7));
|
||||
Error += A == static_cast<T>(8) ? 0 : 1;
|
||||
|
||||
T const B = glm::nextPowerOfTwo(static_cast<T>(15));
|
||||
Error += B == static_cast<T>(16) ? 0 : 1;
|
||||
|
||||
T const C = glm::nextPowerOfTwo(static_cast<T>(31));
|
||||
Error += C == static_cast<T>(32) ? 0 : 1;
|
||||
|
||||
T const D = glm::nextPowerOfTwo(static_cast<T>(32));
|
||||
Error += D == static_cast<T>(32) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += run<glm::int8>();
|
||||
Error += run<glm::int16>();
|
||||
Error += run<glm::int32>();
|
||||
Error += run<glm::int64>();
|
||||
|
||||
Error += run<glm::uint8>();
|
||||
Error += run<glm::uint16>();
|
||||
Error += run<glm::uint32>();
|
||||
Error += run<glm::uint64>();
|
||||
|
||||
return Error;
|
||||
}
|
||||
}//namespace nextPowerOfTwo
|
||||
|
||||
namespace prevMultiple
|
||||
{
|
||||
template<typename genIUType>
|
||||
struct type
|
||||
{
|
||||
genIUType Source;
|
||||
genIUType Multiple;
|
||||
genIUType Return;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
int run()
|
||||
{
|
||||
type<T> const Data[] =
|
||||
{
|
||||
{8, 3, 6},
|
||||
{7, 7, 7}
|
||||
};
|
||||
|
||||
int Error = 0;
|
||||
|
||||
for(std::size_t i = 0, n = sizeof(Data) / sizeof(type<T>); i < n; ++i)
|
||||
{
|
||||
T const Result = glm::prevMultiple(Data[i].Source, Data[i].Multiple);
|
||||
Error += Data[i].Return == Result ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += run<glm::int8>();
|
||||
Error += run<glm::int16>();
|
||||
Error += run<glm::int32>();
|
||||
Error += run<glm::int64>();
|
||||
|
||||
Error += run<glm::uint8>();
|
||||
Error += run<glm::uint16>();
|
||||
Error += run<glm::uint32>();
|
||||
Error += run<glm::uint64>();
|
||||
|
||||
return Error;
|
||||
}
|
||||
}//namespace prevMultiple
|
||||
|
||||
namespace nextMultiple
|
||||
{
|
||||
static glm::uint const Multiples = 128;
|
||||
|
||||
int perf_nextMultiple(glm::uint Samples)
|
||||
{
|
||||
std::vector<glm::uint> Results(Samples * Multiples);
|
||||
|
||||
std::chrono::high_resolution_clock::time_point t0 = std::chrono::high_resolution_clock::now();
|
||||
|
||||
for(glm::uint Source = 0; Source < Samples; ++Source)
|
||||
for(glm::uint Multiple = 0; Multiple < Multiples; ++Multiple)
|
||||
{
|
||||
Results[Source * Multiples + Multiple] = glm::nextMultiple(Source, Multiples);
|
||||
}
|
||||
|
||||
std::chrono::high_resolution_clock::time_point t1 = std::chrono::high_resolution_clock::now();
|
||||
|
||||
std::printf("- glm::nextMultiple Time %d microseconds\n", static_cast<int>(std::chrono::duration_cast<std::chrono::microseconds>(t1 - t0).count()));
|
||||
|
||||
glm::uint Result = 0;
|
||||
for(std::size_t i = 0, n = Results.size(); i < n; ++i)
|
||||
Result += Results[i];
|
||||
|
||||
return Result > 0 ? 0 : 1;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER T nextMultipleMod(T Source, T Multiple)
|
||||
{
|
||||
T const Tmp = Source - static_cast<T>(1);
|
||||
return Tmp + (Multiple - (Tmp % Multiple));
|
||||
}
|
||||
|
||||
int perf_nextMultipleMod(glm::uint Samples)
|
||||
{
|
||||
std::vector<glm::uint> Results(Samples * Multiples);
|
||||
|
||||
std::chrono::high_resolution_clock::time_point t0 = std::chrono::high_resolution_clock::now();
|
||||
|
||||
for(glm::uint Multiple = 0; Multiple < Multiples; ++Multiple)
|
||||
for (glm::uint Source = 0; Source < Samples; ++Source)
|
||||
{
|
||||
Results[Source * Multiples + Multiple] = nextMultipleMod(Source, Multiples);
|
||||
}
|
||||
|
||||
std::chrono::high_resolution_clock::time_point t1 = std::chrono::high_resolution_clock::now();
|
||||
|
||||
std::printf("- nextMultipleMod Time %d microseconds\n", static_cast<int>(std::chrono::duration_cast<std::chrono::microseconds>(t1 - t0).count()));
|
||||
|
||||
glm::uint Result = 0;
|
||||
for(std::size_t i = 0, n = Results.size(); i < n; ++i)
|
||||
Result += Results[i];
|
||||
|
||||
return Result > 0 ? 0 : 1;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER T nextMultipleNeg(T Source, T Multiple)
|
||||
{
|
||||
if(Source > static_cast<T>(0))
|
||||
{
|
||||
T const Tmp = Source - static_cast<T>(1);
|
||||
return Tmp + (Multiple - (Tmp % Multiple));
|
||||
}
|
||||
else
|
||||
return Source + (-Source % Multiple);
|
||||
}
|
||||
|
||||
int perf_nextMultipleNeg(glm::uint Samples)
|
||||
{
|
||||
std::vector<glm::uint> Results(Samples * Multiples);
|
||||
|
||||
std::chrono::high_resolution_clock::time_point t0 = std::chrono::high_resolution_clock::now();
|
||||
|
||||
for(glm::uint Source = 0; Source < Samples; ++Source)
|
||||
for(glm::uint Multiple = 0; Multiple < Multiples; ++Multiple)
|
||||
{
|
||||
Results[Source * Multiples + Multiple] = nextMultipleNeg(Source, Multiples);
|
||||
}
|
||||
|
||||
std::chrono::high_resolution_clock::time_point t1 = std::chrono::high_resolution_clock::now();
|
||||
|
||||
std::printf("- nextMultipleNeg Time %d microseconds\n", static_cast<int>(std::chrono::duration_cast<std::chrono::microseconds>(t1 - t0).count()));
|
||||
|
||||
glm::uint Result = 0;
|
||||
for (std::size_t i = 0, n = Results.size(); i < n; ++i)
|
||||
Result += Results[i];
|
||||
|
||||
return Result > 0 ? 0 : 1;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER T nextMultipleUFloat(T Source, T Multiple)
|
||||
{
|
||||
return Source + (Multiple - std::fmod(Source, Multiple));
|
||||
}
|
||||
|
||||
int perf_nextMultipleUFloat(glm::uint Samples)
|
||||
{
|
||||
std::vector<float> Results(Samples * Multiples);
|
||||
|
||||
std::chrono::high_resolution_clock::time_point t0 = std::chrono::high_resolution_clock::now();
|
||||
|
||||
for(glm::uint Source = 0; Source < Samples; ++Source)
|
||||
for(glm::uint Multiple = 0; Multiple < Multiples; ++Multiple)
|
||||
{
|
||||
Results[Source * Multiples + Multiple] = nextMultipleUFloat(static_cast<float>(Source), static_cast<float>(Multiples));
|
||||
}
|
||||
|
||||
std::chrono::high_resolution_clock::time_point t1 = std::chrono::high_resolution_clock::now();
|
||||
|
||||
std::printf("- nextMultipleUFloat Time %d microseconds\n", static_cast<int>(std::chrono::duration_cast<std::chrono::microseconds>(t1 - t0).count()));
|
||||
|
||||
float Result = 0;
|
||||
for (std::size_t i = 0, n = Results.size(); i < n; ++i)
|
||||
Result += Results[i];
|
||||
|
||||
return Result > 0.0f ? 0 : 1;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER T nextMultipleFloat(T Source, T Multiple)
|
||||
{
|
||||
if(Source > static_cast<float>(0))
|
||||
return Source + (Multiple - std::fmod(Source, Multiple));
|
||||
else
|
||||
return Source + std::fmod(-Source, Multiple);
|
||||
}
|
||||
|
||||
int perf_nextMultipleFloat(glm::uint Samples)
|
||||
{
|
||||
std::vector<float> Results(Samples * Multiples);
|
||||
|
||||
std::chrono::high_resolution_clock::time_point t0 = std::chrono::high_resolution_clock::now();
|
||||
|
||||
for(glm::uint Source = 0; Source < Samples; ++Source)
|
||||
for(glm::uint Multiple = 0; Multiple < Multiples; ++Multiple)
|
||||
{
|
||||
Results[Source * Multiples + Multiple] = nextMultipleFloat(static_cast<float>(Source), static_cast<float>(Multiples));
|
||||
}
|
||||
|
||||
std::chrono::high_resolution_clock::time_point t1 = std::chrono::high_resolution_clock::now();
|
||||
|
||||
std::printf("- nextMultipleFloat Time %d microseconds\n", static_cast<int>(std::chrono::duration_cast<std::chrono::microseconds>(t1 - t0).count()));
|
||||
|
||||
float Result = 0;
|
||||
for (std::size_t i = 0, n = Results.size(); i < n; ++i)
|
||||
Result += Results[i];
|
||||
|
||||
return Result > 0.0f ? 0 : 1;
|
||||
}
|
||||
|
||||
template<typename genIUType>
|
||||
struct type
|
||||
{
|
||||
genIUType Source;
|
||||
genIUType Multiple;
|
||||
genIUType Return;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
int test_uint()
|
||||
{
|
||||
type<T> const Data[] =
|
||||
{
|
||||
{ 3, 4, 4 },
|
||||
{ 6, 3, 6 },
|
||||
{ 5, 3, 6 },
|
||||
{ 7, 7, 7 },
|
||||
{ 0, 1, 0 },
|
||||
{ 8, 3, 9 }
|
||||
};
|
||||
|
||||
int Error = 0;
|
||||
|
||||
for(std::size_t i = 0, n = sizeof(Data) / sizeof(type<T>); i < n; ++i)
|
||||
{
|
||||
T const Result0 = glm::nextMultiple(Data[i].Source, Data[i].Multiple);
|
||||
Error += Data[i].Return == Result0 ? 0 : 1;
|
||||
assert(!Error);
|
||||
|
||||
T const Result1 = nextMultipleMod(Data[i].Source, Data[i].Multiple);
|
||||
Error += Data[i].Return == Result1 ? 0 : 1;
|
||||
assert(!Error);
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int perf()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
glm::uint const Samples = 10000;
|
||||
|
||||
for(int i = 0; i < 4; ++i)
|
||||
{
|
||||
std::printf("Run %d :\n", i);
|
||||
Error += perf_nextMultiple(Samples);
|
||||
Error += perf_nextMultipleMod(Samples);
|
||||
Error += perf_nextMultipleNeg(Samples);
|
||||
Error += perf_nextMultipleUFloat(Samples);
|
||||
Error += perf_nextMultipleFloat(Samples);
|
||||
std::printf("\n");
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += test_uint<glm::int8>();
|
||||
Error += test_uint<glm::int16>();
|
||||
Error += test_uint<glm::int32>();
|
||||
Error += test_uint<glm::int64>();
|
||||
|
||||
Error += test_uint<glm::uint8>();
|
||||
Error += test_uint<glm::uint16>();
|
||||
Error += test_uint<glm::uint32>();
|
||||
Error += test_uint<glm::uint64>();
|
||||
|
||||
return Error;
|
||||
}
|
||||
}//namespace nextMultiple
|
||||
|
||||
namespace findNSB
|
||||
{
|
||||
template<typename T>
|
||||
struct type
|
||||
{
|
||||
T Source;
|
||||
int SignificantBitCount;
|
||||
int Return;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
int run()
|
||||
{
|
||||
type<T> const Data[] =
|
||||
{
|
||||
{ 0x00, 1,-1 },
|
||||
{ 0x01, 2,-1 },
|
||||
{ 0x02, 2,-1 },
|
||||
{ 0x06, 3,-1 },
|
||||
{ 0x01, 1, 0 },
|
||||
{ 0x03, 1, 0 },
|
||||
{ 0x03, 2, 1 },
|
||||
{ 0x07, 2, 1 },
|
||||
{ 0x05, 2, 2 },
|
||||
{ 0x0D, 2, 2 }
|
||||
};
|
||||
|
||||
int Error = 0;
|
||||
|
||||
for (std::size_t i = 0, n = sizeof(Data) / sizeof(type<T>); i < n; ++i)
|
||||
{
|
||||
int const Result0 = glm::findNSB(Data[i].Source, Data[i].SignificantBitCount);
|
||||
Error += Data[i].Return == Result0 ? 0 : 1;
|
||||
assert(!Error);
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += run<glm::uint8>();
|
||||
Error += run<glm::uint16>();
|
||||
Error += run<glm::uint32>();
|
||||
Error += run<glm::uint64>();
|
||||
|
||||
Error += run<glm::int8>();
|
||||
Error += run<glm::int16>();
|
||||
Error += run<glm::int32>();
|
||||
Error += run<glm::int64>();
|
||||
|
||||
return Error;
|
||||
}
|
||||
}//namespace findNSB
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += findNSB::test();
|
||||
|
||||
Error += isPowerOfTwo::test();
|
||||
Error += prevPowerOfTwo::test();
|
||||
Error += nextPowerOfTwo::test();
|
||||
Error += nextPowerOfTwo_advanced::test();
|
||||
Error += prevMultiple::test();
|
||||
Error += nextMultiple::test();
|
||||
|
||||
# ifdef NDEBUG
|
||||
Error += nextPowerOfTwo_advanced::perf();
|
||||
Error += nextMultiple::perf();
|
||||
# endif//NDEBUG
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
106
lib/glm/test/ext/ext_scalar_relational.cpp
Normal file
106
lib/glm/test/ext/ext_scalar_relational.cpp
Normal file
@@ -0,0 +1,106 @@
|
||||
#include <glm/ext/scalar_relational.hpp>
|
||||
#include <glm/ext/scalar_integer.hpp>
|
||||
#include <glm/ext/scalar_ulp.hpp>
|
||||
#include <cmath>
|
||||
|
||||
static int test_equal_epsilon()
|
||||
{
|
||||
# if GLM_CONFIG_CONSTEXP == GLM_ENABLE
|
||||
static_assert(glm::equal(1.01f, 1.02f, 0.1f), "GLM: Failed constexpr");
|
||||
static_assert(!glm::equal(1.01f, 1.02f, 0.001f), "GLM: Failed constexpr");
|
||||
# endif
|
||||
|
||||
int Error = 0;
|
||||
|
||||
Error += glm::equal(1.01f, 1.02f, 0.1f) ? 0 : 1;
|
||||
Error += !glm::equal(1.01f, 1.02f, 0.001f) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_notEqual_epsilon()
|
||||
{
|
||||
# if GLM_CONFIG_CONSTEXP == GLM_ENABLE
|
||||
static_assert(glm::notEqual(1.01f, 1.02f, 0.001f), "GLM: Failed constexpr");
|
||||
static_assert(!glm::notEqual(1.01f, 1.02f, 0.1f), "GLM: Failed constexpr");
|
||||
# endif
|
||||
|
||||
int Error = 0;
|
||||
|
||||
Error += glm::notEqual(1.01f, 1.02f, 0.001f) ? 0 : 1;
|
||||
Error += !glm::notEqual(1.01f, 1.02f, 0.1f) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_equal_ulps()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
float const ULP1Plus = glm::nextFloat(1.0f);
|
||||
Error += glm::equal(1.0f, ULP1Plus, 1) ? 0 : 1;
|
||||
|
||||
float const ULP2Plus = glm::nextFloat(ULP1Plus);
|
||||
Error += !glm::equal(1.0f, ULP2Plus, 1) ? 0 : 1;
|
||||
|
||||
float const ULP1Minus = glm::prevFloat(1.0f);
|
||||
Error += glm::equal(1.0f, ULP1Minus, 1) ? 0 : 1;
|
||||
|
||||
float const ULP2Minus = glm::prevFloat(ULP1Minus);
|
||||
Error += !glm::equal(1.0f, ULP2Minus, 1) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_notEqual_ulps()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
float const ULP1Plus = glm::nextFloat(1.0f);
|
||||
Error += !glm::notEqual(1.0f, ULP1Plus, 1) ? 0 : 1;
|
||||
|
||||
float const ULP2Plus = glm::nextFloat(ULP1Plus);
|
||||
Error += glm::notEqual(1.0f, ULP2Plus, 1) ? 0 : 1;
|
||||
|
||||
float const ULP1Minus = glm::prevFloat(1.0f);
|
||||
Error += !glm::notEqual(1.0f, ULP1Minus, 1) ? 0 : 1;
|
||||
|
||||
float const ULP2Minus = glm::prevFloat(ULP1Minus);
|
||||
Error += glm::notEqual(1.0f, ULP2Minus, 1) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_equal_sign()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += !glm::equal(-0.0f, 0.0f, 2) ? 0 : 1;
|
||||
Error += !glm::equal(-0.0, 0.0, 2) ? 0 : 1;
|
||||
|
||||
Error += !glm::equal(-1.0f, 2.0f, 2) ? 0 : 1;
|
||||
Error += !glm::equal(-1.0, 2.0, 2) ? 0 : 1;
|
||||
|
||||
Error += !glm::equal(-0.00001f, 1.00000f, 2) ? 0 : 1;
|
||||
Error += !glm::equal(-0.00001, 1.00000, 2) ? 0 : 1;
|
||||
|
||||
Error += !glm::equal(-1.0f, 1.0f, 2) ? 0 : 1;
|
||||
Error += !glm::equal(-1.0, 1.0, 2) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += test_equal_epsilon();
|
||||
Error += test_notEqual_epsilon();
|
||||
|
||||
Error += test_equal_ulps();
|
||||
Error += test_notEqual_ulps();
|
||||
|
||||
Error += test_equal_sign();
|
||||
|
||||
return Error;
|
||||
}
|
||||
43
lib/glm/test/ext/ext_scalar_uint_sized.cpp
Normal file
43
lib/glm/test/ext/ext_scalar_uint_sized.cpp
Normal file
@@ -0,0 +1,43 @@
|
||||
#include <glm/ext/scalar_uint_sized.hpp>
|
||||
|
||||
#if GLM_HAS_STATIC_ASSERT
|
||||
static_assert(sizeof(glm::uint8) == 1, "uint8 size isn't 1 byte on this platform");
|
||||
static_assert(sizeof(glm::uint16) == 2, "uint16 size isn't 2 bytes on this platform");
|
||||
static_assert(sizeof(glm::uint32) == 4, "uint32 size isn't 4 bytes on this platform");
|
||||
static_assert(sizeof(glm::uint64) == 8, "uint64 size isn't 8 bytes on this platform");
|
||||
static_assert(sizeof(glm::uint16) == sizeof(unsigned short), "unsigned short size isn't 4 bytes on this platform");
|
||||
static_assert(sizeof(glm::uint32) == sizeof(unsigned int), "unsigned int size isn't 4 bytes on this platform");
|
||||
#endif
|
||||
|
||||
static int test_size()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += sizeof(glm::uint8) == 1 ? 0 : 1;
|
||||
Error += sizeof(glm::uint16) == 2 ? 0 : 1;
|
||||
Error += sizeof(glm::uint32) == 4 ? 0 : 1;
|
||||
Error += sizeof(glm::uint64) == 8 ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_comp()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += sizeof(glm::uint8) < sizeof(glm::uint16) ? 0 : 1;
|
||||
Error += sizeof(glm::uint16) < sizeof(glm::uint32) ? 0 : 1;
|
||||
Error += sizeof(glm::uint32) < sizeof(glm::uint64) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += test_size();
|
||||
Error += test_comp();
|
||||
|
||||
return Error;
|
||||
}
|
||||
96
lib/glm/test/ext/ext_scalar_ulp.cpp
Normal file
96
lib/glm/test/ext/ext_scalar_ulp.cpp
Normal file
@@ -0,0 +1,96 @@
|
||||
#include <glm/ext/scalar_ulp.hpp>
|
||||
#include <glm/ext/scalar_relational.hpp>
|
||||
|
||||
static int test_ulp_float_dist()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
float A = 1.0f;
|
||||
|
||||
float B = glm::nextFloat(A);
|
||||
Error += glm::notEqual(A, B, 0) ? 0 : 1;
|
||||
float C = glm::prevFloat(B);
|
||||
Error += glm::equal(A, C, 0) ? 0 : 1;
|
||||
|
||||
int D = glm::floatDistance(A, B);
|
||||
Error += D == 1 ? 0 : 1;
|
||||
int E = glm::floatDistance(A, C);
|
||||
Error += E == 0 ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_ulp_float_step()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
float A = 1.0f;
|
||||
|
||||
for(int i = 10; i < 1000; i *= 10)
|
||||
{
|
||||
float B = glm::nextFloat(A, i);
|
||||
Error += glm::notEqual(A, B, 0) ? 0 : 1;
|
||||
float C = glm::prevFloat(B, i);
|
||||
Error += glm::equal(A, C, 0) ? 0 : 1;
|
||||
|
||||
int D = glm::floatDistance(A, B);
|
||||
Error += D == i ? 0 : 1;
|
||||
int E = glm::floatDistance(A, C);
|
||||
Error += E == 0 ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_ulp_double_dist()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
double A = 1.0;
|
||||
|
||||
double B = glm::nextFloat(A);
|
||||
Error += glm::notEqual(A, B, 0) ? 0 : 1;
|
||||
double C = glm::prevFloat(B);
|
||||
Error += glm::equal(A, C, 0) ? 0 : 1;
|
||||
|
||||
glm::int64 const D = glm::floatDistance(A, B);
|
||||
Error += D == 1 ? 0 : 1;
|
||||
glm::int64 const E = glm::floatDistance(A, C);
|
||||
Error += E == 0 ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_ulp_double_step()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
double A = 1.0;
|
||||
|
||||
for(int i = 10; i < 1000; i *= 10)
|
||||
{
|
||||
double B = glm::nextFloat(A, i);
|
||||
Error += glm::notEqual(A, B, 0) ? 0 : 1;
|
||||
double C = glm::prevFloat(B, i);
|
||||
Error += glm::equal(A, C, 0) ? 0 : 1;
|
||||
|
||||
glm::int64 const D = glm::floatDistance(A, B);
|
||||
Error += D == i ? 0 : 1;
|
||||
glm::int64 const E = glm::floatDistance(A, C);
|
||||
Error += E == 0 ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += test_ulp_float_dist();
|
||||
Error += test_ulp_float_step();
|
||||
Error += test_ulp_double_dist();
|
||||
Error += test_ulp_double_step();
|
||||
|
||||
return Error;
|
||||
}
|
||||
157
lib/glm/test/ext/ext_vec1.cpp
Normal file
157
lib/glm/test/ext/ext_vec1.cpp
Normal file
@@ -0,0 +1,157 @@
|
||||
#define GLM_FORCE_SWIZZLE
|
||||
#include <glm/vector_relational.hpp>
|
||||
#include <glm/gtc/vec1.hpp>
|
||||
#include <vector>
|
||||
|
||||
static glm::vec1 g1;
|
||||
static glm::vec1 g2(1);
|
||||
|
||||
static int test_vec1_operators()
|
||||
{
|
||||
int Error(0);
|
||||
|
||||
glm::ivec1 A(1);
|
||||
glm::ivec1 B(1);
|
||||
{
|
||||
bool R = A != B;
|
||||
bool S = A == B;
|
||||
|
||||
Error += (S && !R) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
A *= 1;
|
||||
B *= 1;
|
||||
A += 1;
|
||||
B += 1;
|
||||
|
||||
bool R = A != B;
|
||||
bool S = A == B;
|
||||
|
||||
Error += (S && !R) ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_vec1_ctor()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
# if GLM_HAS_TRIVIAL_QUERIES
|
||||
// Error += std::is_trivially_default_constructible<glm::vec1>::value ? 0 : 1;
|
||||
// Error += std::is_trivially_copy_assignable<glm::vec1>::value ? 0 : 1;
|
||||
Error += std::is_trivially_copyable<glm::vec1>::value ? 0 : 1;
|
||||
Error += std::is_trivially_copyable<glm::dvec1>::value ? 0 : 1;
|
||||
Error += std::is_trivially_copyable<glm::ivec1>::value ? 0 : 1;
|
||||
Error += std::is_trivially_copyable<glm::uvec1>::value ? 0 : 1;
|
||||
|
||||
Error += std::is_copy_constructible<glm::vec1>::value ? 0 : 1;
|
||||
# endif
|
||||
|
||||
|
||||
{
|
||||
glm::ivec1 A = glm::vec1(2.0f);
|
||||
|
||||
glm::ivec1 E(glm::dvec1(2.0));
|
||||
Error += A == E ? 0 : 1;
|
||||
|
||||
glm::ivec1 F(glm::ivec1(2));
|
||||
Error += A == F ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_vec1_size()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += sizeof(glm::vec1) == sizeof(glm::mediump_vec1) ? 0 : 1;
|
||||
Error += 4 == sizeof(glm::mediump_vec1) ? 0 : 1;
|
||||
Error += sizeof(glm::dvec1) == sizeof(glm::highp_dvec1) ? 0 : 1;
|
||||
Error += 8 == sizeof(glm::highp_dvec1) ? 0 : 1;
|
||||
Error += glm::vec1().length() == 1 ? 0 : 1;
|
||||
Error += glm::dvec1().length() == 1 ? 0 : 1;
|
||||
Error += glm::vec1::length() == 1 ? 0 : 1;
|
||||
Error += glm::dvec1::length() == 1 ? 0 : 1;
|
||||
|
||||
GLM_CONSTEXPR std::size_t Length = glm::vec1::length();
|
||||
Error += Length == 1 ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_vec1_operator_increment()
|
||||
{
|
||||
int Error(0);
|
||||
|
||||
glm::ivec1 v0(1);
|
||||
glm::ivec1 v1(v0);
|
||||
glm::ivec1 v2(v0);
|
||||
glm::ivec1 v3 = ++v1;
|
||||
glm::ivec1 v4 = v2++;
|
||||
|
||||
Error += glm::all(glm::equal(v0, v4)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(v1, v2)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(v1, v3)) ? 0 : 1;
|
||||
|
||||
int i0(1);
|
||||
int i1(i0);
|
||||
int i2(i0);
|
||||
int i3 = ++i1;
|
||||
int i4 = i2++;
|
||||
|
||||
Error += i0 == i4 ? 0 : 1;
|
||||
Error += i1 == i2 ? 0 : 1;
|
||||
Error += i1 == i3 ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_bvec1_ctor()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
glm::bvec1 const A(true);
|
||||
glm::bvec1 const B(true);
|
||||
glm::bvec1 const C(false);
|
||||
glm::bvec1 const D = A && B;
|
||||
glm::bvec1 const E = A && C;
|
||||
glm::bvec1 const F = A || C;
|
||||
|
||||
Error += D == glm::bvec1(true) ? 0 : 1;
|
||||
Error += E == glm::bvec1(false) ? 0 : 1;
|
||||
Error += F == glm::bvec1(true) ? 0 : 1;
|
||||
|
||||
bool const G = A == C;
|
||||
bool const H = A != C;
|
||||
Error += !G ? 0 : 1;
|
||||
Error += H ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_constexpr()
|
||||
{
|
||||
#if GLM_HAS_CONSTEXPR
|
||||
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;
|
||||
|
||||
Error += test_vec1_size();
|
||||
Error += test_vec1_ctor();
|
||||
Error += test_bvec1_ctor();
|
||||
Error += test_vec1_operators();
|
||||
Error += test_vec1_operator_increment();
|
||||
Error += test_constexpr();
|
||||
|
||||
return Error;
|
||||
}
|
||||
104
lib/glm/test/ext/ext_vector_bool1.cpp
Normal file
104
lib/glm/test/ext/ext_vector_bool1.cpp
Normal file
@@ -0,0 +1,104 @@
|
||||
#include <glm/ext/vector_bool1.hpp>
|
||||
#include <glm/ext/vector_bool1_precision.hpp>
|
||||
|
||||
template <typename genType>
|
||||
static int test_operators()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
genType const A(true);
|
||||
genType const B(true);
|
||||
{
|
||||
bool const R = A != B;
|
||||
bool const S = A == B;
|
||||
Error += (S && !R) ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
static int test_ctor()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
glm::bvec1 const A = genType(true);
|
||||
|
||||
glm::bvec1 const E(genType(true));
|
||||
Error += A == E ? 0 : 1;
|
||||
|
||||
glm::bvec1 const F(E);
|
||||
Error += A == F ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
static int test_size()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += sizeof(glm::bvec1) == sizeof(genType) ? 0 : 1;
|
||||
Error += genType().length() == 1 ? 0 : 1;
|
||||
Error += genType::length() == 1 ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
static int test_relational()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
genType const A(true);
|
||||
genType const B(true);
|
||||
genType const C(false);
|
||||
|
||||
Error += A == B ? 0 : 1;
|
||||
Error += (A && B) == A ? 0 : 1;
|
||||
Error += (A || C) == A ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
static int test_constexpr()
|
||||
{
|
||||
# if GLM_HAS_CONSTEXPR
|
||||
static_assert(genType::length() == 1, "GLM: Failed constexpr");
|
||||
# endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += test_operators<glm::bvec1>();
|
||||
Error += test_operators<glm::lowp_bvec1>();
|
||||
Error += test_operators<glm::mediump_bvec1>();
|
||||
Error += test_operators<glm::highp_bvec1>();
|
||||
|
||||
Error += test_ctor<glm::bvec1>();
|
||||
Error += test_ctor<glm::lowp_bvec1>();
|
||||
Error += test_ctor<glm::mediump_bvec1>();
|
||||
Error += test_ctor<glm::highp_bvec1>();
|
||||
|
||||
Error += test_size<glm::bvec1>();
|
||||
Error += test_size<glm::lowp_bvec1>();
|
||||
Error += test_size<glm::mediump_bvec1>();
|
||||
Error += test_size<glm::highp_bvec1>();
|
||||
|
||||
Error += test_relational<glm::bvec1>();
|
||||
Error += test_relational<glm::lowp_bvec1>();
|
||||
Error += test_relational<glm::mediump_bvec1>();
|
||||
Error += test_relational<glm::highp_bvec1>();
|
||||
|
||||
Error += test_constexpr<glm::bvec1>();
|
||||
Error += test_constexpr<glm::lowp_bvec1>();
|
||||
Error += test_constexpr<glm::mediump_bvec1>();
|
||||
Error += test_constexpr<glm::highp_bvec1>();
|
||||
|
||||
return Error;
|
||||
}
|
||||
250
lib/glm/test/ext/ext_vector_common.cpp
Normal file
250
lib/glm/test/ext/ext_vector_common.cpp
Normal file
@@ -0,0 +1,250 @@
|
||||
#include <glm/ext/vector_common.hpp>
|
||||
#include <glm/ext/vector_bool1.hpp>
|
||||
#include <glm/ext/vector_bool1_precision.hpp>
|
||||
#include <glm/ext/vector_bool2.hpp>
|
||||
#include <glm/ext/vector_bool2_precision.hpp>
|
||||
#include <glm/ext/vector_bool3.hpp>
|
||||
#include <glm/ext/vector_bool3_precision.hpp>
|
||||
#include <glm/ext/vector_bool4.hpp>
|
||||
#include <glm/ext/vector_bool4_precision.hpp>
|
||||
|
||||
#include <glm/ext/vector_float1.hpp>
|
||||
#include <glm/ext/vector_float1_precision.hpp>
|
||||
#include <glm/ext/vector_float2.hpp>
|
||||
#include <glm/ext/vector_float2_precision.hpp>
|
||||
#include <glm/ext/vector_float3.hpp>
|
||||
#include <glm/ext/vector_float3_precision.hpp>
|
||||
#include <glm/ext/vector_float4.hpp>
|
||||
#include <glm/ext/vector_float4_precision.hpp>
|
||||
#include <glm/ext/vector_double1.hpp>
|
||||
#include <glm/ext/vector_double1_precision.hpp>
|
||||
#include <glm/ext/vector_double2.hpp>
|
||||
#include <glm/ext/vector_double2_precision.hpp>
|
||||
#include <glm/ext/vector_double3.hpp>
|
||||
#include <glm/ext/vector_double3_precision.hpp>
|
||||
#include <glm/ext/vector_double4.hpp>
|
||||
#include <glm/ext/vector_double4_precision.hpp>
|
||||
#include <glm/ext/vector_relational.hpp>
|
||||
#include <glm/ext/scalar_constants.hpp>
|
||||
#include <glm/vector_relational.hpp>
|
||||
#include <glm/common.hpp>
|
||||
|
||||
#if ((GLM_LANG & GLM_LANG_CXX11_FLAG) || (GLM_COMPILER & GLM_COMPILER_VC))
|
||||
# define GLM_NAN(T) NAN
|
||||
#else
|
||||
# define GLM_NAN(T) (static_cast<T>(0.0f) / static_cast<T>(0.0f))
|
||||
#endif
|
||||
|
||||
template <typename vecType>
|
||||
static int test_min()
|
||||
{
|
||||
typedef typename vecType::value_type T;
|
||||
|
||||
int Error = 0;
|
||||
|
||||
vecType const N(static_cast<T>(0));
|
||||
vecType const B(static_cast<T>(1));
|
||||
|
||||
Error += glm::all(glm::equal(glm::min(N, B), N, glm::epsilon<T>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(glm::min(B, N), N, glm::epsilon<T>())) ? 0 : 1;
|
||||
|
||||
vecType const C(static_cast<T>(2));
|
||||
Error += glm::all(glm::equal(glm::min(N, B, C), N, glm::epsilon<T>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(glm::min(B, N, C), N, glm::epsilon<T>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(glm::min(C, N, B), N, glm::epsilon<T>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(glm::min(C, B, N), N, glm::epsilon<T>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(glm::min(B, C, N), N, glm::epsilon<T>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(glm::min(N, C, B), N, glm::epsilon<T>())) ? 0 : 1;
|
||||
|
||||
vecType const D(static_cast<T>(3));
|
||||
Error += glm::all(glm::equal(glm::min(D, N, B, C), N, glm::epsilon<T>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(glm::min(B, D, N, C), N, glm::epsilon<T>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(glm::min(C, N, D, B), N, glm::epsilon<T>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(glm::min(C, B, D, N), N, glm::epsilon<T>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(glm::min(B, C, N, D), N, glm::epsilon<T>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(glm::min(N, C, B, D), N, glm::epsilon<T>())) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
template <typename vecType>
|
||||
static int test_min_nan()
|
||||
{
|
||||
typedef typename vecType::value_type T;
|
||||
|
||||
int Error = 0;
|
||||
|
||||
vecType const B(static_cast<T>(1));
|
||||
vecType const N(GLM_NAN(T));
|
||||
|
||||
Error += glm::all(glm::isnan(glm::min(N, B))) ? 0 : 1;
|
||||
Error += !glm::all(glm::isnan(glm::min(B, N))) ? 0 : 1;
|
||||
|
||||
vecType const C(static_cast<T>(2));
|
||||
Error += glm::all(glm::isnan(glm::min(N, B, C))) ? 0 : 1;
|
||||
Error += !glm::all(glm::isnan(glm::min(B, N, C))) ? 0 : 1;
|
||||
Error += !glm::all(glm::isnan(glm::min(C, N, B))) ? 0 : 1;
|
||||
Error += !glm::all(glm::isnan(glm::min(C, B, N))) ? 0 : 1;
|
||||
Error += !glm::all(glm::isnan(glm::min(B, C, N))) ? 0 : 1;
|
||||
Error += glm::all(glm::isnan(glm::min(N, C, B))) ? 0 : 1;
|
||||
|
||||
vecType const D(static_cast<T>(3));
|
||||
Error += !glm::all(glm::isnan(glm::min(D, N, B, C))) ? 0 : 1;
|
||||
Error += !glm::all(glm::isnan(glm::min(B, D, N, C))) ? 0 : 1;
|
||||
Error += !glm::all(glm::isnan(glm::min(C, N, D, B))) ? 0 : 1;
|
||||
Error += !glm::all(glm::isnan(glm::min(C, B, D, N))) ? 0 : 1;
|
||||
Error += !glm::all(glm::isnan(glm::min(B, C, N, D))) ? 0 : 1;
|
||||
Error += glm::all(glm::isnan(glm::min(N, C, B, D))) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
template <typename vecType>
|
||||
static int test_max()
|
||||
{
|
||||
typedef typename vecType::value_type T;
|
||||
|
||||
int Error = 0;
|
||||
|
||||
vecType const N(static_cast<T>(0));
|
||||
vecType const B(static_cast<T>(1));
|
||||
Error += glm::all(glm::equal(glm::max(N, B), B, glm::epsilon<T>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(glm::max(B, N), B, glm::epsilon<T>())) ? 0 : 1;
|
||||
|
||||
vecType const C(static_cast<T>(2));
|
||||
Error += glm::all(glm::equal(glm::max(N, B, C), C, glm::epsilon<T>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(glm::max(B, N, C), C, glm::epsilon<T>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(glm::max(C, N, B), C, glm::epsilon<T>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(glm::max(C, B, N), C, glm::epsilon<T>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(glm::max(B, C, N), C, glm::epsilon<T>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(glm::max(N, C, B), C, glm::epsilon<T>())) ? 0 : 1;
|
||||
|
||||
vecType const D(static_cast<T>(3));
|
||||
Error += glm::all(glm::equal(glm::max(D, N, B, C), D, glm::epsilon<T>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(glm::max(B, D, N, C), D, glm::epsilon<T>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(glm::max(C, N, D, B), D, glm::epsilon<T>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(glm::max(C, B, D, N), D, glm::epsilon<T>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(glm::max(B, C, N, D), D, glm::epsilon<T>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(glm::max(N, C, B, D), D, glm::epsilon<T>())) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
template <typename vecType>
|
||||
static int test_max_nan()
|
||||
{
|
||||
typedef typename vecType::value_type T;
|
||||
|
||||
int Error = 0;
|
||||
|
||||
vecType const B(static_cast<T>(1));
|
||||
vecType const N(GLM_NAN(T));
|
||||
|
||||
Error += glm::all(glm::isnan(glm::max(N, B))) ? 0 : 1;
|
||||
Error += !glm::all(glm::isnan(glm::max(B, N))) ? 0 : 1;
|
||||
|
||||
vecType const C(static_cast<T>(2));
|
||||
Error += glm::all(glm::isnan(glm::max(N, B, C))) ? 0 : 1;
|
||||
Error += !glm::all(glm::isnan(glm::max(B, N, C))) ? 0 : 1;
|
||||
Error += !glm::all(glm::isnan(glm::max(C, N, B))) ? 0 : 1;
|
||||
Error += !glm::all(glm::isnan(glm::max(C, B, N))) ? 0 : 1;
|
||||
Error += !glm::all(glm::isnan(glm::max(B, C, N))) ? 0 : 1;
|
||||
Error += glm::all(glm::isnan(glm::max(N, C, B))) ? 0 : 1;
|
||||
|
||||
vecType const D(static_cast<T>(3));
|
||||
Error += !glm::all(glm::isnan(glm::max(D, N, B, C))) ? 0 : 1;
|
||||
Error += !glm::all(glm::isnan(glm::max(B, D, N, C))) ? 0 : 1;
|
||||
Error += !glm::all(glm::isnan(glm::max(C, N, D, B))) ? 0 : 1;
|
||||
Error += !glm::all(glm::isnan(glm::max(C, B, D, N))) ? 0 : 1;
|
||||
Error += !glm::all(glm::isnan(glm::max(B, C, N, D))) ? 0 : 1;
|
||||
Error += glm::all(glm::isnan(glm::max(N, C, B, D))) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
template <typename vecType>
|
||||
static int test_fmin()
|
||||
{
|
||||
typedef typename vecType::value_type T;
|
||||
|
||||
int Error = 0;
|
||||
|
||||
vecType const B(static_cast<T>(1));
|
||||
vecType const N(GLM_NAN(T));
|
||||
|
||||
Error += glm::all(glm::equal(glm::fmin(N, B), B, glm::epsilon<T>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(glm::fmin(B, N), B, glm::epsilon<T>())) ? 0 : 1;
|
||||
|
||||
vecType const C(static_cast<T>(2));
|
||||
Error += glm::all(glm::equal(glm::fmin(N, B, C), B, glm::epsilon<T>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(glm::fmin(B, N, C), B, glm::epsilon<T>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(glm::fmin(C, N, B), B, glm::epsilon<T>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(glm::fmin(C, B, N), B, glm::epsilon<T>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(glm::fmin(B, C, N), B, glm::epsilon<T>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(glm::fmin(N, C, B), B, glm::epsilon<T>())) ? 0 : 1;
|
||||
|
||||
vecType const D(static_cast<T>(3));
|
||||
Error += glm::all(glm::equal(glm::fmin(D, N, B, C), B, glm::epsilon<T>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(glm::fmin(B, D, N, C), B, glm::epsilon<T>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(glm::fmin(C, N, D, B), B, glm::epsilon<T>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(glm::fmin(C, B, D, N), B, glm::epsilon<T>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(glm::fmin(B, C, N, D), B, glm::epsilon<T>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(glm::fmin(N, C, B, D), B, glm::epsilon<T>())) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
template <typename vecType>
|
||||
static int test_fmax()
|
||||
{
|
||||
typedef typename vecType::value_type T;
|
||||
|
||||
int Error = 0;
|
||||
|
||||
vecType const B(static_cast<T>(1));
|
||||
vecType const N(GLM_NAN(T));
|
||||
|
||||
Error += glm::all(glm::equal(glm::fmax(N, B), B, glm::epsilon<T>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(glm::fmax(B, N), B, glm::epsilon<T>())) ? 0 : 1;
|
||||
|
||||
vecType const C(static_cast<T>(2));
|
||||
Error += glm::all(glm::equal(glm::fmax(N, B, C), C, glm::epsilon<T>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(glm::fmax(B, N, C), C, glm::epsilon<T>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(glm::fmax(C, N, B), C, glm::epsilon<T>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(glm::fmax(C, B, N), C, glm::epsilon<T>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(glm::fmax(B, C, N), C, glm::epsilon<T>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(glm::fmax(N, C, B), C, glm::epsilon<T>())) ? 0 : 1;
|
||||
|
||||
vecType const D(static_cast<T>(3));
|
||||
Error += glm::all(glm::equal(glm::fmax(D, N, B, C), D, glm::epsilon<T>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(glm::fmax(B, D, N, C), D, glm::epsilon<T>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(glm::fmax(C, N, D, B), D, glm::epsilon<T>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(glm::fmax(C, B, D, N), D, glm::epsilon<T>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(glm::fmax(B, C, N, D), D, glm::epsilon<T>())) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(glm::fmax(N, C, B, D), D, glm::epsilon<T>())) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += test_min<glm::vec3>();
|
||||
Error += test_min<glm::vec2>();
|
||||
Error += test_min_nan<glm::vec3>();
|
||||
Error += test_min_nan<glm::vec2>();
|
||||
|
||||
Error += test_max<glm::vec3>();
|
||||
Error += test_max<glm::vec2>();
|
||||
Error += test_max_nan<glm::vec3>();
|
||||
Error += test_max_nan<glm::vec2>();
|
||||
|
||||
Error += test_fmin<glm::vec3>();
|
||||
Error += test_fmin<glm::vec2>();
|
||||
|
||||
Error += test_fmax<glm::vec3>();
|
||||
Error += test_fmax<glm::vec2>();
|
||||
|
||||
return Error;
|
||||
}
|
||||
166
lib/glm/test/ext/ext_vector_iec559.cpp
Normal file
166
lib/glm/test/ext/ext_vector_iec559.cpp
Normal file
@@ -0,0 +1,166 @@
|
||||
#include <glm/gtc/constants.hpp>
|
||||
#include <glm/ext/scalar_relational.hpp>
|
||||
#include <glm/ext/vector_relational.hpp>
|
||||
#include <glm/ext/vector_double1.hpp>
|
||||
#include <glm/ext/vector_double1_precision.hpp>
|
||||
#include <glm/ext/vector_double2.hpp>
|
||||
#include <glm/ext/vector_double3.hpp>
|
||||
#include <glm/ext/vector_double4.hpp>
|
||||
#include <glm/ext/vector_float1.hpp>
|
||||
#include <glm/ext/vector_float1_precision.hpp>
|
||||
#include <glm/ext/vector_float2.hpp>
|
||||
#include <glm/ext/vector_float3.hpp>
|
||||
#include <glm/ext/vector_float4.hpp>
|
||||
|
||||
template <typename genType>
|
||||
static int test_operators()
|
||||
{
|
||||
typedef typename genType::value_type valType;
|
||||
|
||||
int Error = 0;
|
||||
|
||||
{
|
||||
genType const A(1);
|
||||
genType const B(1);
|
||||
|
||||
genType const C = A + B;
|
||||
Error += glm::all(glm::equal(C, genType(2), glm::epsilon<valType>())) ? 0 : 1;
|
||||
|
||||
genType const D = A - B;
|
||||
Error += glm::all(glm::equal(D, genType(0), glm::epsilon<valType>())) ? 0 : 1;
|
||||
|
||||
genType const E = A * B;
|
||||
Error += glm::all(glm::equal(E, genType(1), glm::epsilon<valType>())) ? 0 : 1;
|
||||
|
||||
genType const F = A / B;
|
||||
Error += glm::all(glm::equal(F, genType(1), glm::epsilon<valType>())) ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
static int test_ctor()
|
||||
{
|
||||
typedef typename genType::value_type T;
|
||||
|
||||
int Error = 0;
|
||||
|
||||
glm::vec<1, T> const A = genType(1);
|
||||
|
||||
glm::vec<1, T> const E(genType(1));
|
||||
Error += glm::all(glm::equal(A, E, glm::epsilon<T>())) ? 0 : 1;
|
||||
|
||||
glm::vec<1, T> const F(E);
|
||||
Error += glm::all(glm::equal(A, F, glm::epsilon<T>())) ? 0 : 1;
|
||||
|
||||
genType const B = genType(1);
|
||||
genType const G(glm::vec<2, T>(1));
|
||||
Error += glm::all(glm::equal(B, G, glm::epsilon<T>())) ? 0 : 1;
|
||||
|
||||
genType const H(glm::vec<3, T>(1));
|
||||
Error += glm::all(glm::equal(B, H, glm::epsilon<T>())) ? 0 : 1;
|
||||
|
||||
genType const I(glm::vec<4, T>(1));
|
||||
Error += glm::all(glm::equal(B, I, glm::epsilon<T>())) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
static int test_size()
|
||||
{
|
||||
typedef typename genType::value_type T;
|
||||
|
||||
int Error = 0;
|
||||
|
||||
Error += sizeof(glm::vec<1, T>) == sizeof(genType) ? 0 : 1;
|
||||
Error += genType().length() == 1 ? 0 : 1;
|
||||
Error += genType::length() == 1 ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
static int test_relational()
|
||||
{
|
||||
typedef typename genType::value_type valType;
|
||||
|
||||
int Error = 0;
|
||||
|
||||
genType const A(1);
|
||||
genType const B(1);
|
||||
genType const C(0);
|
||||
|
||||
Error += all(equal(A, B, glm::epsilon<valType>())) ? 0 : 1;
|
||||
Error += any(notEqual(A, C, glm::epsilon<valType>())) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
static int test_constexpr()
|
||||
{
|
||||
# if GLM_CONFIG_CONSTEXP == GLM_ENABLE
|
||||
static_assert(genType::length() == 1, "GLM: Failed constexpr");
|
||||
# endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += test_operators<glm::dvec1>();
|
||||
Error += test_operators<glm::lowp_dvec1>();
|
||||
Error += test_operators<glm::mediump_dvec1>();
|
||||
Error += test_operators<glm::highp_dvec1>();
|
||||
|
||||
Error += test_ctor<glm::dvec1>();
|
||||
Error += test_ctor<glm::lowp_dvec1>();
|
||||
Error += test_ctor<glm::mediump_dvec1>();
|
||||
Error += test_ctor<glm::highp_dvec1>();
|
||||
|
||||
Error += test_size<glm::dvec1>();
|
||||
Error += test_size<glm::lowp_dvec1>();
|
||||
Error += test_size<glm::mediump_dvec1>();
|
||||
Error += test_size<glm::highp_dvec1>();
|
||||
|
||||
Error += test_relational<glm::dvec1>();
|
||||
Error += test_relational<glm::lowp_dvec1>();
|
||||
Error += test_relational<glm::mediump_dvec1>();
|
||||
Error += test_relational<glm::highp_dvec1>();
|
||||
|
||||
Error += test_constexpr<glm::dvec1>();
|
||||
Error += test_constexpr<glm::lowp_dvec1>();
|
||||
Error += test_constexpr<glm::mediump_dvec1>();
|
||||
Error += test_constexpr<glm::highp_dvec1>();
|
||||
|
||||
Error += test_operators<glm::vec1>();
|
||||
Error += test_operators<glm::lowp_vec1>();
|
||||
Error += test_operators<glm::mediump_vec1>();
|
||||
Error += test_operators<glm::highp_vec1>();
|
||||
|
||||
Error += test_ctor<glm::vec1>();
|
||||
Error += test_ctor<glm::lowp_vec1>();
|
||||
Error += test_ctor<glm::mediump_vec1>();
|
||||
Error += test_ctor<glm::highp_vec1>();
|
||||
|
||||
Error += test_size<glm::vec1>();
|
||||
Error += test_size<glm::lowp_vec1>();
|
||||
Error += test_size<glm::mediump_vec1>();
|
||||
Error += test_size<glm::highp_vec1>();
|
||||
|
||||
Error += test_relational<glm::vec1>();
|
||||
Error += test_relational<glm::lowp_vec1>();
|
||||
Error += test_relational<glm::mediump_vec1>();
|
||||
Error += test_relational<glm::highp_vec1>();
|
||||
|
||||
Error += test_constexpr<glm::vec1>();
|
||||
Error += test_constexpr<glm::lowp_vec1>();
|
||||
Error += test_constexpr<glm::mediump_vec1>();
|
||||
Error += test_constexpr<glm::highp_vec1>();
|
||||
|
||||
return Error;
|
||||
}
|
||||
547
lib/glm/test/ext/ext_vector_integer.cpp
Normal file
547
lib/glm/test/ext/ext_vector_integer.cpp
Normal file
@@ -0,0 +1,547 @@
|
||||
#include <glm/ext/vector_integer.hpp>
|
||||
#include <glm/ext/scalar_int_sized.hpp>
|
||||
#include <glm/ext/scalar_uint_sized.hpp>
|
||||
#include <vector>
|
||||
#include <ctime>
|
||||
#include <cstdio>
|
||||
|
||||
namespace isPowerOfTwo
|
||||
{
|
||||
template<typename genType>
|
||||
struct type
|
||||
{
|
||||
genType Value;
|
||||
bool Return;
|
||||
};
|
||||
|
||||
template <glm::length_t L>
|
||||
int test_int16()
|
||||
{
|
||||
type<glm::int16> const Data[] =
|
||||
{
|
||||
{ 0x0001, true },
|
||||
{ 0x0002, true },
|
||||
{ 0x0004, true },
|
||||
{ 0x0080, true },
|
||||
{ 0x0000, true },
|
||||
{ 0x0003, false }
|
||||
};
|
||||
|
||||
int Error = 0;
|
||||
|
||||
for (std::size_t i = 0, n = sizeof(Data) / sizeof(type<glm::int16>); i < n; ++i)
|
||||
{
|
||||
glm::vec<L, bool> const Result = glm::isPowerOfTwo(glm::vec<L, glm::int16>(Data[i].Value));
|
||||
Error += glm::vec<L, bool>(Data[i].Return) == Result ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
template <glm::length_t L>
|
||||
int test_uint16()
|
||||
{
|
||||
type<glm::uint16> const Data[] =
|
||||
{
|
||||
{ 0x0001, true },
|
||||
{ 0x0002, true },
|
||||
{ 0x0004, true },
|
||||
{ 0x0000, true },
|
||||
{ 0x0000, true },
|
||||
{ 0x0003, false }
|
||||
};
|
||||
|
||||
int Error = 0;
|
||||
|
||||
for (std::size_t i = 0, n = sizeof(Data) / sizeof(type<glm::uint16>); i < n; ++i)
|
||||
{
|
||||
glm::vec<L, bool> const Result = glm::isPowerOfTwo(glm::vec<L, glm::uint16>(Data[i].Value));
|
||||
Error += glm::vec<L, bool>(Data[i].Return) == Result ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
template <glm::length_t L>
|
||||
int test_int32()
|
||||
{
|
||||
type<int> const Data[] =
|
||||
{
|
||||
{ 0x00000001, true },
|
||||
{ 0x00000002, true },
|
||||
{ 0x00000004, true },
|
||||
{ 0x0000000f, false },
|
||||
{ 0x00000000, true },
|
||||
{ 0x00000003, false }
|
||||
};
|
||||
|
||||
int Error = 0;
|
||||
|
||||
for (std::size_t i = 0, n = sizeof(Data) / sizeof(type<int>); i < n; ++i)
|
||||
{
|
||||
glm::vec<L, bool> const Result = glm::isPowerOfTwo(glm::vec<L, glm::int32>(Data[i].Value));
|
||||
Error += glm::vec<L, bool>(Data[i].Return) == Result ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
template <glm::length_t L>
|
||||
int test_uint32()
|
||||
{
|
||||
type<glm::uint> const Data[] =
|
||||
{
|
||||
{ 0x00000001, true },
|
||||
{ 0x00000002, true },
|
||||
{ 0x00000004, true },
|
||||
{ 0x80000000, true },
|
||||
{ 0x00000000, true },
|
||||
{ 0x00000003, false }
|
||||
};
|
||||
|
||||
int Error = 0;
|
||||
|
||||
for (std::size_t i = 0, n = sizeof(Data) / sizeof(type<glm::uint>); i < n; ++i)
|
||||
{
|
||||
glm::vec<L, bool> const Result = glm::isPowerOfTwo(glm::vec<L, glm::uint32>(Data[i].Value));
|
||||
Error += glm::vec<L, bool>(Data[i].Return) == Result ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += test_int16<1>();
|
||||
Error += test_int16<2>();
|
||||
Error += test_int16<3>();
|
||||
Error += test_int16<4>();
|
||||
|
||||
Error += test_uint16<1>();
|
||||
Error += test_uint16<2>();
|
||||
Error += test_uint16<3>();
|
||||
Error += test_uint16<4>();
|
||||
|
||||
Error += test_int32<1>();
|
||||
Error += test_int32<2>();
|
||||
Error += test_int32<3>();
|
||||
Error += test_int32<4>();
|
||||
|
||||
Error += test_uint32<1>();
|
||||
Error += test_uint32<2>();
|
||||
Error += test_uint32<3>();
|
||||
Error += test_uint32<4>();
|
||||
|
||||
return Error;
|
||||
}
|
||||
}//isPowerOfTwo
|
||||
|
||||
namespace prevPowerOfTwo
|
||||
{
|
||||
template <glm::length_t L, typename T>
|
||||
int run()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
glm::vec<L, T> const A = glm::prevPowerOfTwo(glm::vec<L, T>(7));
|
||||
Error += A == glm::vec<L, T>(4) ? 0 : 1;
|
||||
|
||||
glm::vec<L, T> const B = glm::prevPowerOfTwo(glm::vec<L, T>(15));
|
||||
Error += B == glm::vec<L, T>(8) ? 0 : 1;
|
||||
|
||||
glm::vec<L, T> const C = glm::prevPowerOfTwo(glm::vec<L, T>(31));
|
||||
Error += C == glm::vec<L, T>(16) ? 0 : 1;
|
||||
|
||||
glm::vec<L, T> const D = glm::prevPowerOfTwo(glm::vec<L, T>(32));
|
||||
Error += D == glm::vec<L, T>(32) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += run<1, glm::int8>();
|
||||
Error += run<2, glm::int8>();
|
||||
Error += run<3, glm::int8>();
|
||||
Error += run<4, glm::int8>();
|
||||
|
||||
Error += run<1, glm::int16>();
|
||||
Error += run<2, glm::int16>();
|
||||
Error += run<3, glm::int16>();
|
||||
Error += run<4, glm::int16>();
|
||||
|
||||
Error += run<1, glm::int32>();
|
||||
Error += run<2, glm::int32>();
|
||||
Error += run<3, glm::int32>();
|
||||
Error += run<4, glm::int32>();
|
||||
|
||||
Error += run<1, glm::int64>();
|
||||
Error += run<2, glm::int64>();
|
||||
Error += run<3, glm::int64>();
|
||||
Error += run<4, glm::int64>();
|
||||
|
||||
Error += run<1, glm::uint8>();
|
||||
Error += run<2, glm::uint8>();
|
||||
Error += run<3, glm::uint8>();
|
||||
Error += run<4, glm::uint8>();
|
||||
|
||||
Error += run<1, glm::uint16>();
|
||||
Error += run<2, glm::uint16>();
|
||||
Error += run<3, glm::uint16>();
|
||||
Error += run<4, glm::uint16>();
|
||||
|
||||
Error += run<1, glm::uint32>();
|
||||
Error += run<2, glm::uint32>();
|
||||
Error += run<3, glm::uint32>();
|
||||
Error += run<4, glm::uint32>();
|
||||
|
||||
Error += run<1, glm::uint64>();
|
||||
Error += run<2, glm::uint64>();
|
||||
Error += run<3, glm::uint64>();
|
||||
Error += run<4, glm::uint64>();
|
||||
|
||||
return Error;
|
||||
}
|
||||
}//namespace prevPowerOfTwo
|
||||
|
||||
namespace nextPowerOfTwo
|
||||
{
|
||||
template <glm::length_t L, typename T>
|
||||
int run()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
glm::vec<L, T> const A = glm::nextPowerOfTwo(glm::vec<L, T>(7));
|
||||
Error += A == glm::vec<L, T>(8) ? 0 : 1;
|
||||
|
||||
glm::vec<L, T> const B = glm::nextPowerOfTwo(glm::vec<L, T>(15));
|
||||
Error += B == glm::vec<L, T>(16) ? 0 : 1;
|
||||
|
||||
glm::vec<L, T> const C = glm::nextPowerOfTwo(glm::vec<L, T>(31));
|
||||
Error += C == glm::vec<L, T>(32) ? 0 : 1;
|
||||
|
||||
glm::vec<L, T> const D = glm::nextPowerOfTwo(glm::vec<L, T>(32));
|
||||
Error += D == glm::vec<L, T>(32) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += run<1, glm::int8>();
|
||||
Error += run<2, glm::int8>();
|
||||
Error += run<3, glm::int8>();
|
||||
Error += run<4, glm::int8>();
|
||||
|
||||
Error += run<1, glm::int16>();
|
||||
Error += run<2, glm::int16>();
|
||||
Error += run<3, glm::int16>();
|
||||
Error += run<4, glm::int16>();
|
||||
|
||||
Error += run<1, glm::int32>();
|
||||
Error += run<2, glm::int32>();
|
||||
Error += run<3, glm::int32>();
|
||||
Error += run<4, glm::int32>();
|
||||
|
||||
Error += run<1, glm::int64>();
|
||||
Error += run<2, glm::int64>();
|
||||
Error += run<3, glm::int64>();
|
||||
Error += run<4, glm::int64>();
|
||||
|
||||
Error += run<1, glm::uint8>();
|
||||
Error += run<2, glm::uint8>();
|
||||
Error += run<3, glm::uint8>();
|
||||
Error += run<4, glm::uint8>();
|
||||
|
||||
Error += run<1, glm::uint16>();
|
||||
Error += run<2, glm::uint16>();
|
||||
Error += run<3, glm::uint16>();
|
||||
Error += run<4, glm::uint16>();
|
||||
|
||||
Error += run<1, glm::uint32>();
|
||||
Error += run<2, glm::uint32>();
|
||||
Error += run<3, glm::uint32>();
|
||||
Error += run<4, glm::uint32>();
|
||||
|
||||
Error += run<1, glm::uint64>();
|
||||
Error += run<2, glm::uint64>();
|
||||
Error += run<3, glm::uint64>();
|
||||
Error += run<4, glm::uint64>();
|
||||
|
||||
return Error;
|
||||
}
|
||||
}//namespace nextPowerOfTwo
|
||||
|
||||
namespace prevMultiple
|
||||
{
|
||||
template<typename genIUType>
|
||||
struct type
|
||||
{
|
||||
genIUType Source;
|
||||
genIUType Multiple;
|
||||
genIUType Return;
|
||||
};
|
||||
|
||||
template <glm::length_t L, typename T>
|
||||
int run()
|
||||
{
|
||||
type<T> const Data[] =
|
||||
{
|
||||
{ 8, 3, 6 },
|
||||
{ 7, 7, 7 }
|
||||
};
|
||||
|
||||
int Error = 0;
|
||||
|
||||
for (std::size_t i = 0, n = sizeof(Data) / sizeof(type<T>); i < n; ++i)
|
||||
{
|
||||
glm::vec<L, T> const Result0 = glm::prevMultiple(glm::vec<L, T>(Data[i].Source), Data[i].Multiple);
|
||||
Error += glm::vec<L, T>(Data[i].Return) == Result0 ? 0 : 1;
|
||||
|
||||
glm::vec<L, T> const Result1 = glm::prevMultiple(glm::vec<L, T>(Data[i].Source), glm::vec<L, T>(Data[i].Multiple));
|
||||
Error += glm::vec<L, T>(Data[i].Return) == Result1 ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += run<1, glm::int8>();
|
||||
Error += run<2, glm::int8>();
|
||||
Error += run<3, glm::int8>();
|
||||
Error += run<4, glm::int8>();
|
||||
|
||||
Error += run<1, glm::int16>();
|
||||
Error += run<2, glm::int16>();
|
||||
Error += run<3, glm::int16>();
|
||||
Error += run<4, glm::int16>();
|
||||
|
||||
Error += run<1, glm::int32>();
|
||||
Error += run<2, glm::int32>();
|
||||
Error += run<3, glm::int32>();
|
||||
Error += run<4, glm::int32>();
|
||||
|
||||
Error += run<1, glm::int64>();
|
||||
Error += run<2, glm::int64>();
|
||||
Error += run<3, glm::int64>();
|
||||
Error += run<4, glm::int64>();
|
||||
|
||||
Error += run<1, glm::uint8>();
|
||||
Error += run<2, glm::uint8>();
|
||||
Error += run<3, glm::uint8>();
|
||||
Error += run<4, glm::uint8>();
|
||||
|
||||
Error += run<1, glm::uint16>();
|
||||
Error += run<2, glm::uint16>();
|
||||
Error += run<3, glm::uint16>();
|
||||
Error += run<4, glm::uint16>();
|
||||
|
||||
Error += run<1, glm::uint32>();
|
||||
Error += run<2, glm::uint32>();
|
||||
Error += run<3, glm::uint32>();
|
||||
Error += run<4, glm::uint32>();
|
||||
|
||||
Error += run<1, glm::uint64>();
|
||||
Error += run<2, glm::uint64>();
|
||||
Error += run<3, glm::uint64>();
|
||||
Error += run<4, glm::uint64>();
|
||||
|
||||
return Error;
|
||||
}
|
||||
}//namespace prevMultiple
|
||||
|
||||
namespace nextMultiple
|
||||
{
|
||||
template<typename genIUType>
|
||||
struct type
|
||||
{
|
||||
genIUType Source;
|
||||
genIUType Multiple;
|
||||
genIUType Return;
|
||||
};
|
||||
|
||||
template <glm::length_t L, typename T>
|
||||
int run()
|
||||
{
|
||||
type<T> const Data[] =
|
||||
{
|
||||
{ 3, 4, 4 },
|
||||
{ 6, 3, 6 },
|
||||
{ 5, 3, 6 },
|
||||
{ 7, 7, 7 },
|
||||
{ 0, 1, 0 },
|
||||
{ 8, 3, 9 }
|
||||
};
|
||||
|
||||
int Error = 0;
|
||||
|
||||
for (std::size_t i = 0, n = sizeof(Data) / sizeof(type<T>); i < n; ++i)
|
||||
{
|
||||
glm::vec<L, T> const Result0 = glm::nextMultiple(glm::vec<L, T>(Data[i].Source), glm::vec<L, T>(Data[i].Multiple));
|
||||
Error += glm::vec<L, T>(Data[i].Return) == Result0 ? 0 : 1;
|
||||
|
||||
glm::vec<L, T> const Result1 = glm::nextMultiple(glm::vec<L, T>(Data[i].Source), Data[i].Multiple);
|
||||
Error += glm::vec<L, T>(Data[i].Return) == Result1 ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += run<1, glm::int8>();
|
||||
Error += run<2, glm::int8>();
|
||||
Error += run<3, glm::int8>();
|
||||
Error += run<4, glm::int8>();
|
||||
|
||||
Error += run<1, glm::int16>();
|
||||
Error += run<2, glm::int16>();
|
||||
Error += run<3, glm::int16>();
|
||||
Error += run<4, glm::int16>();
|
||||
|
||||
Error += run<1, glm::int32>();
|
||||
Error += run<2, glm::int32>();
|
||||
Error += run<3, glm::int32>();
|
||||
Error += run<4, glm::int32>();
|
||||
|
||||
Error += run<1, glm::int64>();
|
||||
Error += run<2, glm::int64>();
|
||||
Error += run<3, glm::int64>();
|
||||
Error += run<4, glm::int64>();
|
||||
|
||||
Error += run<1, glm::uint8>();
|
||||
Error += run<2, glm::uint8>();
|
||||
Error += run<3, glm::uint8>();
|
||||
Error += run<4, glm::uint8>();
|
||||
|
||||
Error += run<1, glm::uint16>();
|
||||
Error += run<2, glm::uint16>();
|
||||
Error += run<3, glm::uint16>();
|
||||
Error += run<4, glm::uint16>();
|
||||
|
||||
Error += run<1, glm::uint32>();
|
||||
Error += run<2, glm::uint32>();
|
||||
Error += run<3, glm::uint32>();
|
||||
Error += run<4, glm::uint32>();
|
||||
|
||||
Error += run<1, glm::uint64>();
|
||||
Error += run<2, glm::uint64>();
|
||||
Error += run<3, glm::uint64>();
|
||||
Error += run<4, glm::uint64>();
|
||||
|
||||
return Error;
|
||||
}
|
||||
}//namespace nextMultiple
|
||||
|
||||
namespace findNSB
|
||||
{
|
||||
template<typename T>
|
||||
struct type
|
||||
{
|
||||
T Source;
|
||||
int SignificantBitCount;
|
||||
int Return;
|
||||
};
|
||||
|
||||
template <glm::length_t L, typename T>
|
||||
int run()
|
||||
{
|
||||
type<T> const Data[] =
|
||||
{
|
||||
{ 0x00, 1,-1 },
|
||||
{ 0x01, 2,-1 },
|
||||
{ 0x02, 2,-1 },
|
||||
{ 0x06, 3,-1 },
|
||||
{ 0x01, 1, 0 },
|
||||
{ 0x03, 1, 0 },
|
||||
{ 0x03, 2, 1 },
|
||||
{ 0x07, 2, 1 },
|
||||
{ 0x05, 2, 2 },
|
||||
{ 0x0D, 2, 2 }
|
||||
};
|
||||
|
||||
int Error = 0;
|
||||
|
||||
for (std::size_t i = 0, n = sizeof(Data) / sizeof(type<T>); i < n; ++i)
|
||||
{
|
||||
glm::vec<L, int> const Result0 = glm::findNSB<L, T, glm::defaultp>(glm::vec<L, T>(Data[i].Source), glm::vec<L, int>(Data[i].SignificantBitCount));
|
||||
Error += glm::vec<L, int>(Data[i].Return) == Result0 ? 0 : 1;
|
||||
assert(!Error);
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int test()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += run<1, glm::uint8>();
|
||||
Error += run<2, glm::uint8>();
|
||||
Error += run<3, glm::uint8>();
|
||||
Error += run<4, glm::uint8>();
|
||||
|
||||
Error += run<1, glm::uint16>();
|
||||
Error += run<2, glm::uint16>();
|
||||
Error += run<3, glm::uint16>();
|
||||
Error += run<4, glm::uint16>();
|
||||
|
||||
Error += run<1, glm::uint32>();
|
||||
Error += run<2, glm::uint32>();
|
||||
Error += run<3, glm::uint32>();
|
||||
Error += run<4, glm::uint32>();
|
||||
|
||||
Error += run<1, glm::uint64>();
|
||||
Error += run<2, glm::uint64>();
|
||||
Error += run<3, glm::uint64>();
|
||||
Error += run<4, glm::uint64>();
|
||||
|
||||
Error += run<1, glm::int8>();
|
||||
Error += run<2, glm::int8>();
|
||||
Error += run<3, glm::int8>();
|
||||
Error += run<4, glm::int8>();
|
||||
|
||||
Error += run<1, glm::int16>();
|
||||
Error += run<2, glm::int16>();
|
||||
Error += run<3, glm::int16>();
|
||||
Error += run<4, glm::int16>();
|
||||
|
||||
Error += run<1, glm::int32>();
|
||||
Error += run<2, glm::int32>();
|
||||
Error += run<3, glm::int32>();
|
||||
Error += run<4, glm::int32>();
|
||||
|
||||
Error += run<1, glm::int64>();
|
||||
Error += run<2, glm::int64>();
|
||||
Error += run<3, glm::int64>();
|
||||
Error += run<4, glm::int64>();
|
||||
|
||||
|
||||
return Error;
|
||||
}
|
||||
}//namespace findNSB
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += isPowerOfTwo::test();
|
||||
Error += prevPowerOfTwo::test();
|
||||
Error += nextPowerOfTwo::test();
|
||||
Error += prevMultiple::test();
|
||||
Error += nextMultiple::test();
|
||||
Error += findNSB::test();
|
||||
|
||||
return Error;
|
||||
}
|
||||
206
lib/glm/test/ext/ext_vector_integer_sized.cpp
Normal file
206
lib/glm/test/ext/ext_vector_integer_sized.cpp
Normal file
@@ -0,0 +1,206 @@
|
||||
#include <glm/ext/vector_integer.hpp>
|
||||
#include <glm/ext/vector_int1.hpp>
|
||||
#include <glm/ext/vector_int1_precision.hpp>
|
||||
#include <glm/ext/vector_uint1.hpp>
|
||||
#include <glm/ext/vector_uint1_precision.hpp>
|
||||
|
||||
template <typename genType>
|
||||
static int test_operators()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
{
|
||||
genType const A(1);
|
||||
genType const B(1);
|
||||
|
||||
bool const R = A != B;
|
||||
bool const S = A == B;
|
||||
Error += (S && !R) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
genType const A(1);
|
||||
genType const B(1);
|
||||
|
||||
genType const C = A + B;
|
||||
Error += C == genType(2) ? 0 : 1;
|
||||
|
||||
genType const D = A - B;
|
||||
Error += D == genType(0) ? 0 : 1;
|
||||
|
||||
genType const E = A * B;
|
||||
Error += E == genType(1) ? 0 : 1;
|
||||
|
||||
genType const F = A / B;
|
||||
Error += F == genType(1) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
genType const A(3);
|
||||
genType const B(2);
|
||||
|
||||
genType const C = A % B;
|
||||
Error += C == genType(1) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
genType const A(1);
|
||||
genType const B(1);
|
||||
genType const C(0);
|
||||
|
||||
genType const I = A & B;
|
||||
Error += I == genType(1) ? 0 : 1;
|
||||
genType const D = A & C;
|
||||
Error += D == genType(0) ? 0 : 1;
|
||||
|
||||
genType const E = A | B;
|
||||
Error += E == genType(1) ? 0 : 1;
|
||||
genType const F = A | C;
|
||||
Error += F == genType(1) ? 0 : 1;
|
||||
|
||||
genType const G = A ^ B;
|
||||
Error += G == genType(0) ? 0 : 1;
|
||||
genType const H = A ^ C;
|
||||
Error += H == genType(1) ? 0 : 1;
|
||||
}
|
||||
|
||||
{
|
||||
genType const A(0);
|
||||
genType const B(1);
|
||||
genType const C(2);
|
||||
|
||||
genType const D = B << B;
|
||||
Error += D == genType(2) ? 0 : 1;
|
||||
genType const E = C >> B;
|
||||
Error += E == genType(1) ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
static int test_ctor()
|
||||
{
|
||||
typedef typename genType::value_type T;
|
||||
|
||||
int Error = 0;
|
||||
|
||||
genType const A = genType(1);
|
||||
|
||||
genType const E(genType(1));
|
||||
Error += A == E ? 0 : 1;
|
||||
|
||||
genType const F(E);
|
||||
Error += A == F ? 0 : 1;
|
||||
|
||||
genType const B = genType(1);
|
||||
genType const G(glm::vec<2, T>(1));
|
||||
Error += B == G ? 0 : 1;
|
||||
|
||||
genType const H(glm::vec<3, T>(1));
|
||||
Error += B == H ? 0 : 1;
|
||||
|
||||
genType const I(glm::vec<4, T>(1));
|
||||
Error += B == I ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
static int test_size()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += sizeof(typename genType::value_type) == sizeof(genType) ? 0 : 1;
|
||||
Error += genType().length() == 1 ? 0 : 1;
|
||||
Error += genType::length() == 1 ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
static int test_relational()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
genType const A(1);
|
||||
genType const B(1);
|
||||
genType const C(0);
|
||||
|
||||
Error += A == B ? 0 : 1;
|
||||
Error += A != C ? 0 : 1;
|
||||
Error += all(equal(A, B)) ? 0 : 1;
|
||||
Error += any(notEqual(A, C)) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
static int test_constexpr()
|
||||
{
|
||||
# if GLM_CONFIG_CONSTEXP == GLM_ENABLE
|
||||
static_assert(genType::length() == 1, "GLM: Failed constexpr");
|
||||
static_assert(genType(1)[0] == 1, "GLM: Failed constexpr");
|
||||
static_assert(genType(1) == genType(1), "GLM: Failed constexpr");
|
||||
static_assert(genType(1) != genType(0), "GLM: Failed constexpr");
|
||||
# endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += test_operators<glm::ivec1>();
|
||||
Error += test_operators<glm::lowp_ivec1>();
|
||||
Error += test_operators<glm::mediump_ivec1>();
|
||||
Error += test_operators<glm::highp_ivec1>();
|
||||
|
||||
Error += test_ctor<glm::ivec1>();
|
||||
Error += test_ctor<glm::lowp_ivec1>();
|
||||
Error += test_ctor<glm::mediump_ivec1>();
|
||||
Error += test_ctor<glm::highp_ivec1>();
|
||||
|
||||
Error += test_size<glm::ivec1>();
|
||||
Error += test_size<glm::lowp_ivec1>();
|
||||
Error += test_size<glm::mediump_ivec1>();
|
||||
Error += test_size<glm::highp_ivec1>();
|
||||
|
||||
Error += test_relational<glm::ivec1>();
|
||||
Error += test_relational<glm::lowp_ivec1>();
|
||||
Error += test_relational<glm::mediump_ivec1>();
|
||||
Error += test_relational<glm::highp_ivec1>();
|
||||
|
||||
Error += test_constexpr<glm::ivec1>();
|
||||
Error += test_constexpr<glm::lowp_ivec1>();
|
||||
Error += test_constexpr<glm::mediump_ivec1>();
|
||||
Error += test_constexpr<glm::highp_ivec1>();
|
||||
|
||||
Error += test_operators<glm::uvec1>();
|
||||
Error += test_operators<glm::lowp_uvec1>();
|
||||
Error += test_operators<glm::mediump_uvec1>();
|
||||
Error += test_operators<glm::highp_uvec1>();
|
||||
|
||||
Error += test_ctor<glm::uvec1>();
|
||||
Error += test_ctor<glm::lowp_uvec1>();
|
||||
Error += test_ctor<glm::mediump_uvec1>();
|
||||
Error += test_ctor<glm::highp_uvec1>();
|
||||
|
||||
Error += test_size<glm::uvec1>();
|
||||
Error += test_size<glm::lowp_uvec1>();
|
||||
Error += test_size<glm::mediump_uvec1>();
|
||||
Error += test_size<glm::highp_uvec1>();
|
||||
|
||||
Error += test_relational<glm::uvec1>();
|
||||
Error += test_relational<glm::lowp_uvec1>();
|
||||
Error += test_relational<glm::mediump_uvec1>();
|
||||
Error += test_relational<glm::highp_uvec1>();
|
||||
|
||||
Error += test_constexpr<glm::uvec1>();
|
||||
Error += test_constexpr<glm::lowp_uvec1>();
|
||||
Error += test_constexpr<glm::mediump_uvec1>();
|
||||
Error += test_constexpr<glm::highp_uvec1>();
|
||||
|
||||
return Error;
|
||||
}
|
||||
205
lib/glm/test/ext/ext_vector_relational.cpp
Normal file
205
lib/glm/test/ext/ext_vector_relational.cpp
Normal file
@@ -0,0 +1,205 @@
|
||||
#include <glm/ext/vector_relational.hpp>
|
||||
#include <glm/ext/vector_float1.hpp>
|
||||
#include <glm/ext/vector_float1_precision.hpp>
|
||||
#include <glm/ext/vector_float2.hpp>
|
||||
#include <glm/ext/vector_float2_precision.hpp>
|
||||
#include <glm/ext/vector_float3.hpp>
|
||||
#include <glm/ext/vector_float3_precision.hpp>
|
||||
#include <glm/ext/vector_float4.hpp>
|
||||
#include <glm/ext/vector_float4_precision.hpp>
|
||||
#include <glm/ext/vector_double1.hpp>
|
||||
#include <glm/ext/vector_double1_precision.hpp>
|
||||
#include <glm/ext/vector_double2.hpp>
|
||||
#include <glm/ext/vector_double2_precision.hpp>
|
||||
#include <glm/ext/vector_double3.hpp>
|
||||
#include <glm/ext/vector_double3_precision.hpp>
|
||||
#include <glm/ext/vector_double4.hpp>
|
||||
#include <glm/ext/vector_double4_precision.hpp>
|
||||
#include <glm/ext/vector_ulp.hpp>
|
||||
|
||||
template <typename vecType>
|
||||
static int test_equal()
|
||||
{
|
||||
typedef typename vecType::value_type valType;
|
||||
|
||||
valType const A = static_cast<valType>(1.01f);
|
||||
valType const B = static_cast<valType>(1.02f);
|
||||
valType const Epsilon1 = static_cast<valType>(0.1f);
|
||||
valType const Epsilon2 = static_cast<valType>(0.001f);
|
||||
|
||||
int Error = 0;
|
||||
|
||||
Error += glm::all(glm::equal(vecType(A), vecType(B), Epsilon1)) ? 0 : 1;
|
||||
Error += glm::all(glm::equal(vecType(A), vecType(B), vecType(Epsilon1))) ? 0 : 1;
|
||||
|
||||
Error += !glm::any(glm::equal(vecType(A), vecType(B), Epsilon2)) ? 0 : 1;
|
||||
Error += !glm::any(glm::equal(vecType(A), vecType(B), vecType(Epsilon2))) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
template <typename vecType>
|
||||
static int test_notEqual()
|
||||
{
|
||||
typedef typename vecType::value_type valType;
|
||||
|
||||
valType const A = static_cast<valType>(1.01f);
|
||||
valType const B = static_cast<valType>(1.02f);
|
||||
valType const Epsilon1 = static_cast<valType>(0.1f);
|
||||
valType const Epsilon2 = static_cast<valType>(0.001f);
|
||||
|
||||
int Error = 0;
|
||||
|
||||
Error += glm::all(glm::notEqual(vecType(A), vecType(B), Epsilon2)) ? 0 : 1;
|
||||
Error += glm::all(glm::notEqual(vecType(A), vecType(B), vecType(Epsilon2))) ? 0 : 1;
|
||||
|
||||
Error += !glm::any(glm::notEqual(vecType(A), vecType(B), Epsilon1)) ? 0 : 1;
|
||||
Error += !glm::any(glm::notEqual(vecType(A), vecType(B), vecType(Epsilon1))) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
template <typename genType, typename valType>
|
||||
static int test_constexpr()
|
||||
{
|
||||
# if GLM_CONFIG_CONSTEXP == GLM_ENABLE
|
||||
static_assert(glm::all(glm::equal(genType(static_cast<valType>(1.01f)), genType(static_cast<valType>(1.02f)), static_cast<valType>(0.1f))), "GLM: Failed constexpr");
|
||||
# endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static int test_equal_ulps()
|
||||
{
|
||||
typedef glm::vec<4, T, glm::defaultp> vec4;
|
||||
|
||||
T const One(1);
|
||||
vec4 const Ones(1);
|
||||
|
||||
int Error = 0;
|
||||
|
||||
T const ULP1Plus = glm::nextFloat(One);
|
||||
Error += glm::all(glm::equal(Ones, vec4(ULP1Plus), 1)) ? 0 : 1;
|
||||
|
||||
T const ULP2Plus = glm::nextFloat(ULP1Plus);
|
||||
Error += !glm::all(glm::equal(Ones, vec4(ULP2Plus), 1)) ? 0 : 1;
|
||||
|
||||
T const ULP1Minus = glm::prevFloat(One);
|
||||
Error += glm::all(glm::equal(Ones, vec4(ULP1Minus), 1)) ? 0 : 1;
|
||||
|
||||
T const ULP2Minus = glm::prevFloat(ULP1Minus);
|
||||
Error += !glm::all(glm::equal(Ones, vec4(ULP2Minus), 1)) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static int test_notEqual_ulps()
|
||||
{
|
||||
typedef glm::vec<4, T, glm::defaultp> vec4;
|
||||
|
||||
T const One(1);
|
||||
vec4 const Ones(1);
|
||||
|
||||
int Error = 0;
|
||||
|
||||
T const ULP1Plus = glm::nextFloat(One);
|
||||
Error += !glm::all(glm::notEqual(Ones, vec4(ULP1Plus), 1)) ? 0 : 1;
|
||||
|
||||
T const ULP2Plus = glm::nextFloat(ULP1Plus);
|
||||
Error += glm::all(glm::notEqual(Ones, vec4(ULP2Plus), 1)) ? 0 : 1;
|
||||
|
||||
T const ULP1Minus = glm::prevFloat(One);
|
||||
Error += !glm::all(glm::notEqual(Ones, vec4(ULP1Minus), 1)) ? 0 : 1;
|
||||
|
||||
T const ULP2Minus = glm::prevFloat(ULP1Minus);
|
||||
Error += glm::all(glm::notEqual(Ones, vec4(ULP2Minus), 1)) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += test_equal_ulps<float>();
|
||||
Error += test_equal_ulps<double>();
|
||||
Error += test_notEqual_ulps<float>();
|
||||
Error += test_notEqual_ulps<double>();
|
||||
|
||||
Error += test_equal<glm::vec1>();
|
||||
Error += test_equal<glm::lowp_vec1>();
|
||||
Error += test_equal<glm::mediump_vec1>();
|
||||
Error += test_equal<glm::highp_vec1>();
|
||||
Error += test_equal<glm::vec2>();
|
||||
Error += test_equal<glm::lowp_vec2>();
|
||||
Error += test_equal<glm::mediump_vec2>();
|
||||
Error += test_equal<glm::highp_vec2>();
|
||||
Error += test_equal<glm::vec3>();
|
||||
Error += test_equal<glm::lowp_vec3>();
|
||||
Error += test_equal<glm::mediump_vec3>();
|
||||
Error += test_equal<glm::highp_vec3>();
|
||||
Error += test_equal<glm::vec4>();
|
||||
Error += test_equal<glm::lowp_vec4>();
|
||||
Error += test_equal<glm::mediump_vec4>();
|
||||
Error += test_equal<glm::highp_vec4>();
|
||||
|
||||
Error += test_equal<glm::dvec1>();
|
||||
Error += test_equal<glm::lowp_dvec1>();
|
||||
Error += test_equal<glm::mediump_dvec1>();
|
||||
Error += test_equal<glm::highp_dvec1>();
|
||||
Error += test_equal<glm::dvec2>();
|
||||
Error += test_equal<glm::lowp_dvec2>();
|
||||
Error += test_equal<glm::mediump_dvec2>();
|
||||
Error += test_equal<glm::highp_dvec2>();
|
||||
Error += test_equal<glm::dvec3>();
|
||||
Error += test_equal<glm::lowp_dvec3>();
|
||||
Error += test_equal<glm::mediump_dvec3>();
|
||||
Error += test_equal<glm::highp_dvec3>();
|
||||
Error += test_equal<glm::dvec4>();
|
||||
Error += test_equal<glm::lowp_dvec4>();
|
||||
Error += test_equal<glm::mediump_dvec4>();
|
||||
Error += test_equal<glm::highp_dvec4>();
|
||||
|
||||
Error += test_notEqual<glm::vec1>();
|
||||
Error += test_notEqual<glm::lowp_vec1>();
|
||||
Error += test_notEqual<glm::mediump_vec1>();
|
||||
Error += test_notEqual<glm::highp_vec1>();
|
||||
Error += test_notEqual<glm::vec2>();
|
||||
Error += test_notEqual<glm::lowp_vec2>();
|
||||
Error += test_notEqual<glm::mediump_vec2>();
|
||||
Error += test_notEqual<glm::highp_vec2>();
|
||||
Error += test_notEqual<glm::vec3>();
|
||||
Error += test_notEqual<glm::lowp_vec3>();
|
||||
Error += test_notEqual<glm::mediump_vec3>();
|
||||
Error += test_notEqual<glm::highp_vec3>();
|
||||
Error += test_notEqual<glm::vec4>();
|
||||
Error += test_notEqual<glm::lowp_vec4>();
|
||||
Error += test_notEqual<glm::mediump_vec4>();
|
||||
Error += test_notEqual<glm::highp_vec4>();
|
||||
|
||||
Error += test_notEqual<glm::dvec1>();
|
||||
Error += test_notEqual<glm::lowp_dvec1>();
|
||||
Error += test_notEqual<glm::mediump_dvec1>();
|
||||
Error += test_notEqual<glm::highp_dvec1>();
|
||||
Error += test_notEqual<glm::dvec2>();
|
||||
Error += test_notEqual<glm::lowp_dvec2>();
|
||||
Error += test_notEqual<glm::mediump_dvec2>();
|
||||
Error += test_notEqual<glm::highp_dvec2>();
|
||||
Error += test_notEqual<glm::dvec3>();
|
||||
Error += test_notEqual<glm::lowp_dvec3>();
|
||||
Error += test_notEqual<glm::mediump_dvec3>();
|
||||
Error += test_notEqual<glm::highp_dvec3>();
|
||||
Error += test_notEqual<glm::dvec4>();
|
||||
Error += test_notEqual<glm::lowp_dvec4>();
|
||||
Error += test_notEqual<glm::mediump_dvec4>();
|
||||
Error += test_notEqual<glm::highp_dvec4>();
|
||||
|
||||
Error += test_constexpr<glm::vec1, float>();
|
||||
Error += test_constexpr<glm::vec2, float>();
|
||||
Error += test_constexpr<glm::vec3, float>();
|
||||
Error += test_constexpr<glm::vec4, float>();
|
||||
|
||||
return Error;
|
||||
}
|
||||
99
lib/glm/test/ext/ext_vector_ulp.cpp
Normal file
99
lib/glm/test/ext/ext_vector_ulp.cpp
Normal file
@@ -0,0 +1,99 @@
|
||||
#include <glm/ext/vector_ulp.hpp>
|
||||
#include <glm/ext/vector_relational.hpp>
|
||||
#include <glm/ext/vector_float4.hpp>
|
||||
#include <glm/ext/vector_double4.hpp>
|
||||
#include <glm/ext/vector_int4.hpp>
|
||||
|
||||
static int test_ulp_float_dist()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
glm::vec4 const A(1.0f);
|
||||
|
||||
glm::vec4 const B = glm::nextFloat(A);
|
||||
Error += glm::any(glm::notEqual(A, B, 0)) ? 0 : 1;
|
||||
glm::vec4 const C = glm::prevFloat(B);
|
||||
Error += glm::all(glm::equal(A, C, 0)) ? 0 : 1;
|
||||
|
||||
glm::ivec4 const D = glm::floatDistance(A, B);
|
||||
Error += D == glm::ivec4(1) ? 0 : 1;
|
||||
glm::ivec4 const E = glm::floatDistance(A, C);
|
||||
Error += E == glm::ivec4(0) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_ulp_float_step()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
glm::vec4 const A(1.0f);
|
||||
|
||||
for(int i = 10; i < 1000; i *= 10)
|
||||
{
|
||||
glm::vec4 const B = glm::nextFloat(A, i);
|
||||
Error += glm::any(glm::notEqual(A, B, 0)) ? 0 : 1;
|
||||
glm::vec4 const C = glm::prevFloat(B, i);
|
||||
Error += glm::all(glm::equal(A, C, 0)) ? 0 : 1;
|
||||
|
||||
glm::ivec4 const D = glm::floatDistance(A, B);
|
||||
Error += D == glm::ivec4(i) ? 0 : 1;
|
||||
glm::ivec4 const E = glm::floatDistance(A, C);
|
||||
Error += E == glm::ivec4(0) ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_ulp_double_dist()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
glm::dvec4 const A(1.0);
|
||||
|
||||
glm::dvec4 const B = glm::nextFloat(A);
|
||||
Error += glm::any(glm::notEqual(A, B, 0)) ? 0 : 1;
|
||||
glm::dvec4 const C = glm::prevFloat(B);
|
||||
Error += glm::all(glm::equal(A, C, 0)) ? 0 : 1;
|
||||
|
||||
glm::ivec4 const D(glm::floatDistance(A, B));
|
||||
Error += D == glm::ivec4(1) ? 0 : 1;
|
||||
glm::ivec4 const E = glm::floatDistance(A, C);
|
||||
Error += E == glm::ivec4(0) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
static int test_ulp_double_step()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
glm::dvec4 const A(1.0);
|
||||
|
||||
for(int i = 10; i < 1000; i *= 10)
|
||||
{
|
||||
glm::dvec4 const B = glm::nextFloat(A, i);
|
||||
Error += glm::any(glm::notEqual(A, B, 0)) ? 0 : 1;
|
||||
glm::dvec4 const C = glm::prevFloat(B, i);
|
||||
Error += glm::all(glm::equal(A, C, 0)) ? 0 : 1;
|
||||
|
||||
glm::ivec4 const D(glm::floatDistance(A, B));
|
||||
Error += D == glm::ivec4(i) ? 0 : 1;
|
||||
glm::ivec4 const E(glm::floatDistance(A, C));
|
||||
Error += E == glm::ivec4(0) ? 0 : 1;
|
||||
}
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int Error = 0;
|
||||
|
||||
Error += test_ulp_float_dist();
|
||||
Error += test_ulp_float_step();
|
||||
Error += test_ulp_double_dist();
|
||||
Error += test_ulp_double_step();
|
||||
|
||||
return Error;
|
||||
}
|
||||
Reference in New Issue
Block a user