Fixed gtc_swizzle test

This commit is contained in:
Christophe Riccio 2011-05-02 22:27:55 +01:00
parent 6eb7d8ad20
commit c3763826e8

View File

@ -13,114 +13,122 @@
int test_swizzle_vec4_ref_dynamic()
{
int Error = 0;
{
glm::ivec4 A(0, 1, 2, 3);
glm::ivec4 B(2, 1, 0, 3);
glm::swizzle(A, glm::Z, glm::Y, glm::X, glm::W) = B;
assert(A.x == B.x && A.y == B.y && A.z == B.z && A.w == B.w);
Error += (A.z == B.x && A.y == B.y && A.x == B.z && A.w == B.w) ? 0 : 1;
}
{
glm::ivec4 A(0, 1, 2, 3);
glm::ivec3 B(2, 1, 0);
glm::swizzle(A, glm::Z, glm::Y, glm::X) = B;
assert(A.x == B.x && A.y == B.y && A.z == B.z);
Error += (A.z == B.x && A.y == B.y && A.x == B.z) ? 0 : 1;
}
{
glm::ivec4 A(0, 1, 2, 3);
glm::ivec2 B(2, 1);
glm::swizzle(A, glm::Z, glm::Y) = B;
assert(A.x == B.x && A.y == B.y);
Error += (A.z == B.x && A.y == B.y) ? 0 : 1;
}
{
glm::ivec4 A(0, 1, 2, 3);
int B(2);
glm::swizzle(A, glm::Z) = B;
assert(A.x == B);
Error += (A.z == B) ? 0 : 1;
}
return 0;
return Error;
}
int test_swizzle_vec4_ref_static()
{
int Error = 0;
{
glm::ivec4 A(0, 1, 2, 3);
glm::ivec4 B(2, 1, 0, 3);
glm::swizzle<glm::Z, glm::Y, glm::X, glm::W>(A) = B;
assert(A.x == B.x && A.y == B.y && A.z == B.z && A.w == B.w);
Error += (A.z == B.x && A.y == B.y && A.x == B.z && A.w == B.w) ? 0 : 1;
}
{
glm::ivec4 A(0, 1, 2, 3);
glm::ivec3 B(2, 1, 0);
glm::swizzle<glm::Z, glm::Y, glm::X>(A) = B;
assert(A.x == B.x && A.y == B.y && A.z == B.z);
Error += (A.z == B.x && A.y == B.y && A.x == B.z) ? 0 : 1;
}
{
glm::ivec4 A(0, 1, 2, 3);
glm::ivec2 B(2, 1);
glm::swizzle<glm::Z, glm::Y>(A) = B;
assert(A.x == B.x && A.y == B.y);
Error += (A.z == B.x && A.y == B.y) ? 0 : 1;
}
{
glm::ivec4 A(0, 1, 2, 3);
int B(2);
glm::swizzle<glm::Z>(A) = B;
assert(A.x == B);
Error += (A.z == B) ? 0 : 1;
}
return 0;
return Error;
}
int test_swizzle_vec4_const_dynamic()
{
int Error = 0;
glm::ivec4 A(0, 1, 2, 3);
glm::ivec4 B = glm::swizzle(A, glm::B, glm::G, glm::R, glm::A);
assert(glm::all(glm::equal(A, B)));
Error += (glm::all(glm::equal(glm::ivec4(2, 1, 0, 3), B))) ? 0 : 1;
glm::ivec3 C = glm::swizzle(A, glm::W, glm::Y, glm::Z);
assert(glm::all(glm::equal(glm::ivec3(A), C)));
Error += (glm::all(glm::equal(glm::ivec3(3, 1, 2), C))) ? 0 : 1;
glm::ivec2 D = glm::swizzle(A, glm::W, glm::X);
assert(glm::all(glm::equal(glm::ivec2(A), D)));
Error += (glm::all(glm::equal(glm::ivec2(3, 0), D))) ? 0 : 1;
int E = glm::swizzle(A, glm::Q);
assert(E == A.q);
Error += (E == 3) ? 0 : 1;
return 0;
return Error;
}
int test_swizzle_vec4_const_static()
{
int Error = 0;
glm::ivec4 A(0, 1, 2, 3);
glm::ivec4 B = glm::swizzle<glm::B, glm::G, glm::R, glm::A>(A);
assert(glm::all(glm::equal(A, B)));
Error += (glm::all(glm::equal(glm::ivec4(2, 1, 0, 3), B))) ? 0 : 1;
glm::ivec3 C = glm::swizzle<glm::W, glm::Y, glm::Z>(A);
assert(glm::all(glm::equal(glm::ivec3(A), C)));
Error += (glm::all(glm::equal(glm::ivec3(3, 1, 2), C))) ? 0 : 1;
glm::ivec2 D = glm::swizzle<glm::W, glm::X>(A);
assert(glm::all(glm::equal(glm::ivec2(A), D)));
Error += (glm::all(glm::equal(glm::ivec2(3, 0), D))) ? 0 : 1;
int E = glm::swizzle<glm::Q>(A);
assert(E == A.q);
Error += (E == 3) ? 0 : 1;
return 0;
return Error;
}
int main()
{
int Failed = 0;
Failed += test_swizzle_vec4_ref_dynamic();
Failed += test_swizzle_vec4_ref_static();
Failed += test_swizzle_vec4_const_dynamic();
Failed += test_swizzle_vec4_const_static();
int Error = 0;
Error += test_swizzle_vec4_ref_dynamic();
Error += test_swizzle_vec4_ref_static();
Error += test_swizzle_vec4_const_dynamic();
Error += test_swizzle_vec4_const_static();
return Failed;
return Error;
}