Refactored GLM_FORCE_MESSAGES, added swizzle operators and functions tests

This commit is contained in:
Christophe Riccio
2018-07-14 17:56:40 +02:00
parent d50c699515
commit 4db3abe6b5
6 changed files with 140 additions and 83 deletions

View File

@@ -6,14 +6,39 @@ static int test_ivec2_swizzle()
{
int Error = 0;
#if GLM_SWIZZLE == GLM_ENABLE
glm::ivec2 A(1, 2);
glm::ivec2 B = A.yx();
glm::ivec2 C = B.yx();
# if GLM_SWIZZLE
{
glm::ivec2 A(1, 2);
glm::ivec2 B = A.yx();
glm::ivec2 C = B.yx();
Error += A != B ? 0 : 1;
Error += A == C ? 0 : 1;
#endif//GLM_SWIZZLE == GLM_ENABLE
Error += A != B ? 0 : 1;
Error += A == C ? 0 : 1;
}
# endif//GLM_SWIZZLE
# if GLM_SWIZZLE == GLM_SWIZZLE_OPERATOR
{
glm::ivec2 A(1, 2);
glm::ivec2 B = A.yx;
glm::ivec2 C = A.yx;
Error += A != B ? 0 : 1;
Error += B == C ? 0 : 1;
B.xy = B.yx;
C.xy = C.yx;
Error += B == C ? 0 : 1;
glm::ivec2 D(0, 0);
D.yx = A.xy;
Error += A.yx() == D ? 0 : 1;
glm::ivec2 E = A.yx;
Error += E == D ? 0 : 1;
}
# endif//GLM_SWIZZLE
return Error;
}
@@ -22,14 +47,43 @@ int test_ivec3_swizzle()
{
int Error = 0;
#if GLM_SWIZZLE == GLM_ENABLE
glm::ivec3 A(1, 2, 3);
glm::ivec3 B = A.zyx();
glm::ivec3 C = B.zyx();
# if GLM_SWIZZLE == GLM_ENABLE
{
glm::ivec3 A(1, 2, 3);
glm::ivec3 B = A.zyx();
glm::ivec3 C = B.zyx();
Error += A != B ? 0 : 1;
Error += A == C ? 0 : 1;
#endif//GLM_SWIZZLE == GLM_ENABLE
Error += A != B ? 0 : 1;
Error += A == C ? 0 : 1;
}
# endif//GLM_SWIZZLE == GLM_ENABLE
# if GLM_SWIZZLE == GLM_SWIZZLE_OPERATOR
{
glm::ivec3 A(1, 2, 3);
glm::ivec2 B = A.yx;
glm::ivec2 C = A.yx;
Error += A.yx() == B ? 0 : 1;
Error += B == C ? 0 : 1;
B.xy = B.yx;
C.xy = C.yx;
Error += B == C ? 0 : 1;
glm::ivec2 D(0, 0);
D.yx = A.xy;
Error += A.yx() == D ? 0 : 1;
glm::ivec2 E(0, 0);
E.xy = A.xy();
Error += E == A.xy() ? 0 : 1;
Error += E.xy() == A.xy() ? 0 : 1;
}
# endif//GLM_SWIZZLE
return Error;
}