From d917eaa479a3241d08bacac4d1bbe1ce881d669b Mon Sep 17 00:00:00 2001 From: Mikhail Romanko Date: Sun, 2 Feb 2025 22:51:28 +0300 Subject: Fix file and directory permissions --- .gitignore | 0 include/BH/Algo.h | 0 include/BH/Hashmap.h | 0 include/BH/Queue.h | 0 src/Algo.c | 0 src/Hashmap.c | 0 src/Queue.c | 0 test/CMakeLists.txt | 0 test/src/TestMath.c | 41 +++++++++++++++++++++++++++++++++++++++++ unit/CMakeLists.txt | 0 unit/include/BH/Unit.h | 0 unit/src/Unit.c | 17 +++++++++++++++++ 12 files changed, 58 insertions(+) mode change 100755 => 100644 .gitignore mode change 100755 => 100644 include/BH/Algo.h mode change 100755 => 100644 include/BH/Hashmap.h mode change 100755 => 100644 include/BH/Queue.h mode change 100755 => 100644 src/Algo.c mode change 100755 => 100644 src/Hashmap.c mode change 100755 => 100644 src/Queue.c mode change 100755 => 100644 test/CMakeLists.txt mode change 100755 => 100644 unit/CMakeLists.txt mode change 100755 => 100644 unit/include/BH/Unit.h mode change 100755 => 100644 unit/src/Unit.c 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; } -- cgit v1.2.3