Added vec3 operator tests

This commit is contained in:
Christophe Riccio 2011-09-25 05:38:30 +01:00
parent 82ffd4aaf3
commit 426082bfbf
2 changed files with 98 additions and 3 deletions

View File

@ -37,6 +37,101 @@ static int test_vec3_operators()
glm::vec3 F = B / A;
Error += F == glm::vec3(4, 2.5, 2) ? 0 : 1;
glm::vec3 G = A + 1.0f;
Error += G == glm::vec3(2, 3, 4) ? 0 : 1;
glm::vec3 H = B - 1.0f;
Error += H == glm::vec3(3, 4, 5) ? 0 : 1;
glm::vec3 I = A * 2.0f;
Error += I == glm::vec3(2, 4, 6) ? 0 : 1;
glm::vec3 J = B / 2.0f;
Error += J == glm::vec3(2, 2.5, 3) ? 0 : 1;
glm::vec3 K = 1.0f + A;
Error += K == glm::vec3(2, 3, 4) ? 0 : 1;
glm::vec3 L = 1.0f - B;
Error += L == glm::vec3(-3, -4, -5) ? 0 : 1;
glm::vec3 M = 2.0f * A;
Error += M == glm::vec3(2, 4, 6) ? 0 : 1;
glm::vec3 N = 2.0f / B;
Error += N == glm::vec3(0.5, 2.0 / 5.0, 2.0 / 6.0) ? 0 : 1;
}
{
glm::vec3 A(1.0f, 2.0f, 3.0f);
glm::vec3 B(4.0f, 5.0f, 6.0f);
A += B;
Error += A == glm::vec3(5, 7, 9) ? 0 : 1;
A += 1.0f;
Error += A == glm::vec3(6, 8, 10) ? 0 : 1;
}
{
glm::vec3 A(1.0f, 2.0f, 3.0f);
glm::vec3 B(4.0f, 5.0f, 6.0f);
B -= A;
Error += B == glm::vec3(3, 3, 3) ? 0 : 1;
B -= 1.0f;
Error += B == glm::vec3(2, 2, 2) ? 0 : 1;
}
{
glm::vec3 A(1.0f, 2.0f, 3.0f);
glm::vec3 B(4.0f, 5.0f, 6.0f);
A *= B;
Error += A == glm::vec3(4, 10, 18) ? 0 : 1;
A *= 2.0f;
Error += A == glm::vec3(8, 20, 36) ? 0 : 1;
}
{
glm::vec3 A(1.0f, 2.0f, 3.0f);
glm::vec3 B(4.0f, 5.0f, 6.0f);
B /= A;
Error += B == glm::vec3(4, 2.5, 2) ? 0 : 1;
B /= 2.0f;
Error += B == glm::vec3(2, 1.25, 1) ? 0 : 1;
}
{
glm::vec3 A(1.0f, 2.0f, 3.0f);
glm::vec3 B = -A;
Error += B == glm::vec3(-1.0f, -2.0f, -3.0f) ? 0 : 1;
}
{
glm::vec3 A(1.0f, 2.0f, 3.0f);
glm::vec3 B = --A;
Error += B == glm::vec3(0.0f, 1.0f, 2.0f) ? 0 : 1;
}
{
glm::vec3 A(1.0f, 2.0f, 3.0f);
glm::vec3 B = A--;
Error += B == glm::vec3(0.0f, 1.0f, 2.0f) ? 0 : 1;
}
{
glm::vec3 A(1.0f, 2.0f, 3.0f);
glm::vec3 B = ++A;
Error += B == glm::vec3(2.0f, 3.0f, 4.0f) ? 0 : 1;
}
{
glm::vec3 A(1.0f, 2.0f, 3.0f);
glm::vec3 B = A++;
Error += B == glm::vec3(2.0f, 3.0f, 4.0f) ? 0 : 1;
}
return Error;

View File

@ -23,7 +23,7 @@ int test_simplex()
for(std::size_t y = 0; y < Size; ++y)
for(std::size_t x = 0; x < Size; ++x)
{
ImageData[(x + y * Size) * 3 + 0] = glm::byte(glm::simplex(glm::vec2(x / 16.f, y / 16.f)) * 128.f + 127.f);
ImageData[(x + y * Size) * 3 + 0] = glm::byte(glm::simplex(glm::vec2(x / 32.f, y / 32.f)) * 128.f + 127.f);
ImageData[(x + y * Size) * 3 + 1] = ImageData[(x + y * Size) * 3 + 0];
ImageData[(x + y * Size) * 3 + 2] = ImageData[(x + y * Size) * 3 + 0];
}
@ -40,7 +40,7 @@ int test_simplex()
for(std::size_t y = 0; y < Size; ++y)
for(std::size_t x = 0; x < Size; ++x)
{
ImageData[(x + y * Size) * 3 + 0] = glm::byte(glm::simplex(glm::vec3(x / 16.f, y / 16.f, 0.5f)) * 128.f + 127.f);
ImageData[(x + y * Size) * 3 + 0] = glm::byte(glm::simplex(glm::vec3(x / 32.f, y / 32.f, 0.5f)) * 128.f + 127.f);
ImageData[(x + y * Size) * 3 + 1] = ImageData[(x + y * Size) * 3 + 0];
ImageData[(x + y * Size) * 3 + 2] = ImageData[(x + y * Size) * 3 + 0];
}
@ -57,7 +57,7 @@ int test_simplex()
for(std::size_t y = 0; y < Size; ++y)
for(std::size_t x = 0; x < Size; ++x)
{
ImageData[(x + y * Size) * 3 + 0] = glm::byte(glm::simplex(glm::vec4(x / 16.f, y / 16.f, 0.5f, 0.5f)) * 128.f + 127.f);
ImageData[(x + y * Size) * 3 + 0] = glm::byte(glm::simplex(glm::vec4(x / 32.f, y / 32.f, 0.5f, 0.5f)) * 128.f + 127.f);
ImageData[(x + y * Size) * 3 + 1] = ImageData[(x + y * Size) * 3 + 0];
ImageData[(x + y * Size) * 3 + 2] = ImageData[(x + y * Size) * 3 + 0];
}