From 5ea160413d89174131c7d056e9863d5fadc36f3e Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Sat, 5 Oct 2013 14:02:33 +0200 Subject: [PATCH] Completed initializer list tests --- test/core/core_type_mat2x3.cpp | 45 ++++++++++++++++++++++++++++++- test/core/core_type_mat2x4.cpp | 43 ++++++++++++++++++++++++++++++ test/core/core_type_mat3x2.cpp | 47 +++++++++++++++++++++++++++++++++ test/core/core_type_mat3x3.cpp | 47 +++++++++++++++++++++++++++++++++ test/core/core_type_mat3x4.cpp | 48 +++++++++++++++++++++++++++++++++- 5 files changed, 228 insertions(+), 2 deletions(-) diff --git a/test/core/core_type_mat2x3.cpp b/test/core/core_type_mat2x3.cpp index af42b76f..b6321209 100644 --- a/test/core/core_type_mat2x3.cpp +++ b/test/core/core_type_mat2x3.cpp @@ -2,7 +2,7 @@ // OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) /////////////////////////////////////////////////////////////////////////////////////////////////// // Created : 2008-08-31 -// Updated : 2008-08-31 +// Updated : 2013-10-04 // Licence : This source is under MIT License // File : test/core/type_mat2x3.cpp /////////////////////////////////////////////////////////////////////////////////////////////////// @@ -28,10 +28,53 @@ static int test_operators() return (S && !R) ? 0 : 1; } +int test_ctr() +{ + int Error(0); + +#if(GLM_HAS_INITIALIZER_LISTS) + glm::mat2x3 m0( + glm::vec2(0, 1, 2), + glm::vec2(3, 4, 5)); + + glm::mat2x3 m1{0, 1, 2, 3, 4, 5}; + + glm::mat2x3 m2{ + {0, 1, 2}, + {3, 4, 5}}; + + for(int i = 0; i < m0.length(); ++i) + Error += glm::all(glm::equal(m0[i], m2[i])) ? 0 : 1; + + for(int i = 0; i < m1.length(); ++i) + Error += glm::all(glm::equal(m1[i], m2[i])) ? 0 : 1; + + std::vector v1{ + {0, 1, 2, 3, 4, 5}, + {0, 1, 2, 3, 4, 5} + }; + + std::vector v2{ + { + { 0, 1, 2}, + { 4, 5, 6} + }, + { + { 0, 1, 2}, + { 4, 5, 6} + } + }; + +#endif//GLM_HAS_INITIALIZER_LISTS + + return Error; +} + int main() { int Error = 0; + Error += test_ctr(); Error += test_operators(); return Error; diff --git a/test/core/core_type_mat2x4.cpp b/test/core/core_type_mat2x4.cpp index 5ba3b6ed..4b4e67a3 100644 --- a/test/core/core_type_mat2x4.cpp +++ b/test/core/core_type_mat2x4.cpp @@ -28,10 +28,53 @@ static int test_operators() return (S && !R) ? 0 : 1; } +int test_ctr() +{ + int Error(0); + +#if(GLM_HAS_INITIALIZER_LISTS) + glm::mat2x4 m0( + glm::vec4(0, 1, 2, 3), + glm::vec4(4, 5, 6, 7)); + + glm::mat2x4 m1{0, 1, 2, 3, 4, 5, 6, 7}; + + glm::mat2x4 m2{ + {0, 1, 2, 3}, + {4, 5, 6, 7}}; + + for(int i = 0; i < m0.length(); ++i) + Error += glm::all(glm::equal(m0[i], m2[i])) ? 0 : 1; + + for(int i = 0; i < m1.length(); ++i) + Error += glm::all(glm::equal(m1[i], m2[i])) ? 0 : 1; + + std::vector v1{ + {0, 1, 2, 3, 4, 5, 6, 7}, + {0, 1, 2, 3, 4, 5, 6, 7} + }; + + std::vector v2{ + { + { 0, 1, 2, 3}, + { 4, 5, 6, 7} + }, + { + { 0, 1, 2, 3}, + { 4, 5, 6, 7} + } + }; + +#endif//GLM_HAS_INITIALIZER_LISTS + + return Error; +} + int main() { int Error = 0; + Error += test_ctr(); Error += test_operators(); return Error; diff --git a/test/core/core_type_mat3x2.cpp b/test/core/core_type_mat3x2.cpp index e1bdc20d..2cdefc54 100644 --- a/test/core/core_type_mat3x2.cpp +++ b/test/core/core_type_mat3x2.cpp @@ -28,10 +28,57 @@ static bool test_operators() return (S && !R) ? 0 : 1; } +int test_ctr() +{ + int Error(0); + +#if(GLM_HAS_INITIALIZER_LISTS) + glm::mat3x2 m0( + glm::vec2(0, 1), + glm::vec2(2, 3), + glm::vec2(4, 5)); + + glm::mat3x2 m1{0, 1, 2, 3, 4, 5}; + + glm::mat3x2 m2{ + {0, 1}, + {2, 3}, + {4, 5}}; + + for(int i = 0; i < m0.length(); ++i) + Error += glm::all(glm::equal(m0[i], m2[i])) ? 0 : 1; + + for(int i = 0; i < m1.length(); ++i) + Error += glm::all(glm::equal(m1[i], m2[i])) ? 0 : 1; + + std::vector v1{ + {0, 1, 2, 3, 4, 5, 6, 7, 8}, + {0, 1, 2, 3, 4, 5, 6, 7, 8} + }; + + std::vector v2{ + { + { 0, 1}, + { 2, 3}, + { 4, 5} + }, + { + { 0, 1}, + { 2, 3}, + { 4, 5} + } + }; + +#endif//GLM_HAS_INITIALIZER_LISTS + + return Error; +} + int main() { int Error = 0; + Error += test_ctr(); Error += test_operators(); return Error; diff --git a/test/core/core_type_mat3x3.cpp b/test/core/core_type_mat3x3.cpp index 7448f796..610d7ff2 100644 --- a/test/core/core_type_mat3x3.cpp +++ b/test/core/core_type_mat3x3.cpp @@ -86,10 +86,57 @@ int test_inverse() return Error; } +int test_ctr() +{ + int Error(0); + +#if(GLM_HAS_INITIALIZER_LISTS) + glm::mat3x3 m0( + glm::vec3(0, 1, 2), + glm::vec3(3, 4, 5), + glm::vec3(6, 7, 9)); + + glm::mat3x3 m1{0, 1, 2, 3, 4, 5, 6, 7, 8}; + + glm::mat3x3 m2{ + {0, 1, 2}, + {3, 4, 5}, + {6, 7, 8}}; + + for(int i = 0; i < m0.length(); ++i) + Error += glm::all(glm::equal(m0[i], m2[i])) ? 0 : 1; + + for(int i = 0; i < m1.length(); ++i) + Error += glm::all(glm::equal(m1[i], m2[i])) ? 0 : 1; + + std::vector v1{ + {0, 1, 2, 3, 4, 5, 6, 7, 8}, + {0, 1, 2, 3, 4, 5, 6, 7, 8} + }; + + std::vector v2{ + { + { 0, 1, 2}, + { 4, 5, 6}, + { 7, 8, 9} + }, + { + { 0, 1, 2}, + { 4, 5, 6}, + { 7, 8, 9} + } + }; + +#endif//GLM_HAS_INITIALIZER_LISTS + + return Error; +} + int main() { int Error = 0; + Error += test_ctr(); Error += test_mat3x3(); Error += test_operators(); Error += test_inverse(); diff --git a/test/core/core_type_mat3x4.cpp b/test/core/core_type_mat3x4.cpp index 140d4368..89573268 100644 --- a/test/core/core_type_mat3x4.cpp +++ b/test/core/core_type_mat3x4.cpp @@ -28,10 +28,56 @@ static bool test_operators() return (S && !R) ? 0 : 1; } +int test_ctr() +{ + int Error(0); + +#if(GLM_HAS_INITIALIZER_LISTS) + glm::mat3x4 m0( + glm::vec3(0, 1, 2), + glm::vec3(3, 4, 5), + glm::vec3(6, 7, 8), + glm::vec3(9, 10, 11)); + + glm::mat3x4 m1{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; + + glm::mat3x4 m2{ + {0, 1, 2}, + {3, 4, 5}, + {6, 7, 8}}; + + for(int i = 0; i < m0.length(); ++i) + Error += glm::all(glm::equal(m0[i], m2[i])) ? 0 : 1; + + for(int i = 0; i < m1.length(); ++i) + Error += glm::all(glm::equal(m1[i], m2[i])) ? 0 : 1; + + std::vector v1{ + {0, 1, 2, 3, 4, 5, 6, 7, 8}, + {0, 1, 2, 3, 4, 5, 6, 7, 8} + }; + + std::vector v2{ + { + { 0, 1, 2}, + { 4, 5, 6} + }, + { + { 0, 1, 2}, + { 4, 5, 6} + } + }; + +#endif//GLM_HAS_INITIALIZER_LISTS + + return Error; +} + int main() { int Error = 0; - + + Error += test_ctr(); Error += test_operators(); return Error;