diff options
Diffstat (limited to '3rdparty/glm/source/test/ext')
59 files changed, 5584 insertions, 0 deletions
diff --git a/3rdparty/glm/source/test/ext/CMakeLists.txt b/3rdparty/glm/source/test/ext/CMakeLists.txt new file mode 100644 index 0000000..40c91ba --- /dev/null +++ b/3rdparty/glm/source/test/ext/CMakeLists.txt @@ -0,0 +1,55 @@ +glmCreateTestGTC(ext_matrix_relational) +glmCreateTestGTC(ext_matrix_transform) +glmCreateTestGTC(ext_matrix_common) +glmCreateTestGTC(ext_matrix_integer) +glmCreateTestGTC(ext_matrix_int2x2_sized) +glmCreateTestGTC(ext_matrix_int2x3_sized) +glmCreateTestGTC(ext_matrix_int2x4_sized) +glmCreateTestGTC(ext_matrix_int3x2_sized) +glmCreateTestGTC(ext_matrix_int3x3_sized) +glmCreateTestGTC(ext_matrix_int3x4_sized) +glmCreateTestGTC(ext_matrix_int4x2_sized) +glmCreateTestGTC(ext_matrix_int4x3_sized) +glmCreateTestGTC(ext_matrix_int4x4_sized) +glmCreateTestGTC(ext_matrix_uint2x2_sized) +glmCreateTestGTC(ext_matrix_uint2x3_sized) +glmCreateTestGTC(ext_matrix_uint2x4_sized) +glmCreateTestGTC(ext_matrix_uint3x2_sized) +glmCreateTestGTC(ext_matrix_uint3x3_sized) +glmCreateTestGTC(ext_matrix_uint3x4_sized) +glmCreateTestGTC(ext_matrix_uint4x2_sized) +glmCreateTestGTC(ext_matrix_uint4x3_sized) +glmCreateTestGTC(ext_matrix_uint4x4_sized) +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_reciprocal) +glmCreateTestGTC(ext_scalar_relational) +glmCreateTestGTC(ext_vec1) +glmCreateTestGTC(ext_vector_bool1) +glmCreateTestGTC(ext_vector_common) +glmCreateTestGTC(ext_vector_iec559) +glmCreateTestGTC(ext_vector_int1_sized) +glmCreateTestGTC(ext_vector_int2_sized) +glmCreateTestGTC(ext_vector_int3_sized) +glmCreateTestGTC(ext_vector_int4_sized) +glmCreateTestGTC(ext_vector_integer) +glmCreateTestGTC(ext_vector_integer_sized) +glmCreateTestGTC(ext_vector_uint1_sized) +glmCreateTestGTC(ext_vector_uint2_sized) +glmCreateTestGTC(ext_vector_uint3_sized) +glmCreateTestGTC(ext_vector_uint4_sized) +glmCreateTestGTC(ext_vector_reciprocal) +glmCreateTestGTC(ext_vector_relational) +glmCreateTestGTC(ext_vector_ulp) + diff --git a/3rdparty/glm/source/test/ext/ext_matrix_clip_space.cpp b/3rdparty/glm/source/test/ext/ext_matrix_clip_space.cpp new file mode 100644 index 0000000..ca84c19 --- /dev/null +++ b/3rdparty/glm/source/test/ext/ext_matrix_clip_space.cpp @@ -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; +} diff --git a/3rdparty/glm/source/test/ext/ext_matrix_common.cpp b/3rdparty/glm/source/test/ext/ext_matrix_common.cpp new file mode 100644 index 0000000..df0c3fe --- /dev/null +++ b/3rdparty/glm/source/test/ext/ext_matrix_common.cpp @@ -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; +} diff --git a/3rdparty/glm/source/test/ext/ext_matrix_int2x2_sized.cpp b/3rdparty/glm/source/test/ext/ext_matrix_int2x2_sized.cpp new file mode 100644 index 0000000..93b6e86 --- /dev/null +++ b/3rdparty/glm/source/test/ext/ext_matrix_int2x2_sized.cpp @@ -0,0 +1,28 @@ +#include <glm/ext/matrix_int2x2_sized.hpp> + +#if GLM_HAS_STATIC_ASSERT + static_assert(sizeof(glm::i8mat2x2) == 4, "int8 size isn't 1 byte on this platform"); + static_assert(sizeof(glm::i16mat2x2) == 8, "int16 size isn't 2 bytes on this platform"); + static_assert(sizeof(glm::i32mat2x2) == 16, "int32 size isn't 4 bytes on this platform"); + static_assert(sizeof(glm::i64mat2x2) == 32, "int64 size isn't 8 bytes on this platform"); +#endif + +static int test_comp() +{ + int Error = 0; + + Error += sizeof(glm::i8mat2x2) < sizeof(glm::i16mat2x2) ? 0 : 1; + Error += sizeof(glm::i16mat2x2) < sizeof(glm::i32mat2x2) ? 0 : 1; + Error += sizeof(glm::i32mat2x2) < sizeof(glm::i64mat2x2) ? 0 : 1; + + return Error; +} + +int main() +{ + int Error = 0; + + Error += test_comp(); + + return Error; +} diff --git a/3rdparty/glm/source/test/ext/ext_matrix_int2x3_sized.cpp b/3rdparty/glm/source/test/ext/ext_matrix_int2x3_sized.cpp new file mode 100644 index 0000000..058f57b --- /dev/null +++ b/3rdparty/glm/source/test/ext/ext_matrix_int2x3_sized.cpp @@ -0,0 +1,28 @@ +#include <glm/ext/matrix_int2x3_sized.hpp> + +#if GLM_HAS_STATIC_ASSERT +static_assert(sizeof(glm::i8mat2x3) == 6, "int8 size isn't 1 byte on this platform"); +static_assert(sizeof(glm::i16mat2x3) == 12, "int16 size isn't 2 bytes on this platform"); +static_assert(sizeof(glm::i32mat2x3) == 24, "int32 size isn't 4 bytes on this platform"); +static_assert(sizeof(glm::i64mat2x3) == 48, "int64 size isn't 8 bytes on this platform"); +#endif + +static int test_comp() +{ + int Error = 0; + + Error += sizeof(glm::i8mat2x3) < sizeof(glm::i16mat2x3) ? 0 : 1; + Error += sizeof(glm::i16mat2x3) < sizeof(glm::i32mat2x3) ? 0 : 1; + Error += sizeof(glm::i32mat2x3) < sizeof(glm::i64mat2x3) ? 0 : 1; + + return Error; +} + +int main() +{ + int Error = 0; + + Error += test_comp(); + + return Error; +} diff --git a/3rdparty/glm/source/test/ext/ext_matrix_int2x4_sized.cpp b/3rdparty/glm/source/test/ext/ext_matrix_int2x4_sized.cpp new file mode 100644 index 0000000..c20198d --- /dev/null +++ b/3rdparty/glm/source/test/ext/ext_matrix_int2x4_sized.cpp @@ -0,0 +1,28 @@ +#include <glm/ext/matrix_int2x4_sized.hpp> + +#if GLM_HAS_STATIC_ASSERT +static_assert(sizeof(glm::i8mat2x4) == 8, "int8 size isn't 1 byte on this platform"); +static_assert(sizeof(glm::i16mat2x4) == 16, "int16 size isn't 2 bytes on this platform"); +static_assert(sizeof(glm::i32mat2x4) == 32, "int32 size isn't 4 bytes on this platform"); +static_assert(sizeof(glm::i64mat2x4) == 64, "int64 size isn't 8 bytes on this platform"); +#endif + +static int test_comp() +{ + int Error = 0; + + Error += sizeof(glm::i8mat2x4) < sizeof(glm::i16mat2x4) ? 0 : 1; + Error += sizeof(glm::i16mat2x4) < sizeof(glm::i32mat2x4) ? 0 : 1; + Error += sizeof(glm::i32mat2x4) < sizeof(glm::i64mat2x4) ? 0 : 1; + + return Error; +} + +int main() +{ + int Error = 0; + + Error += test_comp(); + + return Error; +} diff --git a/3rdparty/glm/source/test/ext/ext_matrix_int3x2_sized.cpp b/3rdparty/glm/source/test/ext/ext_matrix_int3x2_sized.cpp new file mode 100644 index 0000000..1d14029 --- /dev/null +++ b/3rdparty/glm/source/test/ext/ext_matrix_int3x2_sized.cpp @@ -0,0 +1,28 @@ +#include <glm/ext/matrix_int3x2_sized.hpp> + +#if GLM_HAS_STATIC_ASSERT +static_assert(sizeof(glm::i8mat3x2) == 6, "int8 size isn't 1 byte on this platform"); +static_assert(sizeof(glm::i16mat3x2) == 12, "int16 size isn't 2 bytes on this platform"); +static_assert(sizeof(glm::i32mat3x2) == 24, "int32 size isn't 4 bytes on this platform"); +static_assert(sizeof(glm::i64mat3x2) == 48, "int64 size isn't 8 bytes on this platform"); +#endif + +static int test_comp() +{ + int Error = 0; + + Error += sizeof(glm::i8mat3x2) < sizeof(glm::i16mat3x2) ? 0 : 1; + Error += sizeof(glm::i16mat3x2) < sizeof(glm::i32mat3x2) ? 0 : 1; + Error += sizeof(glm::i32mat3x2) < sizeof(glm::i64mat3x2) ? 0 : 1; + + return Error; +} + +int main() +{ + int Error = 0; + + Error += test_comp(); + + return Error; +} diff --git a/3rdparty/glm/source/test/ext/ext_matrix_int3x3_sized.cpp b/3rdparty/glm/source/test/ext/ext_matrix_int3x3_sized.cpp new file mode 100644 index 0000000..d82836c --- /dev/null +++ b/3rdparty/glm/source/test/ext/ext_matrix_int3x3_sized.cpp @@ -0,0 +1,28 @@ +#include <glm/ext/matrix_int3x3_sized.hpp> + +#if GLM_HAS_STATIC_ASSERT +static_assert(sizeof(glm::i8mat3x3) == 9, "int8 size isn't 1 byte on this platform"); +static_assert(sizeof(glm::i16mat3x3) == 18, "int16 size isn't 2 bytes on this platform"); +static_assert(sizeof(glm::i32mat3x3) == 36, "int32 size isn't 4 bytes on this platform"); +static_assert(sizeof(glm::i64mat3x3) == 72, "int64 size isn't 8 bytes on this platform"); +#endif + +static int test_comp() +{ + int Error = 0; + + Error += sizeof(glm::i8mat3x3) < sizeof(glm::i16mat3x3) ? 0 : 1; + Error += sizeof(glm::i16mat3x3) < sizeof(glm::i32mat3x3) ? 0 : 1; + Error += sizeof(glm::i32mat3x3) < sizeof(glm::i64mat3x3) ? 0 : 1; + + return Error; +} + +int main() +{ + int Error = 0; + + Error += test_comp(); + + return Error; +} diff --git a/3rdparty/glm/source/test/ext/ext_matrix_int3x4_sized.cpp b/3rdparty/glm/source/test/ext/ext_matrix_int3x4_sized.cpp new file mode 100644 index 0000000..52b7d52 --- /dev/null +++ b/3rdparty/glm/source/test/ext/ext_matrix_int3x4_sized.cpp @@ -0,0 +1,28 @@ +#include <glm/ext/matrix_int3x4_sized.hpp> + +#if GLM_HAS_STATIC_ASSERT +static_assert(sizeof(glm::i8mat3x4) == 12, "int8 size isn't 1 byte on this platform"); +static_assert(sizeof(glm::i16mat3x4) == 24, "int16 size isn't 2 bytes on this platform"); +static_assert(sizeof(glm::i32mat3x4) == 48, "int32 size isn't 4 bytes on this platform"); +static_assert(sizeof(glm::i64mat3x4) == 96, "int64 size isn't 8 bytes on this platform"); +#endif + +static int test_comp() +{ + int Error = 0; + + Error += sizeof(glm::i8mat3x4) < sizeof(glm::i16mat3x4) ? 0 : 1; + Error += sizeof(glm::i16mat3x4) < sizeof(glm::i32mat3x4) ? 0 : 1; + Error += sizeof(glm::i32mat3x4) < sizeof(glm::i64mat3x4) ? 0 : 1; + + return Error; +} + +int main() +{ + int Error = 0; + + Error += test_comp(); + + return Error; +} diff --git a/3rdparty/glm/source/test/ext/ext_matrix_int4x2_sized.cpp b/3rdparty/glm/source/test/ext/ext_matrix_int4x2_sized.cpp new file mode 100644 index 0000000..3c4566f --- /dev/null +++ b/3rdparty/glm/source/test/ext/ext_matrix_int4x2_sized.cpp @@ -0,0 +1,28 @@ +#include <glm/ext/matrix_int4x2_sized.hpp> + +#if GLM_HAS_STATIC_ASSERT +static_assert(sizeof(glm::i8mat4x2) == 8, "int8 size isn't 1 byte on this platform"); +static_assert(sizeof(glm::i16mat4x2) == 16, "int16 size isn't 2 bytes on this platform"); +static_assert(sizeof(glm::i32mat4x2) == 32, "int32 size isn't 4 bytes on this platform"); +static_assert(sizeof(glm::i64mat4x2) == 64, "int64 size isn't 8 bytes on this platform"); +#endif + +static int test_comp() +{ + int Error = 0; + + Error += sizeof(glm::i8mat4x2) < sizeof(glm::i16mat4x2) ? 0 : 1; + Error += sizeof(glm::i16mat4x2) < sizeof(glm::i32mat4x2) ? 0 : 1; + Error += sizeof(glm::i32mat4x2) < sizeof(glm::i64mat4x2) ? 0 : 1; + + return Error; +} + +int main() +{ + int Error = 0; + + Error += test_comp(); + + return Error; +} diff --git a/3rdparty/glm/source/test/ext/ext_matrix_int4x3_sized.cpp b/3rdparty/glm/source/test/ext/ext_matrix_int4x3_sized.cpp new file mode 100644 index 0000000..fb882af --- /dev/null +++ b/3rdparty/glm/source/test/ext/ext_matrix_int4x3_sized.cpp @@ -0,0 +1,28 @@ +#include <glm/ext/matrix_int4x3_sized.hpp> + +#if GLM_HAS_STATIC_ASSERT +static_assert(sizeof(glm::i8mat4x3) == 12, "int8 size isn't 1 byte on this platform"); +static_assert(sizeof(glm::i16mat4x3) == 24, "int16 size isn't 2 bytes on this platform"); +static_assert(sizeof(glm::i32mat4x3) == 48, "int32 size isn't 4 bytes on this platform"); +static_assert(sizeof(glm::i64mat4x3) == 96, "int64 size isn't 8 bytes on this platform"); +#endif + +static int test_comp() +{ + int Error = 0; + + Error += sizeof(glm::i8mat4x3) < sizeof(glm::i16mat4x3) ? 0 : 1; + Error += sizeof(glm::i16mat4x3) < sizeof(glm::i32mat4x3) ? 0 : 1; + Error += sizeof(glm::i32mat4x3) < sizeof(glm::i64mat4x3) ? 0 : 1; + + return Error; +} + +int main() +{ + int Error = 0; + + Error += test_comp(); + + return Error; +} diff --git a/3rdparty/glm/source/test/ext/ext_matrix_int4x4_sized.cpp b/3rdparty/glm/source/test/ext/ext_matrix_int4x4_sized.cpp new file mode 100644 index 0000000..02769ea --- /dev/null +++ b/3rdparty/glm/source/test/ext/ext_matrix_int4x4_sized.cpp @@ -0,0 +1,28 @@ +#include <glm/ext/matrix_int4x4_sized.hpp> + +#if GLM_HAS_STATIC_ASSERT +static_assert(sizeof(glm::i8mat4x4) == 16, "int8 size isn't 1 byte on this platform"); +static_assert(sizeof(glm::i16mat4x4) == 32, "int16 size isn't 2 bytes on this platform"); +static_assert(sizeof(glm::i32mat4x4) == 64, "int32 size isn't 4 bytes on this platform"); +static_assert(sizeof(glm::i64mat4x4) == 128, "int64 size isn't 8 bytes on this platform"); +#endif + +static int test_comp() +{ + int Error = 0; + + Error += sizeof(glm::i8mat4x4) < sizeof(glm::i16mat4x4) ? 0 : 1; + Error += sizeof(glm::i16mat4x4) < sizeof(glm::i32mat4x4) ? 0 : 1; + Error += sizeof(glm::i32mat4x4) < sizeof(glm::i64mat4x4) ? 0 : 1; + + return Error; +} + +int main() +{ + int Error = 0; + + Error += test_comp(); + + return Error; +} diff --git a/3rdparty/glm/source/test/ext/ext_matrix_integer.cpp b/3rdparty/glm/source/test/ext/ext_matrix_integer.cpp new file mode 100644 index 0000000..c26d557 --- /dev/null +++ b/3rdparty/glm/source/test/ext/ext_matrix_integer.cpp @@ -0,0 +1,237 @@ +#include <glm/ext/matrix_relational.hpp> +#include <glm/ext/matrix_integer.hpp> +#include <glm/ext/matrix_int2x2.hpp> +#include <glm/ext/matrix_int2x3.hpp> +#include <glm/ext/matrix_int2x4.hpp> +#include <glm/ext/matrix_int3x2.hpp> +#include <glm/ext/matrix_int3x3.hpp> +#include <glm/ext/matrix_int3x4.hpp> +#include <glm/ext/matrix_int4x2.hpp> +#include <glm/ext/matrix_int4x3.hpp> +#include <glm/ext/matrix_int4x4.hpp> + +using namespace glm; + +int test_matrixCompMult() +{ + int Error = 0; + + { + imat2 m(0, 1, 2, 3); + imat2 n = matrixCompMult(m, m); + imat2 expected = imat2(0, 1, 4, 9); + Error += all(equal(n, expected)) ? 0 : 1; + } + + { + imat2x3 m(0, 1, 2, 3, 4, 5); + imat2x3 n = matrixCompMult(m, m); + imat2x3 expected = imat2x3(0, 1, 4, 9, 16, 25); + Error += all(equal(n, expected)) ? 0 : 1; + } + + { + imat2x4 m(0, 1, 2, 3, 4, 5, 6, 7); + imat2x4 n = matrixCompMult(m, m); + imat2x4 expected = imat2x4(0, 1, 4, 9, 16, 25, 36, 49); + Error += all(equal(n, expected)) ? 0 : 1; + } + + { + imat3 m(0, 1, 2, 3, 4, 5, 6, 7, 8); + imat3 n = matrixCompMult(m, m); + imat3 expected = imat3(0, 1, 4, 9, 16, 25, 36, 49, 64); + Error += all(equal(n, expected)) ? 0 : 1; + } + + { + imat3x2 m(0, 1, 2, 3, 4, 5); + imat3x2 n = matrixCompMult(m, m); + imat3x2 expected = imat3x2(0, 1, 4, 9, 16, 25); + Error += all(equal(n, expected)) ? 0 : 1; + } + + { + imat3x4 m(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11); + imat3x4 n = matrixCompMult(m, m); + imat3x4 expected = imat3x4(0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121); + Error += all(equal(n, expected)) ? 0 : 1; + } + + { + imat4 m(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); + imat4 n = matrixCompMult(m, m); + imat4 expected = imat4(0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225); + Error += all(equal(n, expected)) ? 0 : 1; + } + + { + imat4x2 m(0, 1, 2, 3, 4, 5, 6, 7); + imat4x2 n = matrixCompMult(m, m); + imat4x2 expected = imat4x2(0, 1, 4, 9, 16, 25, 36, 49); + Error += all(equal(n, expected)) ? 0 : 1; + } + + { + imat4x3 m(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11); + imat4x3 n = matrixCompMult(m, m); + imat4x3 expected = imat4x3(0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121); + Error += all(equal(n, expected)) ? 0 : 1; + } + + return Error; +} + +int test_outerProduct() +{ + int Error = 0; + + { + glm::imat2x2 const m = glm::outerProduct(glm::ivec2(1), glm::ivec2(1)); + Error += all(equal(m, glm::imat2x2(1, 1, 1, 1))) ? 0 : 1; + } + { + glm::imat2x3 const m = glm::outerProduct(glm::ivec3(1), glm::ivec2(1)); + Error += all(equal(m, glm::imat2x3(1, 1, 1, 1, 1, 1))) ? 0 : 1; + } + { + glm::imat2x4 const m = glm::outerProduct(glm::ivec4(1), glm::ivec2(1)); + Error += all(equal(m, glm::imat2x4(1, 1, 1, 1, 1, 1, 1, 1))) ? 0 : 1; + } + + { + glm::imat3x2 const m = glm::outerProduct(glm::ivec2(1), glm::ivec3(1)); + Error += all(equal(m, glm::imat3x2(1, 1, 1, 1, 1, 1))) ? 0 : 1; + } + { + glm::imat3x3 const m = glm::outerProduct(glm::ivec3(1), glm::ivec3(1)); + Error += all(equal(m, glm::imat3x3(1, 1, 1, 1, 1, 1, 1, 1, 1))) ? 0 : 1; + } + { + glm::imat3x4 const m = glm::outerProduct(glm::ivec4(1), glm::ivec3(1)); + Error += all(equal(m, glm::imat3x4(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1))) ? 0 : 1; + } + + + { + glm::imat4x2 const m = glm::outerProduct(glm::ivec2(1), glm::ivec4(1)); + Error += all(equal(m, glm::imat4x2(1, 1, 1, 1, 1, 1, 1, 1))) ? 0 : 1; + } + { + glm::imat4x3 const m = glm::outerProduct(glm::ivec3(1), glm::ivec4(1)); + Error += all(equal(m, glm::imat4x3(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1))) ? 0 : 1; + } + { + glm::imat4x4 const m = glm::outerProduct(glm::ivec4(1), glm::ivec4(1)); + Error += all(equal(m, glm::imat4x4(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1))) ? 0 : 1; + } + + return Error; +} + +int test_transpose() +{ + int Error = 0; + + { + imat2 const m(0, 1, 2, 3); + imat2 const t = transpose(m); + imat2 const expected = imat2(0, 2, 1, 3); + Error += all(equal(t, expected)) ? 0 : 1; + } + + { + imat2x3 m(0, 1, 2, 3, 4, 5); + imat3x2 t = transpose(m); + imat3x2 const expected = imat3x2(0, 3, 1, 4, 2, 5); + Error += all(equal(t, expected)) ? 0 : 1; + } + + { + imat2x4 m(0, 1, 2, 3, 4, 5, 6, 7); + imat4x2 t = transpose(m); + imat4x2 const expected = imat4x2(0, 4, 1, 5, 2, 6, 3, 7); + Error += all(equal(t, expected)) ? 0 : 1; + } + + { + imat3 m(0, 1, 2, 3, 4, 5, 6, 7, 8); + imat3 t = transpose(m); + imat3 const expected = imat3(0, 3, 6, 1, 4, 7, 2, 5, 8); + Error += all(equal(t, expected)) ? 0 : 1; + } + + { + imat3x2 m(0, 1, 2, 3, 4, 5); + imat2x3 t = transpose(m); + imat2x3 const expected = imat2x3(0, 2, 4, 1, 3, 5); + Error += all(equal(t, expected)) ? 0 : 1; + } + + { + imat3x4 m(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11); + imat4x3 t = transpose(m); + imat4x3 const expected = imat4x3(0, 4, 8, 1, 5, 9, 2, 6, 10, 3, 7, 11); + Error += all(equal(t, expected)) ? 0 : 1; + } + + { + imat4 m(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); + imat4 t = transpose(m); + imat4 const expected = imat4(0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15); + Error += all(equal(t, expected)) ? 0 : 1; + } + + { + imat4x2 m(0, 1, 2, 3, 4, 5, 6, 7); + imat2x4 t = transpose(m); + imat2x4 const expected = imat2x4(0, 2, 4, 6, 1, 3, 5, 7); + Error += all(equal(t, expected)) ? 0 : 1; + } + + { + imat4x3 m(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11); + imat3x4 t = transpose(m); + imat3x4 const expected = imat3x4(0, 3, 6, 9, 1, 4, 7, 10, 2, 5, 8, 11); + Error += all(equal(t, expected)) ? 0 : 1; + } + + return Error; +} + +int test_determinant() +{ + int Error = 0; + + { + imat2 const m(1, 1, 1, 1); + int const t = determinant(m); + Error += t == 0 ? 0 : 1; + } + + { + imat3 m(1, 1, 1, 1, 1, 1, 1, 1, 1); + int t = determinant(m); + Error += t == 0 ? 0 : 1; + } + + { + imat4 m(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); + int t = determinant(m); + Error += t == 0 ? 0 : 1; + } + + return Error; +} + +int main() +{ + int Error = 0; + + Error += test_matrixCompMult(); + Error += test_outerProduct(); + Error += test_transpose(); + Error += test_determinant(); + + return Error; +} diff --git a/3rdparty/glm/source/test/ext/ext_matrix_projection.cpp b/3rdparty/glm/source/test/ext/ext_matrix_projection.cpp new file mode 100644 index 0000000..88f6ae9 --- /dev/null +++ b/3rdparty/glm/source/test/ext/ext_matrix_projection.cpp @@ -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; +} diff --git a/3rdparty/glm/source/test/ext/ext_matrix_relational.cpp b/3rdparty/glm/source/test/ext/ext_matrix_relational.cpp new file mode 100644 index 0000000..64c0dae --- /dev/null +++ b/3rdparty/glm/source/test/ext/ext_matrix_relational.cpp @@ -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; +} diff --git a/3rdparty/glm/source/test/ext/ext_matrix_transform.cpp b/3rdparty/glm/source/test/ext/ext_matrix_transform.cpp new file mode 100644 index 0000000..cf653b7 --- /dev/null +++ b/3rdparty/glm/source/test/ext/ext_matrix_transform.cpp @@ -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; +} diff --git a/3rdparty/glm/source/test/ext/ext_matrix_uint2x2_sized.cpp b/3rdparty/glm/source/test/ext/ext_matrix_uint2x2_sized.cpp new file mode 100644 index 0000000..a9bd49c --- /dev/null +++ b/3rdparty/glm/source/test/ext/ext_matrix_uint2x2_sized.cpp @@ -0,0 +1,28 @@ +#include <glm/ext/matrix_uint2x2_sized.hpp> + +#if GLM_HAS_STATIC_ASSERT + static_assert(sizeof(glm::u8mat2x2) == 4, "uint8 size isn't 1 byte on this platform"); + static_assert(sizeof(glm::u16mat2x2) == 8, "uint16 size isn't 2 bytes on this platform"); + static_assert(sizeof(glm::u32mat2x2) == 16, "uint32 size isn't 4 bytes on this platform"); + static_assert(sizeof(glm::u64mat2x2) == 32, "uint64 size isn't 8 bytes on this platform"); +#endif + +static int test_comp() +{ + int Error = 0; + + Error += sizeof(glm::u8mat2x2) < sizeof(glm::u16mat2x2) ? 0 : 1; + Error += sizeof(glm::u16mat2x2) < sizeof(glm::u32mat2x2) ? 0 : 1; + Error += sizeof(glm::u32mat2x2) < sizeof(glm::u64mat2x2) ? 0 : 1; + + return Error; +} + +int main() +{ + int Error = 0; + + Error += test_comp(); + + return Error; +} diff --git a/3rdparty/glm/source/test/ext/ext_matrix_uint2x3_sized.cpp b/3rdparty/glm/source/test/ext/ext_matrix_uint2x3_sized.cpp new file mode 100644 index 0000000..0b75893 --- /dev/null +++ b/3rdparty/glm/source/test/ext/ext_matrix_uint2x3_sized.cpp @@ -0,0 +1,28 @@ +#include <glm/ext/matrix_uint2x3_sized.hpp> + +#if GLM_HAS_STATIC_ASSERT +static_assert(sizeof(glm::u8mat2x3) == 6, "uint8 size isn't 1 byte on this platform"); +static_assert(sizeof(glm::u16mat2x3) == 12, "uint16 size isn't 2 bytes on this platform"); +static_assert(sizeof(glm::u32mat2x3) == 24, "uint32 size isn't 4 bytes on this platform"); +static_assert(sizeof(glm::u64mat2x3) == 48, "uint64 size isn't 8 bytes on this platform"); +#endif + +static int test_comp() +{ + int Error = 0; + + Error += sizeof(glm::u8mat2x3) < sizeof(glm::u16mat2x3) ? 0 : 1; + Error += sizeof(glm::u16mat2x3) < sizeof(glm::u32mat2x3) ? 0 : 1; + Error += sizeof(glm::u32mat2x3) < sizeof(glm::u64mat2x3) ? 0 : 1; + + return Error; +} + +int main() +{ + int Error = 0; + + Error += test_comp(); + + return Error; +} diff --git a/3rdparty/glm/source/test/ext/ext_matrix_uint2x4_sized.cpp b/3rdparty/glm/source/test/ext/ext_matrix_uint2x4_sized.cpp new file mode 100644 index 0000000..84af4dd --- /dev/null +++ b/3rdparty/glm/source/test/ext/ext_matrix_uint2x4_sized.cpp @@ -0,0 +1,28 @@ +#include <glm/ext/matrix_uint2x4_sized.hpp> + +#if GLM_HAS_STATIC_ASSERT +static_assert(sizeof(glm::u8mat2x4) == 8, "uint8 size isn't 1 byte on this platform"); +static_assert(sizeof(glm::u16mat2x4) == 16, "uint16 size isn't 2 bytes on this platform"); +static_assert(sizeof(glm::u32mat2x4) == 32, "uint32 size isn't 4 bytes on this platform"); +static_assert(sizeof(glm::u64mat2x4) == 64, "uint64 size isn't 8 bytes on this platform"); +#endif + +static int test_comp() +{ + int Error = 0; + + Error += sizeof(glm::u8mat2x4) < sizeof(glm::u16mat2x4) ? 0 : 1; + Error += sizeof(glm::u16mat2x4) < sizeof(glm::u32mat2x4) ? 0 : 1; + Error += sizeof(glm::u32mat2x4) < sizeof(glm::u64mat2x4) ? 0 : 1; + + return Error; +} + +int main() +{ + int Error = 0; + + Error += test_comp(); + + return Error; +} diff --git a/3rdparty/glm/source/test/ext/ext_matrix_uint3x2_sized.cpp b/3rdparty/glm/source/test/ext/ext_matrix_uint3x2_sized.cpp new file mode 100644 index 0000000..3c035e2 --- /dev/null +++ b/3rdparty/glm/source/test/ext/ext_matrix_uint3x2_sized.cpp @@ -0,0 +1,28 @@ +#include <glm/ext/matrix_uint3x2_sized.hpp> + +#if GLM_HAS_STATIC_ASSERT +static_assert(sizeof(glm::u8mat3x2) == 6, "uint8 size isn't 1 byte on this platform"); +static_assert(sizeof(glm::u16mat3x2) == 12, "uint16 size isn't 2 bytes on this platform"); +static_assert(sizeof(glm::u32mat3x2) == 24, "uint32 size isn't 4 bytes on this platform"); +static_assert(sizeof(glm::u64mat3x2) == 48, "uint64 size isn't 8 bytes on this platform"); +#endif + +static int test_comp() +{ + int Error = 0; + + Error += sizeof(glm::u8mat3x2) < sizeof(glm::u16mat3x2) ? 0 : 1; + Error += sizeof(glm::u16mat3x2) < sizeof(glm::u32mat3x2) ? 0 : 1; + Error += sizeof(glm::u32mat3x2) < sizeof(glm::u64mat3x2) ? 0 : 1; + + return Error; +} + +int main() +{ + int Error = 0; + + Error += test_comp(); + + return Error; +} diff --git a/3rdparty/glm/source/test/ext/ext_matrix_uint3x3_sized.cpp b/3rdparty/glm/source/test/ext/ext_matrix_uint3x3_sized.cpp new file mode 100644 index 0000000..64384ed --- /dev/null +++ b/3rdparty/glm/source/test/ext/ext_matrix_uint3x3_sized.cpp @@ -0,0 +1,28 @@ +#include <glm/ext/matrix_uint3x3_sized.hpp> + +#if GLM_HAS_STATIC_ASSERT +static_assert(sizeof(glm::u8mat3x3) == 9, "uint8 size isn't 1 byte on this platform"); +static_assert(sizeof(glm::u16mat3x3) == 18, "uint16 size isn't 2 bytes on this platform"); +static_assert(sizeof(glm::u32mat3x3) == 36, "uint32 size isn't 4 bytes on this platform"); +static_assert(sizeof(glm::u64mat3x3) == 72, "uint64 size isn't 8 bytes on this platform"); +#endif + +static int test_comp() +{ + int Error = 0; + + Error += sizeof(glm::u8mat3x3) < sizeof(glm::u16mat3x3) ? 0 : 1; + Error += sizeof(glm::u16mat3x3) < sizeof(glm::u32mat3x3) ? 0 : 1; + Error += sizeof(glm::u32mat3x3) < sizeof(glm::u64mat3x3) ? 0 : 1; + + return Error; +} + +int main() +{ + int Error = 0; + + Error += test_comp(); + + return Error; +} diff --git a/3rdparty/glm/source/test/ext/ext_matrix_uint3x4_sized.cpp b/3rdparty/glm/source/test/ext/ext_matrix_uint3x4_sized.cpp new file mode 100644 index 0000000..7f743df --- /dev/null +++ b/3rdparty/glm/source/test/ext/ext_matrix_uint3x4_sized.cpp @@ -0,0 +1,28 @@ +#include <glm/ext/matrix_uint3x4_sized.hpp> + +#if GLM_HAS_STATIC_ASSERT +static_assert(sizeof(glm::u8mat3x4) == 12, "uint8 size isn't 1 byte on this platform"); +static_assert(sizeof(glm::u16mat3x4) == 24, "uint16 size isn't 2 bytes on this platform"); +static_assert(sizeof(glm::u32mat3x4) == 48, "uint32 size isn't 4 bytes on this platform"); +static_assert(sizeof(glm::u64mat3x4) == 96, "uint64 size isn't 8 bytes on this platform"); +#endif + +static int test_comp() +{ + int Error = 0; + + Error += sizeof(glm::u8mat3x4) < sizeof(glm::u16mat3x4) ? 0 : 1; + Error += sizeof(glm::u16mat3x4) < sizeof(glm::u32mat3x4) ? 0 : 1; + Error += sizeof(glm::u32mat3x4) < sizeof(glm::u64mat3x4) ? 0 : 1; + + return Error; +} + +int main() +{ + int Error = 0; + + Error += test_comp(); + + return Error; +} diff --git a/3rdparty/glm/source/test/ext/ext_matrix_uint4x2_sized.cpp b/3rdparty/glm/source/test/ext/ext_matrix_uint4x2_sized.cpp new file mode 100644 index 0000000..2b4453f --- /dev/null +++ b/3rdparty/glm/source/test/ext/ext_matrix_uint4x2_sized.cpp @@ -0,0 +1,28 @@ +#include <glm/ext/matrix_uint4x2_sized.hpp> + +#if GLM_HAS_STATIC_ASSERT +static_assert(sizeof(glm::u8mat4x2) == 8, "uint8 size isn't 1 byte on this platform"); +static_assert(sizeof(glm::u16mat4x2) == 16, "uint16 size isn't 2 bytes on this platform"); +static_assert(sizeof(glm::u32mat4x2) == 32, "uint32 size isn't 4 bytes on this platform"); +static_assert(sizeof(glm::u64mat4x2) == 64, "uint64 size isn't 8 bytes on this platform"); +#endif + +static int test_comp() +{ + int Error = 0; + + Error += sizeof(glm::u8mat4x2) < sizeof(glm::u16mat4x2) ? 0 : 1; + Error += sizeof(glm::u16mat4x2) < sizeof(glm::u32mat4x2) ? 0 : 1; + Error += sizeof(glm::u32mat4x2) < sizeof(glm::u64mat4x2) ? 0 : 1; + + return Error; +} + +int main() +{ + int Error = 0; + + Error += test_comp(); + + return Error; +} diff --git a/3rdparty/glm/source/test/ext/ext_matrix_uint4x3_sized.cpp b/3rdparty/glm/source/test/ext/ext_matrix_uint4x3_sized.cpp new file mode 100644 index 0000000..2820bde --- /dev/null +++ b/3rdparty/glm/source/test/ext/ext_matrix_uint4x3_sized.cpp @@ -0,0 +1,28 @@ +#include <glm/ext/matrix_uint4x3_sized.hpp> + +#if GLM_HAS_STATIC_ASSERT +static_assert(sizeof(glm::u8mat4x3) == 12, "uint8 size isn't 1 byte on this platform"); +static_assert(sizeof(glm::u16mat4x3) == 24, "uint16 size isn't 2 bytes on this platform"); +static_assert(sizeof(glm::u32mat4x3) == 48, "uint32 size isn't 4 bytes on this platform"); +static_assert(sizeof(glm::u64mat4x3) == 96, "uint64 size isn't 8 bytes on this platform"); +#endif + +static int test_comp() +{ + int Error = 0; + + Error += sizeof(glm::u8mat4x3) < sizeof(glm::u16mat4x3) ? 0 : 1; + Error += sizeof(glm::u16mat4x3) < sizeof(glm::u32mat4x3) ? 0 : 1; + Error += sizeof(glm::u32mat4x3) < sizeof(glm::u64mat4x3) ? 0 : 1; + + return Error; +} + +int main() +{ + int Error = 0; + + Error += test_comp(); + + return Error; +} diff --git a/3rdparty/glm/source/test/ext/ext_matrix_uint4x4_sized.cpp b/3rdparty/glm/source/test/ext/ext_matrix_uint4x4_sized.cpp new file mode 100644 index 0000000..8f9e239 --- /dev/null +++ b/3rdparty/glm/source/test/ext/ext_matrix_uint4x4_sized.cpp @@ -0,0 +1,28 @@ +#include <glm/ext/matrix_uint4x4_sized.hpp> + +#if GLM_HAS_STATIC_ASSERT +static_assert(sizeof(glm::u8mat4x4) == 16, "uint8 size isn't 1 byte on this platform"); +static_assert(sizeof(glm::u16mat4x4) == 32, "uint16 size isn't 2 bytes on this platform"); +static_assert(sizeof(glm::u32mat4x4) == 64, "uint32 size isn't 4 bytes on this platform"); +static_assert(sizeof(glm::u64mat4x4) == 128, "uint64 size isn't 8 bytes on this platform"); +#endif + +static int test_comp() +{ + int Error = 0; + + Error += sizeof(glm::u8mat4x4) < sizeof(glm::u16mat4x4) ? 0 : 1; + Error += sizeof(glm::u16mat4x4) < sizeof(glm::u32mat4x4) ? 0 : 1; + Error += sizeof(glm::u32mat4x4) < sizeof(glm::u64mat4x4) ? 0 : 1; + + return Error; +} + +int main() +{ + int Error = 0; + + Error += test_comp(); + + return Error; +} diff --git a/3rdparty/glm/source/test/ext/ext_quaternion_common.cpp b/3rdparty/glm/source/test/ext/ext_quaternion_common.cpp new file mode 100644 index 0000000..861aa65 --- /dev/null +++ b/3rdparty/glm/source/test/ext/ext_quaternion_common.cpp @@ -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; +} diff --git a/3rdparty/glm/source/test/ext/ext_quaternion_exponential.cpp b/3rdparty/glm/source/test/ext/ext_quaternion_exponential.cpp new file mode 100644 index 0000000..fbcdbef --- /dev/null +++ b/3rdparty/glm/source/test/ext/ext_quaternion_exponential.cpp @@ -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; +} diff --git a/3rdparty/glm/source/test/ext/ext_quaternion_geometric.cpp b/3rdparty/glm/source/test/ext/ext_quaternion_geometric.cpp new file mode 100644 index 0000000..73b5dea --- /dev/null +++ b/3rdparty/glm/source/test/ext/ext_quaternion_geometric.cpp @@ -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; +} diff --git a/3rdparty/glm/source/test/ext/ext_quaternion_relational.cpp b/3rdparty/glm/source/test/ext/ext_quaternion_relational.cpp new file mode 100644 index 0000000..7f51fdc --- /dev/null +++ b/3rdparty/glm/source/test/ext/ext_quaternion_relational.cpp @@ -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; +} diff --git a/3rdparty/glm/source/test/ext/ext_quaternion_transform.cpp b/3rdparty/glm/source/test/ext/ext_quaternion_transform.cpp new file mode 100644 index 0000000..fefe88e --- /dev/null +++ b/3rdparty/glm/source/test/ext/ext_quaternion_transform.cpp @@ -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; +} diff --git a/3rdparty/glm/source/test/ext/ext_quaternion_trigonometric.cpp b/3rdparty/glm/source/test/ext/ext_quaternion_trigonometric.cpp new file mode 100644 index 0000000..d237125 --- /dev/null +++ b/3rdparty/glm/source/test/ext/ext_quaternion_trigonometric.cpp @@ -0,0 +1,40 @@ +#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; + } + + { + glm::quat const Q = glm::angleAxis(glm::two_pi<float>() - 1.0f, glm::vec3(1, 0, 0)); + float const A = glm::angle(Q); + Error += glm::equal(A, 1.0f, Epsilon) ? 1 : 0; + } + + return Error; +} + +int main() +{ + int Error = 0; + + Error += test_angle(); + + return Error; +} diff --git a/3rdparty/glm/source/test/ext/ext_quaternion_type.cpp b/3rdparty/glm/source/test/ext/ext_quaternion_type.cpp new file mode 100644 index 0000000..7e61149 --- /dev/null +++ b/3rdparty/glm/source/test/ext/ext_quaternion_type.cpp @@ -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; +} diff --git a/3rdparty/glm/source/test/ext/ext_scalar_common.cpp b/3rdparty/glm/source/test/ext/ext_scalar_common.cpp new file mode 100644 index 0000000..917a242 --- /dev/null +++ b/3rdparty/glm/source/test/ext/ext_scalar_common.cpp @@ -0,0 +1,360 @@ +#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; +} + +static int test_clamp() +{ + int Error = 0; + + float A = glm::clamp(0.5f); + Error += glm::equal(A, 0.5f, 0.00001f) ? 0 : 1; + + float B = glm::clamp(0.0f); + Error += glm::equal(B, 0.0f, 0.00001f) ? 0 : 1; + + float C = glm::clamp(1.0f); + Error += glm::equal(C, 1.0f, 0.00001f) ? 0 : 1; + + float D = glm::clamp(-0.5f); + Error += glm::equal(D, 0.0f, 0.00001f) ? 0 : 1; + + float E = glm::clamp(1.5f); + Error += glm::equal(E, 1.0f, 0.00001f) ? 0 : 1; + + return Error; +} + +static int test_repeat() +{ + int Error = 0; + + float A = glm::repeat(0.5f); + Error += glm::equal(A, 0.5f, 0.00001f) ? 0 : 1; + + float B = glm::repeat(0.0f); + Error += glm::equal(B, 0.0f, 0.00001f) ? 0 : 1; + + float C = glm::repeat(1.0f); + Error += glm::equal(C, 0.0f, 0.00001f) ? 0 : 1; + + float D = glm::repeat(-0.5f); + Error += glm::equal(D, 0.5f, 0.00001f) ? 0 : 1; + + float E = glm::repeat(1.5f); + Error += glm::equal(E, 0.5f, 0.00001f) ? 0 : 1; + + float F = glm::repeat(0.9f); + Error += glm::equal(F, 0.9f, 0.00001f) ? 0 : 1; + + return Error; +} + +static int test_mirrorClamp() +{ + int Error = 0; + + float A = glm::mirrorClamp(0.5f); + Error += glm::equal(A, 0.5f, 0.00001f) ? 0 : 1; + + float B = glm::mirrorClamp(0.0f); + Error += glm::equal(B, 0.0f, 0.00001f) ? 0 : 1; + + float C = glm::mirrorClamp(1.1f); + Error += glm::equal(C, 0.1f, 0.00001f) ? 0 : 1; + + float D = glm::mirrorClamp(-0.5f); + Error += glm::equal(D, 0.5f, 0.00001f) ? 0 : 1; + + float E = glm::mirrorClamp(1.5f); + Error += glm::equal(E, 0.5f, 0.00001f) ? 0 : 1; + + float F = glm::mirrorClamp(0.9f); + Error += glm::equal(F, 0.9f, 0.00001f) ? 0 : 1; + + float G = glm::mirrorClamp(3.1f); + Error += glm::equal(G, 0.1f, 0.00001f) ? 0 : 1; + + float H = glm::mirrorClamp(-3.1f); + Error += glm::equal(H, 0.1f, 0.00001f) ? 0 : 1; + + float I = glm::mirrorClamp(-0.9f); + Error += glm::equal(I, 0.9f, 0.00001f) ? 0 : 1; + + return Error; +} + +static int test_mirrorRepeat() +{ + int Error = 0; + + float A = glm::mirrorRepeat(0.5f); + Error += glm::equal(A, 0.5f, 0.00001f) ? 0 : 1; + + float B = glm::mirrorRepeat(0.0f); + Error += glm::equal(B, 0.0f, 0.00001f) ? 0 : 1; + + float C = glm::mirrorRepeat(1.0f); + Error += glm::equal(C, 1.0f, 0.00001f) ? 0 : 1; + + float D = glm::mirrorRepeat(-0.5f); + Error += glm::equal(D, 0.5f, 0.00001f) ? 0 : 1; + + float E = glm::mirrorRepeat(1.5f); + Error += glm::equal(E, 0.5f, 0.00001f) ? 0 : 1; + + float F = glm::mirrorRepeat(0.9f); + Error += glm::equal(F, 0.9f, 0.00001f) ? 0 : 1; + + float G = glm::mirrorRepeat(3.0f); + Error += glm::equal(G, 1.0f, 0.00001f) ? 0 : 1; + + float H = glm::mirrorRepeat(-3.0f); + Error += glm::equal(H, 1.0f, 0.00001f) ? 0 : 1; + + float I = glm::mirrorRepeat(-1.0f); + Error += glm::equal(I, 1.0f, 0.00001f) ? 0 : 1; + + return Error; +} + +static int test_iround() +{ + int Error = 0; + + for(float f = 0.0f; f < 3.1f; f += 0.05f) + { + int RoundFast = static_cast<int>(glm::iround(f)); + int RoundSTD = static_cast<int>(glm::round(f)); + Error += RoundFast == RoundSTD ? 0 : 1; + assert(!Error); + } + + return Error; +} + +static int test_uround() +{ + int Error = 0; + + for(float f = 0.0f; f < 3.1f; f += 0.05f) + { + int RoundFast = static_cast<int>(glm::uround(f)); + int RoundSTD = static_cast<int>(glm::round(f)); + Error += RoundFast == RoundSTD ? 0 : 1; + assert(!Error); + } + + 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>(); + + Error += test_clamp(); + Error += test_repeat(); + Error += test_mirrorClamp(); + Error += test_mirrorRepeat(); + + Error += test_iround(); + Error += test_uround(); + + return Error; +} diff --git a/3rdparty/glm/source/test/ext/ext_scalar_constants.cpp b/3rdparty/glm/source/test/ext/ext_scalar_constants.cpp new file mode 100644 index 0000000..3af7099 --- /dev/null +++ b/3rdparty/glm/source/test/ext/ext_scalar_constants.cpp @@ -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; +} diff --git a/3rdparty/glm/source/test/ext/ext_scalar_int_sized.cpp b/3rdparty/glm/source/test/ext/ext_scalar_int_sized.cpp new file mode 100644 index 0000000..b55c6ca --- /dev/null +++ b/3rdparty/glm/source/test/ext/ext_scalar_int_sized.cpp @@ -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; +} diff --git a/3rdparty/glm/source/test/ext/ext_scalar_integer.cpp b/3rdparty/glm/source/test/ext/ext_scalar_integer.cpp new file mode 100644 index 0000000..f169e8a --- /dev/null +++ b/3rdparty/glm/source/test/ext/ext_scalar_integer.cpp @@ -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 diff --git a/3rdparty/glm/source/test/ext/ext_scalar_packing.cpp b/3rdparty/glm/source/test/ext/ext_scalar_packing.cpp new file mode 100644 index 0000000..77616e3 --- /dev/null +++ b/3rdparty/glm/source/test/ext/ext_scalar_packing.cpp @@ -0,0 +1,28 @@ +#include <glm/ext/scalar_packing.hpp> +#include <glm/ext/scalar_relational.hpp> + +int test_packUnorm() +{ + int Error = 0; + + + return Error; +} + +int test_packSnorm() +{ + int Error = 0; + + + return Error; +} + +int main() +{ + int Error = 0; + + Error += test_packUnorm(); + Error += test_packSnorm(); + + return Error; +} diff --git a/3rdparty/glm/source/test/ext/ext_scalar_reciprocal.cpp b/3rdparty/glm/source/test/ext/ext_scalar_reciprocal.cpp new file mode 100644 index 0000000..ebba10d --- /dev/null +++ b/3rdparty/glm/source/test/ext/ext_scalar_reciprocal.cpp @@ -0,0 +1,171 @@ +#include <glm/ext/scalar_reciprocal.hpp> +#include <glm/ext/scalar_relational.hpp> +#include <glm/ext/scalar_constants.hpp> + +static int test_sec() +{ + int Error = 0; + + Error += glm::equal(glm::sec(0.0), 1.0, 0.01) ? 0 : 1; + Error += glm::equal(glm::sec(glm::pi<double>() * 2.0), 1.0, 0.01) ? 0 : 1; + Error += glm::equal(glm::sec(glm::pi<double>() * -2.0), 1.0, 0.01) ? 0 : 1; + Error += glm::equal(glm::sec(glm::pi<double>() * 1.0), -1.0, 0.01) ? 0 : 1; + Error += glm::equal(glm::sec(glm::pi<double>() * -1.0), -1.0, 0.01) ? 0 : 1; + + return Error; +} + +static int test_csc() +{ + int Error = 0; + + double const a = glm::csc(glm::pi<double>() * 0.5); + Error += glm::equal(a, 1.0, 0.01) ? 0 : 1; + double const b = glm::csc(glm::pi<double>() * -0.5); + Error += glm::equal(b, -1.0, 0.01) ? 0 : 1; + + return Error; +} + +static int test_cot() +{ + int Error = 0; + + double const a = glm::cot(glm::pi<double>() * 0.5); + Error += glm::equal(a, 0.0, 0.01) ? 0 : 1; + double const b = glm::cot(glm::pi<double>() * -0.5); + Error += glm::equal(b, 0.0, 0.01) ? 0 : 1; + + return Error; +} + +static int test_asec() +{ + int Error = 0; + + Error += glm::equal(glm::asec(100000.0), glm::pi<double>() * 0.5, 0.01) ? 0 : 1; + Error += glm::equal(glm::asec(-100000.0), glm::pi<double>() * 0.5, 0.01) ? 0 : 1; + + return Error; +} + +static int test_acsc() +{ + int Error = 0; + + Error += glm::equal(glm::acsc(100000.0), 0.0, 0.01) ? 0 : 1; + Error += glm::equal(glm::acsc(-100000.0), 0.0, 0.01) ? 0 : 1; + + return Error; +} + +static int test_acot() +{ + int Error = 0; + + Error += glm::equal(glm::acot(100000.0), 0.0, 0.01) ? 0 : 1; + Error += glm::equal(glm::acot(-100000.0), glm::pi<double>(), 0.01) ? 0 : 1; + Error += glm::equal(glm::acot(0.0), glm::pi<double>() * 0.5, 0.01) ? 0 : 1; + + return Error; +} + +static int test_sech() +{ + int Error = 0; + + Error += glm::equal(glm::sech(100000.0), 0.0, 0.01) ? 0 : 1; + Error += glm::equal(glm::sech(-100000.0), 0.0, 0.01) ? 0 : 1; + Error += glm::equal(glm::sech(0.0), 1.0, 0.01) ? 0 : 1; + + return Error; +} + +static int test_csch() +{ + int Error = 0; + + Error += glm::equal(glm::csch(100000.0), 0.0, 0.01) ? 0 : 1; + Error += glm::equal(glm::csch(-100000.0), 0.0, 0.01) ? 0 : 1; + + return Error; +} + +static int test_coth() +{ + int Error = 0; + + double const a = glm::coth(100.0); + Error += glm::equal(a, 1.0, 0.01) ? 0 : 1; + + double const b = glm::coth(-100.0); + Error += glm::equal(b, -1.0, 0.01) ? 0 : 1; + + return Error; +} + +static int test_asech() +{ + int Error = 0; + + double const a = glm::asech(1.0); + Error += glm::equal(a, 0.0, 0.01) ? 0 : 1; + + return Error; +} + +static int test_acsch() +{ + int Error = 0; + + Error += glm::acsch(0.01) > 1.0 ? 0 : 1; + Error += glm::acsch(-0.01) < -1.0 ? 0 : 1; + + Error += glm::equal(glm::acsch(100.0), 0.0, 0.01) ? 0 : 1; + Error += glm::equal(glm::acsch(-100.0), 0.0, 0.01) ? 0 : 1; + + return Error; +} + +static int test_acoth() +{ + int Error = 0; + + double const a = glm::acoth(1.00001); + Error += a > 6.0 ? 0 : 1; + + double const b = glm::acoth(-1.00001); + Error += b < -6.0 ? 0 : 1; + + double const c = glm::acoth(10000.0); + Error += glm::equal(c, 0.0, 0.01) ? 0 : 1; + + double const d = glm::acoth(-10000.0); + Error += glm::equal(d, 0.0, 0.01) ? 0 : 1; + + return Error; +} + + +int main() +{ + int Error = 0; + + Error += test_sec(); + Error += test_csc(); + Error += test_cot(); + + Error += test_asec(); + Error += test_acsc(); + Error += test_acot(); + + Error += test_sech(); + Error += test_csch(); + Error += test_coth(); + + Error += test_asech(); + Error += test_acsch(); + Error += test_acoth(); + + return Error; +} diff --git a/3rdparty/glm/source/test/ext/ext_scalar_relational.cpp b/3rdparty/glm/source/test/ext/ext_scalar_relational.cpp new file mode 100644 index 0000000..61f1999 --- /dev/null +++ b/3rdparty/glm/source/test/ext/ext_scalar_relational.cpp @@ -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; +} diff --git a/3rdparty/glm/source/test/ext/ext_scalar_uint_sized.cpp b/3rdparty/glm/source/test/ext/ext_scalar_uint_sized.cpp new file mode 100644 index 0000000..1122947 --- /dev/null +++ b/3rdparty/glm/source/test/ext/ext_scalar_uint_sized.cpp @@ -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; +} diff --git a/3rdparty/glm/source/test/ext/ext_scalar_ulp.cpp b/3rdparty/glm/source/test/ext/ext_scalar_ulp.cpp new file mode 100644 index 0000000..a19b774 --- /dev/null +++ b/3rdparty/glm/source/test/ext/ext_scalar_ulp.cpp @@ -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; +} diff --git a/3rdparty/glm/source/test/ext/ext_vec1.cpp b/3rdparty/glm/source/test/ext/ext_vec1.cpp new file mode 100644 index 0000000..fc0b931 --- /dev/null +++ b/3rdparty/glm/source/test/ext/ext_vec1.cpp @@ -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; +} diff --git a/3rdparty/glm/source/test/ext/ext_vector_bool1.cpp b/3rdparty/glm/source/test/ext/ext_vector_bool1.cpp new file mode 100644 index 0000000..43eed57 --- /dev/null +++ b/3rdparty/glm/source/test/ext/ext_vector_bool1.cpp @@ -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; +} diff --git a/3rdparty/glm/source/test/ext/ext_vector_common.cpp b/3rdparty/glm/source/test/ext/ext_vector_common.cpp new file mode 100644 index 0000000..211003f --- /dev/null +++ b/3rdparty/glm/source/test/ext/ext_vector_common.cpp @@ -0,0 +1,365 @@ +#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; +} + +static int test_clamp() +{ + int Error = 0; + + glm::vec2 K = glm::clamp(glm::vec2(0.5f)); + Error += glm::all(glm::equal(K, glm::vec2(0.5f), glm::vec2(0.00001f))) ? 0 : 1; + + glm::vec3 L = glm::clamp(glm::vec3(0.5f)); + Error += glm::all(glm::equal(L, glm::vec3(0.5f), glm::vec3(0.00001f))) ? 0 : 1; + + glm::vec4 M = glm::clamp(glm::vec4(0.5f)); + Error += glm::all(glm::equal(M, glm::vec4(0.5f), glm::vec4(0.00001f))) ? 0 : 1; + + glm::vec1 N = glm::clamp(glm::vec1(0.5f)); + Error += glm::all(glm::equal(N, glm::vec1(0.5f), glm::vec1(0.00001f))) ? 0 : 1; + + return Error; +} + +static int test_repeat() +{ + int Error = 0; + + glm::vec2 K = glm::repeat(glm::vec2(0.5f)); + Error += glm::all(glm::equal(K, glm::vec2(0.5f), glm::vec2(0.00001f))) ? 0 : 1; + + glm::vec3 L = glm::repeat(glm::vec3(0.5f)); + Error += glm::all(glm::equal(L, glm::vec3(0.5f), glm::vec3(0.00001f))) ? 0 : 1; + + glm::vec4 M = glm::repeat(glm::vec4(0.5f)); + Error += glm::all(glm::equal(M, glm::vec4(0.5f), glm::vec4(0.00001f))) ? 0 : 1; + + glm::vec1 N = glm::repeat(glm::vec1(0.5f)); + Error += glm::all(glm::equal(N, glm::vec1(0.5f), glm::vec1(0.00001f))) ? 0 : 1; + + return Error; +} + +static int test_mirrorClamp() +{ + int Error = 0; + + glm::vec2 K = glm::mirrorClamp(glm::vec2(0.5f)); + Error += glm::all(glm::equal(K, glm::vec2(0.5f), glm::vec2(0.00001f))) ? 0 : 1; + + glm::vec3 L = glm::mirrorClamp(glm::vec3(0.5f)); + Error += glm::all(glm::equal(L, glm::vec3(0.5f), glm::vec3(0.00001f))) ? 0 : 1; + + glm::vec4 M = glm::mirrorClamp(glm::vec4(0.5f)); + Error += glm::all(glm::equal(M, glm::vec4(0.5f), glm::vec4(0.00001f))) ? 0 : 1; + + glm::vec1 N = glm::mirrorClamp(glm::vec1(0.5f)); + Error += glm::all(glm::equal(N, glm::vec1(0.5f), glm::vec1(0.00001f))) ? 0 : 1; + + return Error; +} + +static int test_mirrorRepeat() +{ + int Error = 0; + + glm::vec2 K = glm::mirrorRepeat(glm::vec2(0.5f)); + Error += glm::all(glm::equal(K, glm::vec2(0.5f), glm::vec2(0.00001f))) ? 0 : 1; + + glm::vec3 L = glm::mirrorRepeat(glm::vec3(0.5f)); + Error += glm::all(glm::equal(L, glm::vec3(0.5f), glm::vec3(0.00001f))) ? 0 : 1; + + glm::vec4 M = glm::mirrorRepeat(glm::vec4(0.5f)); + Error += glm::all(glm::equal(M, glm::vec4(0.5f), glm::vec4(0.00001f))) ? 0 : 1; + + glm::vec1 N = glm::mirrorRepeat(glm::vec1(0.5f)); + Error += glm::all(glm::equal(N, glm::vec1(0.5f), glm::vec1(0.00001f))) ? 0 : 1; + + return Error; +} + +static int test_iround() +{ + int Error = 0; + + for(float f = 0.0f; f < 3.1f; f += 0.05f) + { + int RoundFast = static_cast<int>(glm::iround(f)); + int RoundSTD = static_cast<int>(glm::round(f)); + Error += RoundFast == RoundSTD ? 0 : 1; + assert(!Error); + } + + return Error; +} + +static int test_uround() +{ + int Error = 0; + + for(float f = 0.0f; f < 3.1f; f += 0.05f) + { + int RoundFast = static_cast<int>(glm::uround(f)); + int RoundSTD = static_cast<int>(glm::round(f)); + Error += RoundFast == RoundSTD ? 0 : 1; + assert(!Error); + } + + 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>(); + + Error += test_clamp(); + Error += test_repeat(); + Error += test_mirrorClamp(); + Error += test_mirrorRepeat(); + + Error += test_iround(); + Error += test_uround(); + + return Error; +} diff --git a/3rdparty/glm/source/test/ext/ext_vector_iec559.cpp b/3rdparty/glm/source/test/ext/ext_vector_iec559.cpp new file mode 100644 index 0000000..5a9da50 --- /dev/null +++ b/3rdparty/glm/source/test/ext/ext_vector_iec559.cpp @@ -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; +} diff --git a/3rdparty/glm/source/test/ext/ext_vector_int1_sized.cpp b/3rdparty/glm/source/test/ext/ext_vector_int1_sized.cpp new file mode 100644 index 0000000..c262f49 --- /dev/null +++ b/3rdparty/glm/source/test/ext/ext_vector_int1_sized.cpp @@ -0,0 +1,41 @@ +#include <glm/ext/vector_int1_sized.hpp> + +#if GLM_HAS_STATIC_ASSERT + static_assert(sizeof(glm::i8vec1) == 1, "int8 size isn't 1 byte on this platform"); + static_assert(sizeof(glm::i16vec1) == 2, "int16 size isn't 2 bytes on this platform"); + static_assert(sizeof(glm::i32vec1) == 4, "int32 size isn't 4 bytes on this platform"); + static_assert(sizeof(glm::i64vec1) == 8, "int64 size isn't 8 bytes on this platform"); +#endif + +static int test_size() +{ + int Error = 0; + + Error += sizeof(glm::i8vec1) == 1 ? 0 : 1; + Error += sizeof(glm::i16vec1) == 2 ? 0 : 1; + Error += sizeof(glm::i32vec1) == 4 ? 0 : 1; + Error += sizeof(glm::i64vec1) == 8 ? 0 : 1; + + return Error; +} + +static int test_comp() +{ + int Error = 0; + + Error += sizeof(glm::i8vec1) < sizeof(glm::i16vec1) ? 0 : 1; + Error += sizeof(glm::i16vec1) < sizeof(glm::i32vec1) ? 0 : 1; + Error += sizeof(glm::i32vec1) < sizeof(glm::i64vec1) ? 0 : 1; + + return Error; +} + +int main() +{ + int Error = 0; + + Error += test_size(); + Error += test_comp(); + + return Error; +} diff --git a/3rdparty/glm/source/test/ext/ext_vector_int2_sized.cpp b/3rdparty/glm/source/test/ext/ext_vector_int2_sized.cpp new file mode 100644 index 0000000..f4ad8b6 --- /dev/null +++ b/3rdparty/glm/source/test/ext/ext_vector_int2_sized.cpp @@ -0,0 +1,41 @@ +#include <glm/ext/vector_int2_sized.hpp> + +#if GLM_HAS_STATIC_ASSERT + static_assert(sizeof(glm::i8vec2) == 2, "int8 size isn't 1 byte on this platform"); + static_assert(sizeof(glm::i16vec2) == 4, "int16 size isn't 2 bytes on this platform"); + static_assert(sizeof(glm::i32vec2) == 8, "int32 size isn't 4 bytes on this platform"); + static_assert(sizeof(glm::i64vec2) == 16, "int64 size isn't 8 bytes on this platform"); +#endif + +static int test_size() +{ + int Error = 0; + + Error += sizeof(glm::i8vec2) == 2 ? 0 : 1; + Error += sizeof(glm::i16vec2) == 4 ? 0 : 1; + Error += sizeof(glm::i32vec2) == 8 ? 0 : 1; + Error += sizeof(glm::i64vec2) == 16 ? 0 : 1; + + return Error; +} + +static int test_comp() +{ + int Error = 0; + + Error += sizeof(glm::i8vec2) < sizeof(glm::i16vec2) ? 0 : 1; + Error += sizeof(glm::i16vec2) < sizeof(glm::i32vec2) ? 0 : 1; + Error += sizeof(glm::i32vec2) < sizeof(glm::i64vec2) ? 0 : 1; + + return Error; +} + +int main() +{ + int Error = 0; + + Error += test_size(); + Error += test_comp(); + + return Error; +} diff --git a/3rdparty/glm/source/test/ext/ext_vector_int3_sized.cpp b/3rdparty/glm/source/test/ext/ext_vector_int3_sized.cpp new file mode 100644 index 0000000..c51bfe7 --- /dev/null +++ b/3rdparty/glm/source/test/ext/ext_vector_int3_sized.cpp @@ -0,0 +1,41 @@ +#include <glm/ext/vector_int3_sized.hpp> + +#if GLM_HAS_STATIC_ASSERT + static_assert(sizeof(glm::i8vec3) == 3, "int8 size isn't 1 byte on this platform"); + static_assert(sizeof(glm::i16vec3) == 6, "int16 size isn't 2 bytes on this platform"); + static_assert(sizeof(glm::i32vec3) == 12, "int32 size isn't 4 bytes on this platform"); + static_assert(sizeof(glm::i64vec3) == 24, "int64 size isn't 8 bytes on this platform"); +#endif + +static int test_size() +{ + int Error = 0; + + Error += sizeof(glm::i8vec3) == 3 ? 0 : 1; + Error += sizeof(glm::i16vec3) == 6 ? 0 : 1; + Error += sizeof(glm::i32vec3) == 12 ? 0 : 1; + Error += sizeof(glm::i64vec3) == 24 ? 0 : 1; + + return Error; +} + +static int test_comp() +{ + int Error = 0; + + Error += sizeof(glm::i8vec3) < sizeof(glm::i16vec3) ? 0 : 1; + Error += sizeof(glm::i16vec3) < sizeof(glm::i32vec3) ? 0 : 1; + Error += sizeof(glm::i32vec3) < sizeof(glm::i64vec3) ? 0 : 1; + + return Error; +} + +int main() +{ + int Error = 0; + + Error += test_size(); + Error += test_comp(); + + return Error; +} diff --git a/3rdparty/glm/source/test/ext/ext_vector_int4_sized.cpp b/3rdparty/glm/source/test/ext/ext_vector_int4_sized.cpp new file mode 100644 index 0000000..93fd9ed --- /dev/null +++ b/3rdparty/glm/source/test/ext/ext_vector_int4_sized.cpp @@ -0,0 +1,41 @@ +#include <glm/ext/vector_int4_sized.hpp> + +#if GLM_HAS_STATIC_ASSERT +static_assert(sizeof(glm::i8vec4) == 4, "int8 size isn't 1 byte on this platform"); +static_assert(sizeof(glm::i16vec4) == 8, "int16 size isn't 2 bytes on this platform"); +static_assert(sizeof(glm::i32vec4) == 16, "int32 size isn't 4 bytes on this platform"); +static_assert(sizeof(glm::i64vec4) == 32, "int64 size isn't 8 bytes on this platform"); +#endif + +static int test_size() +{ + int Error = 0; + + Error += sizeof(glm::i8vec4) == 4 ? 0 : 1; + Error += sizeof(glm::i16vec4) == 8 ? 0 : 1; + Error += sizeof(glm::i32vec4) == 16 ? 0 : 1; + Error += sizeof(glm::i64vec4) == 32 ? 0 : 1; + + return Error; +} + +static int test_comp() +{ + int Error = 0; + + Error += sizeof(glm::i8vec4) < sizeof(glm::i16vec4) ? 0 : 1; + Error += sizeof(glm::i16vec4) < sizeof(glm::i32vec4) ? 0 : 1; + Error += sizeof(glm::i32vec4) < sizeof(glm::i64vec4) ? 0 : 1; + + return Error; +} + +int main() +{ + int Error = 0; + + Error += test_size(); + Error += test_comp(); + + return Error; +} diff --git a/3rdparty/glm/source/test/ext/ext_vector_integer.cpp b/3rdparty/glm/source/test/ext/ext_vector_integer.cpp new file mode 100644 index 0000000..d7278d3 --- /dev/null +++ b/3rdparty/glm/source/test/ext/ext_vector_integer.cpp @@ -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; +} diff --git a/3rdparty/glm/source/test/ext/ext_vector_integer_sized.cpp b/3rdparty/glm/source/test/ext/ext_vector_integer_sized.cpp new file mode 100644 index 0000000..52b3f4e --- /dev/null +++ b/3rdparty/glm/source/test/ext/ext_vector_integer_sized.cpp @@ -0,0 +1,216 @@ +#include <glm/ext/vector_integer.hpp> +#include <glm/ext/vector_int1.hpp> +#include <glm/ext/vector_int1_sized.hpp> +#include <glm/ext/vector_uint1.hpp> +#include <glm/ext/vector_uint1_sized.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::i8vec1>(); + Error += test_operators<glm::i16vec1>(); + Error += test_operators<glm::i32vec1>(); + Error += test_operators<glm::i64vec1>(); + + Error += test_ctor<glm::ivec1>(); + Error += test_ctor<glm::i8vec1>(); + Error += test_ctor<glm::i16vec1>(); + Error += test_ctor<glm::i32vec1>(); + Error += test_ctor<glm::i64vec1>(); + + Error += test_size<glm::ivec1>(); + Error += test_size<glm::i8vec1>(); + Error += test_size<glm::i16vec1>(); + Error += test_size<glm::i32vec1>(); + Error += test_size<glm::i64vec1>(); + + Error += test_relational<glm::ivec1>(); + Error += test_relational<glm::i8vec1>(); + Error += test_relational<glm::i16vec1>(); + Error += test_relational<glm::i32vec1>(); + Error += test_relational<glm::i64vec1>(); + + Error += test_constexpr<glm::ivec1>(); + Error += test_constexpr<glm::i8vec1>(); + Error += test_constexpr<glm::i16vec1>(); + Error += test_constexpr<glm::i32vec1>(); + Error += test_constexpr<glm::i64vec1>(); + + Error += test_operators<glm::uvec1>(); + Error += test_operators<glm::u8vec1>(); + Error += test_operators<glm::u16vec1>(); + Error += test_operators<glm::u32vec1>(); + Error += test_operators<glm::u64vec1>(); + + Error += test_ctor<glm::uvec1>(); + Error += test_ctor<glm::u8vec1>(); + Error += test_ctor<glm::u16vec1>(); + Error += test_ctor<glm::u32vec1>(); + Error += test_ctor<glm::u64vec1>(); + + Error += test_size<glm::uvec1>(); + Error += test_size<glm::u8vec1>(); + Error += test_size<glm::u16vec1>(); + Error += test_size<glm::u32vec1>(); + Error += test_size<glm::u64vec1>(); + + Error += test_relational<glm::uvec1>(); + Error += test_relational<glm::u8vec1>(); + Error += test_relational<glm::u16vec1>(); + Error += test_relational<glm::u32vec1>(); + Error += test_relational<glm::u64vec1>(); + + Error += test_constexpr<glm::uvec1>(); + Error += test_constexpr<glm::u8vec1>(); + Error += test_constexpr<glm::u16vec1>(); + Error += test_constexpr<glm::u32vec1>(); + Error += test_constexpr<glm::u64vec1>(); + + return Error; +} diff --git a/3rdparty/glm/source/test/ext/ext_vector_packing.cpp b/3rdparty/glm/source/test/ext/ext_vector_packing.cpp new file mode 100644 index 0000000..d7cbce2 --- /dev/null +++ b/3rdparty/glm/source/test/ext/ext_vector_packing.cpp @@ -0,0 +1,58 @@ +#include <glm/ext/vector_packing.hpp> +#include <glm/ext/vector_relational.hpp> +#include <glm/ext/vector_uint2_sized.hpp> +#include <glm/ext/vector_int2_sized.hpp> +#include <glm/gtc/packing.hpp> +#include <glm/vec2.hpp> +#include <vector> + +int test_packUnorm() +{ + int Error = 0; + + std::vector<glm::vec2> A; + A.push_back(glm::vec2(1.0f, 0.7f)); + A.push_back(glm::vec2(0.5f, 0.1f)); + + for (std::size_t i = 0; i < A.size(); ++i) + { + glm::vec2 B(A[i]); + glm::u16vec2 C = glm::packUnorm<glm::uint16>(B); + glm::vec2 D = glm::unpackUnorm<float>(C); + Error += glm::all(glm::equal(B, D, 1.0f / 255.f)) ? 0 : 1; + assert(!Error); + } + + return Error; +} + +int test_packSnorm() +{ + int Error = 0; + + std::vector<glm::vec2> A; + A.push_back(glm::vec2(1.0f, 0.0f)); + A.push_back(glm::vec2(-0.5f, -0.7f)); + A.push_back(glm::vec2(-0.1f, 0.1f)); + + for (std::size_t i = 0; i < A.size(); ++i) + { + glm::vec2 B(A[i]); + glm::i16vec2 C = glm::packSnorm<glm::int16>(B); + glm::vec2 D = glm::unpackSnorm<float>(C); + Error += glm::all(glm::equal(B, D, 1.0f / 32767.0f * 2.0f)) ? 0 : 1; + assert(!Error); + } + + return Error; +} + +int main() +{ + int Error = 0; + + Error += test_packUnorm(); + Error += test_packSnorm(); + + return Error; +} diff --git a/3rdparty/glm/source/test/ext/ext_vector_reciprocal.cpp b/3rdparty/glm/source/test/ext/ext_vector_reciprocal.cpp new file mode 100644 index 0000000..f4b9f18 --- /dev/null +++ b/3rdparty/glm/source/test/ext/ext_vector_reciprocal.cpp @@ -0,0 +1,186 @@ +#include <glm/ext/vector_reciprocal.hpp> +#include <glm/ext/vector_relational.hpp> +#include <glm/ext/scalar_constants.hpp> +#include <glm/ext/vector_double1.hpp> + +static int test_sec() +{ + int Error = 0; + + glm::dvec1 const a = glm::sec(glm::dvec1(0.0)); + Error += glm::all(glm::equal(a, glm::dvec1(1.0), 0.01)) ? 0 : 1; + + glm::dvec1 const b = glm::sec(glm::dvec1(glm::pi<double>() * 2.0)); + Error += glm::all(glm::equal(b, glm::dvec1(1.0), 0.01)) ? 0 : 1; + + glm::dvec1 const c = glm::sec(glm::dvec1(glm::pi<double>() * -2.0)); + Error += glm::all(glm::equal(c, glm::dvec1(1.0), 0.01)) ? 0 : 1; + + glm::dvec1 const d = glm::sec(glm::dvec1(glm::pi<double>() * 1.0)); + Error += glm::all(glm::equal(d, -glm::dvec1(1.0), 0.01)) ? 0 : 1; + + glm::dvec1 const e = glm::sec(glm::dvec1(glm::pi<double>() * -1.0)); + Error += glm::all(glm::equal(e, -glm::dvec1(1.0), 0.01)) ? 0 : 1; + + return Error; +} + +static int test_csc() +{ + int Error = 0; + + glm::dvec1 const a = glm::csc(glm::dvec1(glm::pi<double>() * 0.5)); + Error += glm::all(glm::equal(a, glm::dvec1(1.0), 0.01)) ? 0 : 1; + + glm::dvec1 const b = glm::csc(glm::dvec1(glm::pi<double>() * -0.5)); + Error += glm::all(glm::equal(b, glm::dvec1(-1.0), 0.01)) ? 0 : 1; + + return Error; +} + +static int test_cot() +{ + int Error = 0; + + glm::dvec1 const a = glm::cot(glm::dvec1(glm::pi<double>() * 0.5)); + Error += glm::all(glm::equal(a, glm::dvec1(0.0), 0.01)) ? 0 : 1; + + glm::dvec1 const b = glm::cot(glm::dvec1(glm::pi<double>() * -0.5)); + Error += glm::all(glm::equal(b, glm::dvec1(0.0), 0.01)) ? 0 : 1; + + return Error; +} + +static int test_asec() +{ + int Error = 0; + + Error += glm::all(glm::equal(glm::asec(glm::dvec1(100000.0)), glm::dvec1(glm::pi<double>() * 0.5), 0.01)) ? 0 : 1; + Error += glm::all(glm::equal(glm::asec(glm::dvec1(-100000.0)), glm::dvec1(glm::pi<double>() * 0.5), 0.01)) ? 0 : 1; + + return Error; +} + +static int test_acsc() +{ + int Error = 0; + + Error += glm::all(glm::equal(glm::acsc(glm::dvec1(100000.0)), glm::dvec1(0.0), 0.01)) ? 0 : 1; + Error += glm::all(glm::equal(glm::acsc(glm::dvec1(-100000.0)), glm::dvec1(0.0), 0.01)) ? 0 : 1; + + return Error; +} + +static int test_acot() +{ + int Error = 0; + + Error += glm::all(glm::equal(glm::acot(glm::dvec1(100000.0)), glm::dvec1(0.0), 0.01)) ? 0 : 1; + Error += glm::all(glm::equal(glm::acot(glm::dvec1(-100000.0)), glm::dvec1(glm::pi<double>()), 0.01)) ? 0 : 1; + Error += glm::all(glm::equal(glm::acot(glm::dvec1(0.0)), glm::dvec1(glm::pi<double>() * 0.5), 0.01)) ? 0 : 1; + + return Error; +} + +static int test_sech() +{ + int Error = 0; + + Error += glm::all(glm::equal(glm::sech(glm::dvec1(100000.0)), glm::dvec1(0.0), 0.01)) ? 0 : 1; + Error += glm::all(glm::equal(glm::sech(glm::dvec1(-100000.0)), glm::dvec1(0.0), 0.01)) ? 0 : 1; + Error += glm::all(glm::equal(glm::sech(glm::dvec1(0.0)), glm::dvec1(1.0), 0.01)) ? 0 : 1; + + return Error; +} + +static int test_csch() +{ + int Error = 0; + + Error += glm::all(glm::equal(glm::csch(glm::dvec1(100000.0)), glm::dvec1(0.0), 0.01)) ? 0 : 1; + Error += glm::all(glm::equal(glm::csch(glm::dvec1(-100000.0)), glm::dvec1(0.0), 0.01)) ? 0 : 1; + + return Error; +} + +static int test_coth() +{ + int Error = 0; + + glm::dvec1 const a = glm::coth(glm::dvec1(100.0)); + Error += glm::all(glm::equal(a, glm::dvec1(1.0), 0.01)) ? 0 : 1; + + glm::dvec1 const b = glm::coth(glm::dvec1(-100.0)); + Error += glm::all(glm::equal(b, glm::dvec1(-1.0), 0.01)) ? 0 : 1; + + return Error; +} + +static int test_asech() +{ + int Error = 0; + + glm::dvec1 const a = glm::asech(glm::dvec1(1.0)); + Error += glm::all(glm::equal(a, glm::dvec1(0.0), 0.01)) ? 0 : 1; + + return Error; +} + +static int test_acsch() +{ + int Error = 0; + + glm::dvec1 const a(glm::acsch(glm::dvec1(0.01))); + Error += a.x > 1.0 ? 0 : 1; + + glm::dvec1 const b(glm::acsch(glm::dvec1(-0.01))); + Error += b.x < -1.0 ? 0 : 1; + + Error += glm::all(glm::equal(glm::acsch(glm::dvec1(100.0)), glm::dvec1(0.0), 0.01)) ? 0 : 1; + Error += glm::all(glm::equal(glm::acsch(glm::dvec1(-100.0)), glm::dvec1(0.0), 0.01)) ? 0 : 1; + + return Error; +} + +static int test_acoth() +{ + int Error = 0; + + glm::dvec1 const a = glm::acoth(glm::dvec1(1.00001)); + Error += a.x > 6.0 ? 0 : 1; + + glm::dvec1 const b = glm::acoth(glm::dvec1(-1.00001)); + Error += b.x < -6.0 ? 0 : 1; + + glm::dvec1 const c = glm::acoth(glm::dvec1(10000.0)); + Error += glm::all(glm::equal(c, glm::dvec1(0.0), 0.01)) ? 0 : 1; + + glm::dvec1 const d = glm::acoth(glm::dvec1(-10000.0)); + Error += glm::all(glm::equal(d, glm::dvec1(0.0), 0.01)) ? 0 : 1; + + return Error; +} + + +int main() +{ + int Error = 0; + + Error += test_sec(); + Error += test_csc(); + Error += test_cot(); + + Error += test_asec(); + Error += test_acsc(); + Error += test_acot(); + + Error += test_sech(); + Error += test_csch(); + Error += test_coth(); + + Error += test_asech(); + Error += test_acsch(); + Error += test_acoth(); + + return Error; +} diff --git a/3rdparty/glm/source/test/ext/ext_vector_relational.cpp b/3rdparty/glm/source/test/ext/ext_vector_relational.cpp new file mode 100644 index 0000000..f6cd307 --- /dev/null +++ b/3rdparty/glm/source/test/ext/ext_vector_relational.cpp @@ -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; +} diff --git a/3rdparty/glm/source/test/ext/ext_vector_uint1_sized.cpp b/3rdparty/glm/source/test/ext/ext_vector_uint1_sized.cpp new file mode 100644 index 0000000..f2e4624 --- /dev/null +++ b/3rdparty/glm/source/test/ext/ext_vector_uint1_sized.cpp @@ -0,0 +1,41 @@ +#include <glm/ext/vector_uint1_sized.hpp> + +#if GLM_HAS_STATIC_ASSERT + static_assert(sizeof(glm::u8vec1) == 1, "uint8 size isn't 1 byte on this platform"); + static_assert(sizeof(glm::u16vec1) == 2, "uint16 size isn't 2 bytes on this platform"); + static_assert(sizeof(glm::u32vec1) == 4, "uint32 size isn't 4 bytes on this platform"); + static_assert(sizeof(glm::u64vec1) == 8, "uint64 size isn't 8 bytes on this platform"); +#endif + +static int test_size() +{ + int Error = 0; + + Error += sizeof(glm::u8vec1) == 1 ? 0 : 1; + Error += sizeof(glm::u16vec1) == 2 ? 0 : 1; + Error += sizeof(glm::u32vec1) == 4 ? 0 : 1; + Error += sizeof(glm::u64vec1) == 8 ? 0 : 1; + + return Error; +} + +static int test_comp() +{ + int Error = 0; + + Error += sizeof(glm::u8vec1) < sizeof(glm::u16vec1) ? 0 : 1; + Error += sizeof(glm::u16vec1) < sizeof(glm::u32vec1) ? 0 : 1; + Error += sizeof(glm::u32vec1) < sizeof(glm::u64vec1) ? 0 : 1; + + return Error; +} + +int main() +{ + int Error = 0; + + Error += test_size(); + Error += test_comp(); + + return Error; +} diff --git a/3rdparty/glm/source/test/ext/ext_vector_uint2_sized.cpp b/3rdparty/glm/source/test/ext/ext_vector_uint2_sized.cpp new file mode 100644 index 0000000..9c0977e --- /dev/null +++ b/3rdparty/glm/source/test/ext/ext_vector_uint2_sized.cpp @@ -0,0 +1,41 @@ +#include <glm/ext/vector_uint2_sized.hpp> + +#if GLM_HAS_STATIC_ASSERT +static_assert(sizeof(glm::u8vec2) == 2, "int8 size isn't 1 byte on this platform"); +static_assert(sizeof(glm::u16vec2) == 4, "int16 size isn't 2 bytes on this platform"); +static_assert(sizeof(glm::u32vec2) == 8, "int32 size isn't 4 bytes on this platform"); +static_assert(sizeof(glm::u64vec2) == 16, "int64 size isn't 8 bytes on this platform"); +#endif + +static int test_size() +{ + int Error = 0; + + Error += sizeof(glm::u8vec2) == 2 ? 0 : 1; + Error += sizeof(glm::u16vec2) == 4 ? 0 : 1; + Error += sizeof(glm::u32vec2) == 8 ? 0 : 1; + Error += sizeof(glm::u64vec2) == 16 ? 0 : 1; + + return Error; +} + +static int test_comp() +{ + int Error = 0; + + Error += sizeof(glm::u8vec2) < sizeof(glm::u16vec2) ? 0 : 1; + Error += sizeof(glm::u16vec2) < sizeof(glm::u32vec2) ? 0 : 1; + Error += sizeof(glm::u32vec2) < sizeof(glm::u64vec2) ? 0 : 1; + + return Error; +} + +int main() +{ + int Error = 0; + + Error += test_size(); + Error += test_comp(); + + return Error; +} diff --git a/3rdparty/glm/source/test/ext/ext_vector_uint3_sized.cpp b/3rdparty/glm/source/test/ext/ext_vector_uint3_sized.cpp new file mode 100644 index 0000000..4cc2e44 --- /dev/null +++ b/3rdparty/glm/source/test/ext/ext_vector_uint3_sized.cpp @@ -0,0 +1,41 @@ +#include <glm/ext/vector_uint3_sized.hpp> + +#if GLM_HAS_STATIC_ASSERT +static_assert(sizeof(glm::u8vec3) == 3, "int8 size isn't 1 byte on this platform"); +static_assert(sizeof(glm::u16vec3) == 6, "int16 size isn't 2 bytes on this platform"); +static_assert(sizeof(glm::u32vec3) == 12, "int32 size isn't 4 bytes on this platform"); +static_assert(sizeof(glm::u64vec3) == 24, "int64 size isn't 8 bytes on this platform"); +#endif + +static int test_size() +{ + int Error = 0; + + Error += sizeof(glm::u8vec3) == 3 ? 0 : 1; + Error += sizeof(glm::u16vec3) == 6 ? 0 : 1; + Error += sizeof(glm::u32vec3) == 12 ? 0 : 1; + Error += sizeof(glm::u64vec3) == 24 ? 0 : 1; + + return Error; +} + +static int test_comp() +{ + int Error = 0; + + Error += sizeof(glm::u8vec3) < sizeof(glm::u16vec3) ? 0 : 1; + Error += sizeof(glm::u16vec3) < sizeof(glm::u32vec3) ? 0 : 1; + Error += sizeof(glm::u32vec3) < sizeof(glm::u64vec3) ? 0 : 1; + + return Error; +} + +int main() +{ + int Error = 0; + + Error += test_size(); + Error += test_comp(); + + return Error; +} diff --git a/3rdparty/glm/source/test/ext/ext_vector_uint4_sized.cpp b/3rdparty/glm/source/test/ext/ext_vector_uint4_sized.cpp new file mode 100644 index 0000000..9e7ffe7 --- /dev/null +++ b/3rdparty/glm/source/test/ext/ext_vector_uint4_sized.cpp @@ -0,0 +1,41 @@ +#include <glm/ext/vector_uint4_sized.hpp> + +#if GLM_HAS_STATIC_ASSERT +static_assert(sizeof(glm::u8vec4) == 4, "int8 size isn't 1 byte on this platform"); +static_assert(sizeof(glm::u16vec4) == 8, "int16 size isn't 2 bytes on this platform"); +static_assert(sizeof(glm::u32vec4) == 16, "int32 size isn't 4 bytes on this platform"); +static_assert(sizeof(glm::u64vec4) == 32, "int64 size isn't 8 bytes on this platform"); +#endif + +static int test_size() +{ + int Error = 0; + + Error += sizeof(glm::u8vec4) == 4 ? 0 : 1; + Error += sizeof(glm::u16vec4) == 8 ? 0 : 1; + Error += sizeof(glm::u32vec4) == 16 ? 0 : 1; + Error += sizeof(glm::u64vec4) == 32 ? 0 : 1; + + return Error; +} + +static int test_comp() +{ + int Error = 0; + + Error += sizeof(glm::u8vec4) < sizeof(glm::u16vec4) ? 0 : 1; + Error += sizeof(glm::u16vec4) < sizeof(glm::u32vec4) ? 0 : 1; + Error += sizeof(glm::u32vec4) < sizeof(glm::u64vec4) ? 0 : 1; + + return Error; +} + +int main() +{ + int Error = 0; + + Error += test_size(); + Error += test_comp(); + + return Error; +} diff --git a/3rdparty/glm/source/test/ext/ext_vector_ulp.cpp b/3rdparty/glm/source/test/ext/ext_vector_ulp.cpp new file mode 100644 index 0000000..6ebd1a1 --- /dev/null +++ b/3rdparty/glm/source/test/ext/ext_vector_ulp.cpp @@ -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; +} |