diff --git a/readme.md b/readme.md index 2cefd3fd..6ddded2b 100644 --- a/readme.md +++ b/readme.md @@ -72,6 +72,7 @@ glm::mat4 camera(float Translate, glm::vec2 const& Rotate) - Fixed ortho #790 - Fixed Visual C++ 2013 warnings in vector relational code #782 - Fixed ICC build errors with constexpr #704 +- Fixed defaulted operator= and constructors #791 ### [GLM 0.9.9.0](https://github.com/g-truc/glm/releases/tag/0.9.9.0) - 2018-05-22 #### Features: diff --git a/test/core/CMakeLists.txt b/test/core/CMakeLists.txt index 13477a97..12d76bf3 100644 --- a/test/core/CMakeLists.txt +++ b/test/core/CMakeLists.txt @@ -1,3 +1,4 @@ +glmCreateTestGTC(core_cpp_defaulted_ctor) glmCreateTestGTC(core_force_aligned_gentypes) glmCreateTestGTC(core_force_ctor_init) glmCreateTestGTC(core_force_explicit_ctor) diff --git a/test/core/core_cpp_defaulted_ctor.cpp b/test/core/core_cpp_defaulted_ctor.cpp new file mode 100644 index 00000000..ea927d12 --- /dev/null +++ b/test/core/core_cpp_defaulted_ctor.cpp @@ -0,0 +1,144 @@ +#include + +#if GLM_USE_DEFAULTED_FUNCTIONS == GLM_ENABLE + +#include +#include +#include +#include +#include + +static int test_vec_memcpy() +{ + int Error = 0; + + { + glm::ivec1 const A = glm::ivec1(76); + glm::ivec1 B; + std::memcpy(&B, &A, sizeof(glm::ivec1)); + Error += B == A ? 0 : 1; + } + + { + glm::ivec2 const A = glm::ivec2(76); + glm::ivec2 B; + std::memcpy(&B, &A, sizeof(glm::ivec2)); + Error += B == A ? 0 : 1; + } + + { + glm::ivec3 const A = glm::ivec3(76); + glm::ivec3 B; + std::memcpy(&B, &A, sizeof(glm::ivec3)); + Error += B == A ? 0 : 1; + } + + { + glm::ivec4 const A = glm::ivec4(76); + glm::ivec4 B; + std::memcpy(&B, &A, sizeof(glm::ivec4)); + Error += B == A ? 0 : 1; + } + + return Error; +} + +static int test_mat_memcpy() +{ + int Error = 0; + + { + glm::mat2x2 const A = glm::mat2x2(76); + glm::mat2x2 B; + std::memcpy(&B, &A, sizeof(glm::mat2x2)); + Error += glm::all(glm::equal(B, A, glm::epsilon())) ? 0 : 1; + } + + { + glm::mat2x3 const A = glm::mat2x3(76); + glm::mat2x3 B; + std::memcpy(&B, &A, sizeof(glm::mat2x3)); + Error += glm::all(glm::equal(B, A, glm::epsilon())) ? 0 : 1; + } + + { + glm::mat2x4 const A = glm::mat2x4(76); + glm::mat2x4 B; + std::memcpy(&B, &A, sizeof(glm::mat2x4)); + Error += glm::all(glm::equal(B, A, glm::epsilon())) ? 0 : 1; + } + + { + glm::mat3x2 const A = glm::mat3x2(76); + glm::mat3x2 B; + std::memcpy(&B, &A, sizeof(glm::mat3x2)); + Error += glm::all(glm::equal(B, A, glm::epsilon())) ? 0 : 1; + } + + { + glm::mat3x3 const A = glm::mat3x3(76); + glm::mat3x3 B; + std::memcpy(&B, &A, sizeof(glm::mat3x3)); + Error += glm::all(glm::equal(B, A, glm::epsilon())) ? 0 : 1; + } + + { + glm::mat3x4 const A = glm::mat3x4(76); + glm::mat3x4 B; + std::memcpy(&B, &A, sizeof(glm::mat3x4)); + Error += glm::all(glm::equal(B, A, glm::epsilon())) ? 0 : 1; + } + + { + glm::mat4x2 const A = glm::mat4x2(76); + glm::mat4x2 B; + std::memcpy(&B, &A, sizeof(glm::mat4x2)); + Error += glm::all(glm::equal(B, A, glm::epsilon())) ? 0 : 1; + } + + { + glm::mat4x3 const A = glm::mat4x3(76); + glm::mat4x3 B; + std::memcpy(&B, &A, sizeof(glm::mat4x3)); + Error += glm::all(glm::equal(B, A, glm::epsilon())) ? 0 : 1; + } + + { + glm::mat4x4 const A = glm::mat4x4(76); + glm::mat4x4 B; + std::memcpy(&B, &A, sizeof(glm::mat4x4)); + Error += glm::all(glm::equal(B, A, glm::epsilon())) ? 0 : 1; + } + + return Error; +} + +static int test_quat_memcpy() +{ + int Error = 0; + + { + glm::quat const A = glm::quat(1, 0, 0, 0); + glm::quat B; + std::memcpy(&B, &A, sizeof(glm::quat)); + Error += B == A ? 0 : 1; + } + + return Error; +} + +#endif//GLM_USE_DEFAULTED_FUNCTIONS == GLM_ENABLE + +int main() +{ + int Error = 0; + +# if GLM_USE_DEFAULTED_FUNCTIONS == GLM_ENABLE + Error += test_vec_memcpy(); + Error += test_mat_memcpy(); + Error += test_quat_memcpy(); +# endif//GLM_USE_DEFAULTED_FUNCTIONS == GLM_ENABLE + + return Error; +} +