Completed initializer list tests

This commit is contained in:
Christophe Riccio 2013-10-05 14:02:33 +02:00
parent a699f336f5
commit 5ea160413d
5 changed files with 228 additions and 2 deletions

View File

@ -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<glm::mat2x3> v1{
{0, 1, 2, 3, 4, 5},
{0, 1, 2, 3, 4, 5}
};
std::vector<glm::mat2x3> 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;

View File

@ -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<glm::mat2x4> v1{
{0, 1, 2, 3, 4, 5, 6, 7},
{0, 1, 2, 3, 4, 5, 6, 7}
};
std::vector<glm::mat2x4> 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;

View File

@ -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<glm::mat3x2> v1{
{0, 1, 2, 3, 4, 5, 6, 7, 8},
{0, 1, 2, 3, 4, 5, 6, 7, 8}
};
std::vector<glm::mat3x2> 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;

View File

@ -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<glm::mat3x3> v1{
{0, 1, 2, 3, 4, 5, 6, 7, 8},
{0, 1, 2, 3, 4, 5, 6, 7, 8}
};
std::vector<glm::mat3x3> 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();

View File

@ -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<glm::mat3x4> v1{
{0, 1, 2, 3, 4, 5, 6, 7, 8},
{0, 1, 2, 3, 4, 5, 6, 7, 8}
};
std::vector<glm::mat3x4> 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;