diff options
| -rw-r--r--[-rwxr-xr-x] | .gitignore | 0 | ||||
| -rw-r--r--[-rwxr-xr-x] | include/BH/Algo.h | 0 | ||||
| -rw-r--r--[-rwxr-xr-x] | include/BH/Hashmap.h | 0 | ||||
| -rw-r--r--[-rwxr-xr-x] | include/BH/Queue.h | 0 | ||||
| -rw-r--r--[-rwxr-xr-x] | src/Algo.c | 0 | ||||
| -rw-r--r--[-rwxr-xr-x] | src/Hashmap.c | 0 | ||||
| -rw-r--r--[-rwxr-xr-x] | src/Queue.c | 0 | ||||
| -rw-r--r--[-rwxr-xr-x] | test/CMakeLists.txt | 0 | ||||
| -rw-r--r-- | test/src/TestMath.c | 41 | ||||
| -rw-r--r--[-rwxr-xr-x] | unit/CMakeLists.txt | 0 | ||||
| -rw-r--r--[-rwxr-xr-x] | unit/include/BH/Unit.h | 0 | ||||
| -rw-r--r--[-rwxr-xr-x] | unit/src/Unit.c | 17 |
12 files changed, 58 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore index f1c4374..f1c4374 100755..100644 --- a/.gitignore +++ b/.gitignore diff --git a/include/BH/Algo.h b/include/BH/Algo.h index 2e5320e..2e5320e 100755..100644 --- a/include/BH/Algo.h +++ b/include/BH/Algo.h diff --git a/include/BH/Hashmap.h b/include/BH/Hashmap.h index 615e747..615e747 100755..100644 --- a/include/BH/Hashmap.h +++ b/include/BH/Hashmap.h diff --git a/include/BH/Queue.h b/include/BH/Queue.h index 5d6af58..5d6af58 100755..100644 --- a/include/BH/Queue.h +++ b/include/BH/Queue.h diff --git a/src/Algo.c b/src/Algo.c index 7d0abcd..7d0abcd 100755..100644 --- a/src/Algo.c +++ b/src/Algo.c diff --git a/src/Hashmap.c b/src/Hashmap.c index ad8e7bd..ad8e7bd 100755..100644 --- a/src/Hashmap.c +++ b/src/Hashmap.c diff --git a/src/Queue.c b/src/Queue.c index 4b9d06e..4b9d06e 100755..100644 --- a/src/Queue.c +++ b/src/Queue.c diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 19d1cae..19d1cae 100755..100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt 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 index 42e9ffb..42e9ffb 100755..100644 --- a/unit/CMakeLists.txt +++ b/unit/CMakeLists.txt diff --git a/unit/include/BH/Unit.h b/unit/include/BH/Unit.h index 3b3b2b6..3b3b2b6 100755..100644 --- a/unit/include/BH/Unit.h +++ b/unit/include/BH/Unit.h diff --git a/unit/src/Unit.c b/unit/src/Unit.c index ead5449..57d80b1 100755..100644 --- 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; } |
