Fixed post in/decrement operators

This commit is contained in:
Christophe Riccio
2013-05-08 21:52:21 +02:00
parent 28c6bba18c
commit 691f04e14f
15 changed files with 273 additions and 105 deletions

View File

@@ -9,8 +9,9 @@
#define GLM_SWIZZLE
#include <glm/glm.hpp>
#include <glm/gtx/vec1.hpp>
static int test_operators()
int test_operators()
{
glm::vec4 A(1.0f);
glm::vec4 B(1.0f);
@@ -20,11 +21,39 @@ static int test_operators()
return (S && !R) ? 0 : 1;
}
int test_operator_increment()
{
int Error(0);
glm::ivec1 v0(1);
glm::ivec1 v1(v0);
glm::ivec1 v2(v0);
glm::ivec1 v3 = ++v1;
glm::ivec1 v4 = v2++;
Error += glm::all(glm::equal(v0, v4)) ? 0 : 1;
Error += glm::all(glm::equal(v1, v2)) ? 0 : 1;
Error += glm::all(glm::equal(v1, v3)) ? 0 : 1;
int i0(1);
int i1(i0);
int i2(i0);
int i3 = ++i1;
int i4 = i2++;
Error += i0 == i4 ? 0 : 1;
Error += i1 == i2 ? 0 : 1;
Error += i1 == i3 ? 0 : 1;
return Error;
}
int main()
{
int Error = 0;
Error += test_operators();
Error += test_operator_increment();
return Error;
}

View File

@@ -218,6 +218,33 @@ int test_vec2_size()
return Error;
}
int test_operator_increment()
{
int Error(0);
glm::ivec2 v0(1);
glm::ivec2 v1(v0);
glm::ivec2 v2(v0);
glm::ivec2 v3 = ++v1;
glm::ivec2 v4 = v2++;
Error += glm::all(glm::equal(v0, v4)) ? 0 : 1;
Error += glm::all(glm::equal(v1, v2)) ? 0 : 1;
Error += glm::all(glm::equal(v1, v3)) ? 0 : 1;
int i0(1);
int i1(i0);
int i2(i0);
int i3 = ++i1;
int i4 = i2++;
Error += i0 == i4 ? 0 : 1;
Error += i1 == i2 ? 0 : 1;
Error += i1 == i3 ? 0 : 1;
return Error;
}
int main()
{
int Error = 0;
@@ -225,6 +252,7 @@ int main()
Error += test_vec2_size();
Error += test_vec2_ctor();
Error += test_vec2_operators();
Error += test_operator_increment();
return Error;
}

View File

@@ -421,6 +421,33 @@ int test_vec3_swizzle_partial()
return Error;
}
int test_operator_increment()
{
int Error(0);
glm::ivec3 v0(1);
glm::ivec3 v1(v0);
glm::ivec3 v2(v0);
glm::ivec3 v3 = ++v1;
glm::ivec3 v4 = v2++;
Error += glm::all(glm::equal(v0, v4)) ? 0 : 1;
Error += glm::all(glm::equal(v1, v2)) ? 0 : 1;
Error += glm::all(glm::equal(v1, v3)) ? 0 : 1;
int i0(1);
int i1(i0);
int i2(i0);
int i3 = ++i1;
int i4 = i2++;
Error += i0 == i4 ? 0 : 1;
Error += i1 == i2 ? 0 : 1;
Error += i1 == i3 ? 0 : 1;
return Error;
}
int main()
{
int Error = 0;
@@ -434,6 +461,7 @@ int main()
Error += test_vec3_swizzle_partial();
Error += test_vec3_swizzle_operators();
Error += test_vec3_swizzle_functions();
Error += test_operator_increment();
return Error;
}

View File

@@ -255,17 +255,47 @@ int test_vec4_swizzle_partial()
return Error;
}
int test_operator_increment()
{
int Error(0);
glm::ivec4 v0(1);
glm::ivec4 v1(v0);
glm::ivec4 v2(v0);
glm::ivec4 v3 = ++v1;
glm::ivec4 v4 = v2++;
Error += glm::all(glm::equal(v0, v4)) ? 0 : 1;
Error += glm::all(glm::equal(v1, v2)) ? 0 : 1;
Error += glm::all(glm::equal(v1, v3)) ? 0 : 1;
int i0(1);
int i1(i0);
int i2(i0);
int i3 = ++i1;
int i4 = i2++;
Error += i0 == i4 ? 0 : 1;
Error += i1 == i2 ? 0 : 1;
Error += i1 == i3 ? 0 : 1;
return Error;
}
int main()
{
//__m128 DataA = swizzle<X, Y, Z, W>(glm::vec4(1.0f, 2.0f, 3.0f, 4.0f));
//__m128 DataB = swizzle<W, Z, Y, X>(glm::vec4(1.0f, 2.0f, 3.0f, 4.0f));
int Error = 0;
int Error(0);
Error += test_vec4_ctor();
Error += test_vec4_size();
Error += test_vec4_operators();
Error += test_hvec4();
Error += test_vec4_swizzle_partial();
Error += test_operator_increment();
return Error;
}