diff --git a/.gitignore b/.gitignore old mode 100755 new mode 100644 diff --git a/include/BH/Algo.h b/include/BH/Algo.h old mode 100755 new mode 100644 diff --git a/include/BH/Hashmap.h b/include/BH/Hashmap.h old mode 100755 new mode 100644 diff --git a/include/BH/Queue.h b/include/BH/Queue.h old mode 100755 new mode 100644 diff --git a/src/Algo.c b/src/Algo.c old mode 100755 new mode 100644 diff --git a/src/Hashmap.c b/src/Hashmap.c old mode 100755 new mode 100644 diff --git a/src/Queue.c b/src/Queue.c old mode 100755 new mode 100644 diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt old mode 100755 new mode 100644 diff --git a/test/src/TestMath.c b/test/src/TestMath.c index e03ca96..a6fa15c 100644 --- a/test/src/TestMath.c +++ b/test/src/TestMath.c @@ -408,6 +408,47 @@ static int checkVec2i(void) static int checkQuat(void) { + float a[4], b[3], r[4]; + float roll, pitch, yaw, angle; + + a[0] = -0.9018f; a[1] = -0.0010f; a[2] = -0.4099f; a[3] = 0.1370f; + b[0] = -0.9104f; b[1] = -0.0010f; b[2] = -0.4138f; + + BH_Quat4fIdentity(r); + BH_VERIFY_DELTA(r[0], 0.000f, ACCEPTABLE_DELTA); + BH_VERIFY_DELTA(r[1], 0.000f, ACCEPTABLE_DELTA); + BH_VERIFY_DELTA(r[2], 0.000f, ACCEPTABLE_DELTA); + BH_VERIFY_DELTA(r[3], 1.000f, ACCEPTABLE_DELTA); + + BH_Quat4fConjugate(a, r); + BH_VERIFY_DELTA(r[0], 0.9018f, ACCEPTABLE_DELTA); + BH_VERIFY_DELTA(r[1], 0.0010f, ACCEPTABLE_DELTA); + BH_VERIFY_DELTA(r[2], 0.4099f, ACCEPTABLE_DELTA); + BH_VERIFY_DELTA(r[3], 0.1370f, ACCEPTABLE_DELTA); + + BH_Quat4fToEuler(a, &roll, &pitch, &yaw); + BH_VERIFY_DELTA(roll, -2.7671f, ACCEPTABLE_DELTA); + BH_VERIFY_DELTA(pitch, -0.8324f, ACCEPTABLE_DELTA); + BH_VERIFY_DELTA(yaw, -0.1649f, ACCEPTABLE_DELTA); + + BH_Quat4fFromEuler(-2.7671f, -0.8324f, -0.1649f, r); + BH_VERIFY_DELTA(r[0], -0.9018f, ACCEPTABLE_DELTA); + BH_VERIFY_DELTA(r[1], -0.0010f, ACCEPTABLE_DELTA); + BH_VERIFY_DELTA(r[2], -0.4099f, ACCEPTABLE_DELTA); + BH_VERIFY_DELTA(r[3], 0.1370f, ACCEPTABLE_DELTA); + + BH_Quat4fFromAxis(b, 2.8668f, r); + BH_VERIFY_DELTA(r[0], -0.9018f, ACCEPTABLE_DELTA); + BH_VERIFY_DELTA(r[1], -0.0010f, ACCEPTABLE_DELTA); + BH_VERIFY_DELTA(r[2], -0.4099f, ACCEPTABLE_DELTA); + BH_VERIFY_DELTA(r[3], 0.1370f, ACCEPTABLE_DELTA); + + BH_Quat4fToAxis(a, r, &angle); + BH_VERIFY_DELTA(r[0], -0.9104f, ACCEPTABLE_DELTA); + BH_VERIFY_DELTA(r[1], -0.0010f, ACCEPTABLE_DELTA); + BH_VERIFY_DELTA(r[2], -0.4138f, ACCEPTABLE_DELTA); + BH_VERIFY_DELTA(angle, 2.8668f, ACCEPTABLE_DELTA); + return 0; } diff --git a/unit/CMakeLists.txt b/unit/CMakeLists.txt old mode 100755 new mode 100644 diff --git a/unit/include/BH/Unit.h b/unit/include/BH/Unit.h old mode 100755 new mode 100644 diff --git a/unit/src/Unit.c b/unit/src/Unit.c old mode 100755 new mode 100644 index ead5449..57d80b1 --- a/unit/src/Unit.c +++ b/unit/src/Unit.c @@ -12,6 +12,21 @@ typedef struct BH_Unit static BH_Unit *root = NULL; +static void BH_UnitCleanup(void) +{ + BH_Unit *current; + + current = root; + while (current) + { + BH_Unit *next = current->next; + + free(current); + current = next; + } +} + + void BH_UnitAdd(const char *name, BH_UnitCallback cb) { BH_Unit *unit, *current; @@ -49,6 +64,7 @@ int BH_UnitRun(void) if (current->cb()) { printf("\tFAIL\n"); + BH_UnitCleanup(); return -1; } printf("\tPASS\n"); @@ -56,6 +72,7 @@ int BH_UnitRun(void) current = current->next; } + BH_UnitCleanup(); return 0; }