Модульные тесты для кватернионов
This commit is contained in:
parent
2fae0154ac
commit
899ca7dd52
63 changed files with 1233 additions and 284 deletions
|
|
@ -150,16 +150,24 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="helpers.c" />
|
<ClCompile Include="helpers.c" />
|
||||||
<ClCompile Include="main.c" />
|
<ClCompile Include="main.c" />
|
||||||
|
<ClCompile Include="tests\quaternion.c" />
|
||||||
|
<ClCompile Include="tests\quaternion\quaternion_copy.c" />
|
||||||
|
<ClCompile Include="tests\quaternion\quaternion_reset.c" />
|
||||||
|
<ClCompile Include="tests\quaternion\quaternion_set_to_identity.c" />
|
||||||
|
<ClCompile Include="tests\quaternion\quaternion_set_values.c" />
|
||||||
|
<ClCompile Include="tests\quaternion\quaternion_swap.c" />
|
||||||
<ClCompile Include="tests\utilities.c" />
|
<ClCompile Include="tests\utilities.c" />
|
||||||
<ClCompile Include="tests\utilities\are_close.c" />
|
<ClCompile Include="tests\utilities\are_close.c" />
|
||||||
<ClCompile Include="tests\utilities\is_unit.c" />
|
<ClCompile Include="tests\utilities\is_unit.c" />
|
||||||
<ClCompile Include="tests\utilities\is_zero.c" />
|
<ClCompile Include="tests\utilities\is_zero.c" />
|
||||||
<ClCompile Include="tests\vector2.c" />
|
<ClCompile Include="tests\vector2.c" />
|
||||||
|
<ClCompile Include="tests\vector2\vector2_is_zero.c" />
|
||||||
<ClCompile Include="tests\vector2\vector2_copy.c" />
|
<ClCompile Include="tests\vector2\vector2_copy.c" />
|
||||||
<ClCompile Include="tests\vector2\vector2_reset.c" />
|
<ClCompile Include="tests\vector2\vector2_reset.c" />
|
||||||
<ClCompile Include="tests\vector2\vector2_set_values.c" />
|
<ClCompile Include="tests\vector2\vector2_set_values.c" />
|
||||||
<ClCompile Include="tests\vector2\vector2_swap.c" />
|
<ClCompile Include="tests\vector2\vector2_swap.c" />
|
||||||
<ClCompile Include="tests\vector3.c" />
|
<ClCompile Include="tests\vector3.c" />
|
||||||
|
<ClCompile Include="tests\vector3\vector3_is_zero.c" />
|
||||||
<ClCompile Include="tests\vector3\vector3_copy.c" />
|
<ClCompile Include="tests\vector3\vector3_copy.c" />
|
||||||
<ClCompile Include="tests\vector3\vector3_swap.c" />
|
<ClCompile Include="tests\vector3\vector3_swap.c" />
|
||||||
<ClCompile Include="tests\vector3\vector3_reset.c" />
|
<ClCompile Include="tests\vector3\vector3_reset.c" />
|
||||||
|
|
@ -174,16 +182,24 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="helpers.h" />
|
<ClInclude Include="helpers.h" />
|
||||||
|
<ClInclude Include="tests\quaternion.h" />
|
||||||
|
<ClInclude Include="tests\quaternion\quaternion_copy.h" />
|
||||||
|
<ClInclude Include="tests\quaternion\quaternion_reset.h" />
|
||||||
|
<ClInclude Include="tests\quaternion\quaternion_set_to_identity.h" />
|
||||||
|
<ClInclude Include="tests\quaternion\quaternion_set_values.h" />
|
||||||
|
<ClInclude Include="tests\quaternion\quaternion_swap.h" />
|
||||||
<ClInclude Include="tests\utilities.h" />
|
<ClInclude Include="tests\utilities.h" />
|
||||||
<ClInclude Include="tests\utilities\are_close.h" />
|
<ClInclude Include="tests\utilities\are_close.h" />
|
||||||
<ClInclude Include="tests\utilities\is_unit.h" />
|
<ClInclude Include="tests\utilities\is_unit.h" />
|
||||||
<ClInclude Include="tests\utilities\is_zero.h" />
|
<ClInclude Include="tests\utilities\is_zero.h" />
|
||||||
<ClInclude Include="tests\vector2.h" />
|
<ClInclude Include="tests\vector2.h" />
|
||||||
|
<ClInclude Include="tests\vector2\vector2_is_zero.h" />
|
||||||
<ClInclude Include="tests\vector2\vector2_copy.h" />
|
<ClInclude Include="tests\vector2\vector2_copy.h" />
|
||||||
<ClInclude Include="tests\vector2\vector2_reset.h" />
|
<ClInclude Include="tests\vector2\vector2_reset.h" />
|
||||||
<ClInclude Include="tests\vector2\vector2_set_values.h" />
|
<ClInclude Include="tests\vector2\vector2_set_values.h" />
|
||||||
<ClInclude Include="tests\vector2\vector2_swap.h" />
|
<ClInclude Include="tests\vector2\vector2_swap.h" />
|
||||||
<ClInclude Include="tests\vector3.h" />
|
<ClInclude Include="tests\vector3.h" />
|
||||||
|
<ClInclude Include="tests\vector3\vector3_is_zero.h" />
|
||||||
<ClInclude Include="tests\vector3\vector3_copy.h" />
|
<ClInclude Include="tests\vector3\vector3_copy.h" />
|
||||||
<ClInclude Include="tests\vector3\vector3_swap.h" />
|
<ClInclude Include="tests\vector3\vector3_swap.h" />
|
||||||
<ClInclude Include="tests\vector3\vector3_reset.h" />
|
<ClInclude Include="tests\vector3\vector3_reset.h" />
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,30 @@
|
||||||
<ClCompile Include="tests\versor\versor_swap.c">
|
<ClCompile Include="tests\versor\versor_swap.c">
|
||||||
<Filter>tests\versor</Filter>
|
<Filter>tests\versor</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="tests\quaternion\quaternion_copy.c">
|
||||||
|
<Filter>tests\quaternion</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="tests\quaternion\quaternion_reset.c">
|
||||||
|
<Filter>tests\quaternion</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="tests\quaternion\quaternion_set_values.c">
|
||||||
|
<Filter>tests\quaternion</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="tests\quaternion\quaternion_swap.c">
|
||||||
|
<Filter>tests\quaternion</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="tests\quaternion.c">
|
||||||
|
<Filter>tests</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="tests\quaternion\quaternion_set_to_identity.c">
|
||||||
|
<Filter>tests\quaternion</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="tests\vector3\vector3_is_zero.c">
|
||||||
|
<Filter>tests\vector3</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="tests\vector2\vector2_is_zero.c">
|
||||||
|
<Filter>tests\vector2</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="helpers.h" />
|
<ClInclude Include="helpers.h" />
|
||||||
|
|
@ -132,6 +156,30 @@
|
||||||
<ClInclude Include="tests\versor\versor_swap.h">
|
<ClInclude Include="tests\versor\versor_swap.h">
|
||||||
<Filter>tests\versor</Filter>
|
<Filter>tests\versor</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="tests\quaternion\quaternion_copy.h">
|
||||||
|
<Filter>tests\quaternion</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="tests\quaternion\quaternion_reset.h">
|
||||||
|
<Filter>tests\quaternion</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="tests\quaternion\quaternion_set_values.h">
|
||||||
|
<Filter>tests\quaternion</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="tests\quaternion\quaternion_swap.h">
|
||||||
|
<Filter>tests\quaternion</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="tests\quaternion.h">
|
||||||
|
<Filter>tests</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="tests\quaternion\quaternion_set_to_identity.h">
|
||||||
|
<Filter>tests\quaternion</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="tests\vector3\vector3_is_zero.h">
|
||||||
|
<Filter>tests\vector3</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="tests\vector2\vector2_is_zero.h">
|
||||||
|
<Filter>tests\vector2</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Filter Include="tests">
|
<Filter Include="tests">
|
||||||
|
|
@ -149,5 +197,8 @@
|
||||||
<Filter Include="tests\versor">
|
<Filter Include="tests\versor">
|
||||||
<UniqueIdentifier>{d6f82407-8310-4b32-b153-aa67e766c72a}</UniqueIdentifier>
|
<UniqueIdentifier>{d6f82407-8310-4b32-b153-aa67e766c72a}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
<Filter Include="tests\quaternion">
|
||||||
|
<UniqueIdentifier>{e8bafdb8-66e5-4393-bc89-8bff83bcccd6}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
#include "tests/utilities.h"
|
#include "tests/utilities.h"
|
||||||
#include "tests/vector2.h"
|
#include "tests/vector2.h"
|
||||||
#include "tests/vector3.h"
|
#include "tests/vector3.h"
|
||||||
|
#include "tests/quaternion.h"
|
||||||
#include "tests/versor.h"
|
#include "tests/versor.h"
|
||||||
|
|
||||||
#define PROGRAM_SUCCESS 0
|
#define PROGRAM_SUCCESS 0
|
||||||
|
|
@ -25,6 +26,10 @@ int main()
|
||||||
return PROGRAM_FAILED;
|
return PROGRAM_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (test_quaternion() == TEST_FAILED) {
|
||||||
|
return PROGRAM_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
if (test_versor() == TEST_FAILED) {
|
if (test_versor() == TEST_FAILED) {
|
||||||
return PROGRAM_FAILED;
|
return PROGRAM_FAILED;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
28
basic-geometry-test/tests/quaternion.c
Normal file
28
basic-geometry-test/tests/quaternion.c
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
#include "quaternion.h"
|
||||||
|
|
||||||
|
int test_quaternion()
|
||||||
|
{
|
||||||
|
print_testing_section("BGC Quaternion");
|
||||||
|
|
||||||
|
if (test_bgc_quaternion_reset() != TEST_SUCCES) {
|
||||||
|
return TEST_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (test_bgc_quaternion_set_to_identity() != TEST_SUCCES) {
|
||||||
|
return TEST_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (test_bgc_quaternion_set_values() != TEST_SUCCES) {
|
||||||
|
return TEST_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (test_bgc_quaternion_copy() != TEST_SUCCES) {
|
||||||
|
return TEST_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (test_bgc_quaternion_swap() != TEST_SUCCES) {
|
||||||
|
return TEST_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TEST_SUCCES;
|
||||||
|
}
|
||||||
13
basic-geometry-test/tests/quaternion.h
Normal file
13
basic-geometry-test/tests/quaternion.h
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
#ifndef _TEST_QUATERNION_H_
|
||||||
|
#define _TEST_QUATERNION_H_
|
||||||
|
|
||||||
|
#include "./../helpers.h"
|
||||||
|
#include "./quaternion/quaternion_reset.h"
|
||||||
|
#include "./quaternion/quaternion_set_to_identity.h"
|
||||||
|
#include "./quaternion/quaternion_set_values.h"
|
||||||
|
#include "./quaternion/quaternion_copy.h"
|
||||||
|
#include "./quaternion/quaternion_swap.h"
|
||||||
|
|
||||||
|
int test_quaternion();
|
||||||
|
|
||||||
|
#endif
|
||||||
86
basic-geometry-test/tests/quaternion/quaternion_copy.c
Normal file
86
basic-geometry-test/tests/quaternion/quaternion_copy.c
Normal file
|
|
@ -0,0 +1,86 @@
|
||||||
|
#include "./quaternion_copy.h"
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#include "./../../helpers.h"
|
||||||
|
|
||||||
|
// ==================== FP32 ==================== //
|
||||||
|
|
||||||
|
static const int _TEST_FP32_QUATERNION_AMOUNT = 4;
|
||||||
|
static const BgcQuaternionFP32 _TEST_FP32_QUATERNION_LIST[] = {
|
||||||
|
{ 1.0f, 2.0f, 3.0f, 4.0f },
|
||||||
|
{ -4.0f, -3.0f, -2.0f, -1.0f },
|
||||||
|
{ -0.001f, 100.0f, -100.0f, 0.001f },
|
||||||
|
{ 0.001f, -100.0f, 100.0f, -0.001f }
|
||||||
|
};
|
||||||
|
|
||||||
|
int test_bgc_quaternion_copy_fp32()
|
||||||
|
{
|
||||||
|
BgcQuaternionFP32 vector;
|
||||||
|
|
||||||
|
print_testing_name("bgc_quaternion_copy_fp32");
|
||||||
|
|
||||||
|
for (int i = 0; i < _TEST_FP32_QUATERNION_AMOUNT; i++) {
|
||||||
|
|
||||||
|
bgc_quaternion_copy_fp32(&_TEST_FP32_QUATERNION_LIST[i], &vector);
|
||||||
|
|
||||||
|
if (vector.s0 != _TEST_FP32_QUATERNION_LIST[i].s0 ||
|
||||||
|
vector.x1 != _TEST_FP32_QUATERNION_LIST[i].x1 ||
|
||||||
|
vector.x2 != _TEST_FP32_QUATERNION_LIST[i].x2 ||
|
||||||
|
vector.x3 != _TEST_FP32_QUATERNION_LIST[i].x3) {
|
||||||
|
print_testing_failed();
|
||||||
|
return TEST_FAILED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
print_testing_success();
|
||||||
|
|
||||||
|
return TEST_SUCCES;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==================== FP64 ==================== //
|
||||||
|
|
||||||
|
static const int _TEST_FP64_QUATERNION_AMOUNT = 4;
|
||||||
|
static const BgcQuaternionFP64 _TEST_FP64_QUATERNION_LIST[] = {
|
||||||
|
{ 1.0, 2.0, 3.0, 4.0 },
|
||||||
|
{ -4.0, -3.0, -2.0, -1.0 },
|
||||||
|
{ -0.001, 100.0, -100.0, 0.001 },
|
||||||
|
{ 0.001, -100.0, 100.0, -0.001 }
|
||||||
|
};
|
||||||
|
|
||||||
|
int test_bgc_quaternion_copy_fp64()
|
||||||
|
{
|
||||||
|
BgcQuaternionFP64 vector;
|
||||||
|
|
||||||
|
print_testing_name("bgc_quaternion_copy_fp64");
|
||||||
|
|
||||||
|
for (int i = 0; i < _TEST_FP64_QUATERNION_AMOUNT; i++) {
|
||||||
|
|
||||||
|
bgc_quaternion_copy_fp64(&_TEST_FP64_QUATERNION_LIST[i], &vector);
|
||||||
|
|
||||||
|
if (vector.s0 != _TEST_FP64_QUATERNION_LIST[i].s0 ||
|
||||||
|
vector.x1 != _TEST_FP64_QUATERNION_LIST[i].x1 ||
|
||||||
|
vector.x2 != _TEST_FP64_QUATERNION_LIST[i].x2 ||
|
||||||
|
vector.x3 != _TEST_FP64_QUATERNION_LIST[i].x3) {
|
||||||
|
print_testing_failed();
|
||||||
|
return TEST_FAILED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
print_testing_success();
|
||||||
|
|
||||||
|
return TEST_SUCCES;
|
||||||
|
}
|
||||||
|
|
||||||
|
int test_bgc_quaternion_copy()
|
||||||
|
{
|
||||||
|
if (test_bgc_quaternion_copy_fp32() != TEST_SUCCES) {
|
||||||
|
return TEST_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (test_bgc_quaternion_copy_fp64() != TEST_SUCCES) {
|
||||||
|
return TEST_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TEST_SUCCES;
|
||||||
|
}
|
||||||
10
basic-geometry-test/tests/quaternion/quaternion_copy.h
Normal file
10
basic-geometry-test/tests/quaternion/quaternion_copy.h
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
#ifndef _TEST_QUATERNION_COPY_H_
|
||||||
|
#define _TEST_QUATERNION_COPY_H_
|
||||||
|
|
||||||
|
int test_bgc_quaternion_copy_fp32();
|
||||||
|
|
||||||
|
int test_bgc_quaternion_copy_fp64();
|
||||||
|
|
||||||
|
int test_bgc_quaternion_copy();
|
||||||
|
|
||||||
|
#endif
|
||||||
128
basic-geometry-test/tests/quaternion/quaternion_is_zero.c
Normal file
128
basic-geometry-test/tests/quaternion/quaternion_is_zero.c
Normal file
|
|
@ -0,0 +1,128 @@
|
||||||
|
#include "./quaternion_is_zero.h"
|
||||||
|
|
||||||
|
#include "./../../helpers.h"
|
||||||
|
|
||||||
|
// ==================== FP32 ==================== //
|
||||||
|
|
||||||
|
static const int _TEST_FP32_ZERO_QUATERNION_AMOUNT = 9;
|
||||||
|
static const int _TEST_FP32_NONZERO_QUATERNION_AMOUNT = 11;
|
||||||
|
|
||||||
|
static const BgcQuaternionFP32 _TEST_FP32_ZERO_QUATERNION_LIST[] = {
|
||||||
|
{ 0.0f, 0.0f, 0.0f, 0.0f },
|
||||||
|
{ BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f },
|
||||||
|
{ -BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f },
|
||||||
|
{ 0.0f, BGC_EPSYLON_FP32, 0.0f, 0.0f },
|
||||||
|
{ 0.0f, -BGC_EPSYLON_FP32, 0.0f, 0.0f },
|
||||||
|
{ 0.0f, 0.0f, BGC_EPSYLON_FP32, 0.0f },
|
||||||
|
{ 0.0f, 0.0f, -BGC_EPSYLON_FP32, 0.0f },
|
||||||
|
{ 0.0f, 0.0f, 0.0f, BGC_EPSYLON_FP32 },
|
||||||
|
{ 0.0f, 0.0f, 0.0f, -BGC_EPSYLON_FP32 }
|
||||||
|
};
|
||||||
|
|
||||||
|
static const BgcQuaternionFP32 _TEST_FP32_NONZERO_NUMBERS[] = {
|
||||||
|
{ 0.0f, 1.0f, 0.0f, 0.0f },
|
||||||
|
{ 1.5f * BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f },
|
||||||
|
{ -1.5f * BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f },
|
||||||
|
{ 0.0f, 1.5f * BGC_EPSYLON_FP32, 0.0f, 0.0f },
|
||||||
|
{ 0.0f, -1.5f * BGC_EPSYLON_FP32, 0.0f, 0.0f },
|
||||||
|
{ 0.0f, 0.0f, 1.5f * BGC_EPSYLON_FP32, 0.0f },
|
||||||
|
{ 0.0f, 0.0f, -1.5f * BGC_EPSYLON_FP32, 0.0f },
|
||||||
|
{ 0.0f, 0.0f, 0.0f, 1.5f * BGC_EPSYLON_FP32 },
|
||||||
|
{ 0.0f, 0.0f, 0.0f, -1.5f * BGC_EPSYLON_FP32 },
|
||||||
|
{ BGC_EPSYLON_FP32, BGC_EPSYLON_FP32, 0.0f, 0.0f },
|
||||||
|
{ -BGC_EPSYLON_FP32, -BGC_EPSYLON_FP32, 0.0f, 0.0f }
|
||||||
|
};
|
||||||
|
|
||||||
|
int test_bgc_quaternion_is_zero_fp32()
|
||||||
|
{
|
||||||
|
print_testing_name("bgc_quaternion_is_zero_fp32");
|
||||||
|
|
||||||
|
// Testing zero values:
|
||||||
|
for (int i = 0; i < _TEST_FP32_ZERO_QUATERNION_AMOUNT; i++) {
|
||||||
|
if (!bgc_quaternion_is_zero_fp32(&_TEST_FP32_ZERO_QUATERNION_LIST[i])) {
|
||||||
|
print_testing_failed();
|
||||||
|
return TEST_FAILED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Testing non-zero values:
|
||||||
|
for (int i = 0; i < _TEST_FP32_ZERO_QUATERNION_AMOUNT; i++) {
|
||||||
|
if (bgc_quaternion_is_zero_fp32(&_TEST_FP32_NONZERO_NUMBERS[i])) {
|
||||||
|
print_testing_failed();
|
||||||
|
return TEST_FAILED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
print_testing_success();
|
||||||
|
|
||||||
|
return TEST_SUCCES;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==================== FP64 ==================== //
|
||||||
|
|
||||||
|
static const int _TEST_FP64_ZERO_QUATERNION_AMOUNT = 9;
|
||||||
|
static const int _TEST_FP64_NONZERO_QUATERNION_AMOUNT = 11;
|
||||||
|
|
||||||
|
static const BgcQuaternionFP64 _TEST_FP64_ZERO_QUATERNION_LIST[] = {
|
||||||
|
{ 0.0, 0.0, 0.0, 0.0 },
|
||||||
|
{ BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 },
|
||||||
|
{ -BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 },
|
||||||
|
{ 0.0, BGC_EPSYLON_FP64, 0.0, 0.0 },
|
||||||
|
{ 0.0, -BGC_EPSYLON_FP64, 0.0, 0.0 },
|
||||||
|
{ 0.0, 0.0, BGC_EPSYLON_FP64, 0.0 },
|
||||||
|
{ 0.0, 0.0, -BGC_EPSYLON_FP64, 0.0 },
|
||||||
|
{ 0.0, 0.0, 0.0, BGC_EPSYLON_FP64 },
|
||||||
|
{ 0.0, 0.0, 0.0, -BGC_EPSYLON_FP64 }
|
||||||
|
};
|
||||||
|
|
||||||
|
static const BgcQuaternionFP64 _TEST_FP64_NONZERO_NUMBERS[] = {
|
||||||
|
{ 0.0, 1.0, 0.0, 0.0 },
|
||||||
|
{ 1.5 * BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 },
|
||||||
|
{ -1.5 * BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 },
|
||||||
|
{ 0.0, 1.5 * BGC_EPSYLON_FP64, 0.0, 0.0 },
|
||||||
|
{ 0.0, -1.5 * BGC_EPSYLON_FP64, 0.0, 0.0 },
|
||||||
|
{ 0.0, 0.0, 1.5 * BGC_EPSYLON_FP64, 0.0 },
|
||||||
|
{ 0.0, 0.0, -1.5 * BGC_EPSYLON_FP64, 0.0 },
|
||||||
|
{ 0.0, 0.0, 0.0, 1.5 * BGC_EPSYLON_FP64 },
|
||||||
|
{ 0.0, 0.0, 0.0, -1.5 * BGC_EPSYLON_FP64 },
|
||||||
|
{ BGC_EPSYLON_FP64, BGC_EPSYLON_FP64, 0.0, 0.0 },
|
||||||
|
{ -BGC_EPSYLON_FP64, -BGC_EPSYLON_FP64, 0.0, 0.0 }
|
||||||
|
};
|
||||||
|
|
||||||
|
int test_bgc_quaternion_is_zero_fp64()
|
||||||
|
{
|
||||||
|
print_testing_name("bgc_quaternion_is_zero_fp64");
|
||||||
|
|
||||||
|
// Testing zero values:
|
||||||
|
for (int i = 0; i < _TEST_FP64_ZERO_QUATERNION_AMOUNT; i++) {
|
||||||
|
if (!test_bgc_quaternion_is_zero_fp64(&_TEST_FP64_ZERO_QUATERNION_LIST[i])) {
|
||||||
|
print_testing_failed();
|
||||||
|
return TEST_FAILED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Testing non-zero values:
|
||||||
|
for (int i = 0; i < _TEST_FP64_ZERO_QUATERNION_AMOUNT; i++) {
|
||||||
|
if (test_bgc_quaternion_is_zero_fp64(&_TEST_FP64_NONZERO_NUMBERS[i])) {
|
||||||
|
print_testing_failed();
|
||||||
|
return TEST_FAILED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
print_testing_success();
|
||||||
|
|
||||||
|
return TEST_SUCCES;
|
||||||
|
}
|
||||||
|
|
||||||
|
int test_bgc_quaternion_is_zero()
|
||||||
|
{
|
||||||
|
if (test_bgc_quaternion_is_zero_fp32() != TEST_SUCCES) {
|
||||||
|
return TEST_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (test_bgc_quaternion_is_zero_fp64() != TEST_SUCCES) {
|
||||||
|
return TEST_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TEST_SUCCES;
|
||||||
|
}
|
||||||
10
basic-geometry-test/tests/quaternion/quaternion_is_zero.h
Normal file
10
basic-geometry-test/tests/quaternion/quaternion_is_zero.h
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
#ifndef _TEST_QUATERNION_IS_ZERO_H_
|
||||||
|
#define _TEST_QUATERNION_IS_ZERO_H_
|
||||||
|
|
||||||
|
int test_bgc_quaternion_is_zero_fp32();
|
||||||
|
|
||||||
|
int test_bgc_quaternion_is_zero_fp64();
|
||||||
|
|
||||||
|
int test_bgc_quaternion_is_zero();
|
||||||
|
|
||||||
|
#endif
|
||||||
52
basic-geometry-test/tests/quaternion/quaternion_reset.c
Normal file
52
basic-geometry-test/tests/quaternion/quaternion_reset.c
Normal file
|
|
@ -0,0 +1,52 @@
|
||||||
|
#include "./quaternion_reset.h"
|
||||||
|
|
||||||
|
#include "./../../helpers.h"
|
||||||
|
|
||||||
|
int test_bgc_quaternion_reset_fp32()
|
||||||
|
{
|
||||||
|
BgcQuaternionFP32 vector;
|
||||||
|
|
||||||
|
print_testing_name("bgc_quaternion_reset_fp32");
|
||||||
|
|
||||||
|
bgc_quaternion_reset_fp32(&vector);
|
||||||
|
|
||||||
|
if (vector.s0 != 0.0f || vector.x1 != 0.0f || vector.x2 != 0.0f || vector.x3 != 0.0f) {
|
||||||
|
print_testing_failed();
|
||||||
|
return TEST_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
print_testing_success();
|
||||||
|
|
||||||
|
return TEST_SUCCES;
|
||||||
|
}
|
||||||
|
|
||||||
|
int test_bgc_quaternion_reset_fp64()
|
||||||
|
{
|
||||||
|
BgcQuaternionFP64 vector;
|
||||||
|
|
||||||
|
print_testing_name("bgc_quaternion_reset_fp64");
|
||||||
|
|
||||||
|
bgc_quaternion_reset_fp64(&vector);
|
||||||
|
|
||||||
|
if (vector.s0 != 0.0 || vector.x1 != 0.0 || vector.x2 != 0.0 || vector.x3 != 0.0) {
|
||||||
|
print_testing_failed();
|
||||||
|
return TEST_FAILED;
|
||||||