Модульные тесты для Vector2, Vector3, Quaternion и Versor: is unit, is zero, is identity

This commit is contained in:
Andrey Pokidov 2025-02-11 23:54:38 +07:00
parent 47ba771b68
commit 2d8240265c
74 changed files with 999 additions and 348 deletions

View file

@ -57,6 +57,14 @@
<Option compilerVar="CC" />
</Unit>
<Unit filename="tests/quaternion/quaternion_copy.h" />
<Unit filename="tests/quaternion/quaternion_is_unit.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="tests/quaternion/quaternion_is_unit.h" />
<Unit filename="tests/quaternion/quaternion_is_zero.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="tests/quaternion/quaternion_is_zero.h" />
<Unit filename="tests/quaternion/quaternion_reset.c">
<Option compilerVar="CC" />
</Unit>
@ -97,6 +105,10 @@
<Option compilerVar="CC" />
</Unit>
<Unit filename="tests/vector2/vector2_copy.h" />
<Unit filename="tests/vector2/vector2_is_unit.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="tests/vector2/vector2_is_unit.h" />
<Unit filename="tests/vector2/vector2_is_zero.c">
<Option compilerVar="CC" />
</Unit>
@ -121,6 +133,10 @@
<Option compilerVar="CC" />
</Unit>
<Unit filename="tests/vector3/vector3_copy.h" />
<Unit filename="tests/vector3/vector3_is_unit.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="tests/vector3/vector3_is_unit.h" />
<Unit filename="tests/vector3/vector3_is_zero.c">
<Option compilerVar="CC" />
</Unit>
@ -153,6 +169,10 @@
<Option compilerVar="CC" />
</Unit>
<Unit filename="tests/versor/versor_copy.h" />
<Unit filename="tests/versor/versor_is_identity.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="tests/versor/versor_is_identity.h" />
<Unit filename="tests/versor/versor_reset.c">
<Option compilerVar="CC" />
</Unit>

View file

@ -152,6 +152,8 @@
<ClCompile Include="main.c" />
<ClCompile Include="tests\quaternion.c" />
<ClCompile Include="tests\quaternion\quaternion_copy.c" />
<ClCompile Include="tests\quaternion\quaternion_is_unit.c" />
<ClCompile Include="tests\quaternion\quaternion_is_zero.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" />
@ -161,12 +163,14 @@
<ClCompile Include="tests\utilities\is_unit.c" />
<ClCompile Include="tests\utilities\is_zero.c" />
<ClCompile Include="tests\vector2.c" />
<ClCompile Include="tests\vector2\vector2_is_unit.c" />
<ClCompile Include="tests\vector2\vector2_is_zero.c" />
<ClCompile Include="tests\vector2\vector2_copy.c" />
<ClCompile Include="tests\vector2\vector2_reset.c" />
<ClCompile Include="tests\vector2\vector2_set_values.c" />
<ClCompile Include="tests\vector2\vector2_swap.c" />
<ClCompile Include="tests\vector3.c" />
<ClCompile Include="tests\vector3\vector3_is_unit.c" />
<ClCompile Include="tests\vector3\vector3_is_zero.c" />
<ClCompile Include="tests\vector3\vector3_copy.c" />
<ClCompile Include="tests\vector3\vector3_swap.c" />
@ -174,6 +178,7 @@
<ClCompile Include="tests\vector3\vector3_set_values.c" />
<ClCompile Include="tests\versor.c" />
<ClCompile Include="tests\versor\versor_copy.c" />
<ClCompile Include="tests\versor\versor_is_identity.c" />
<ClCompile Include="tests\versor\versor_swap.c" />
<ClCompile Include="tests\versor\versor_combine.c" />
<ClCompile Include="tests\versor\versor_reset.c" />
@ -184,6 +189,8 @@
<ClInclude Include="helpers.h" />
<ClInclude Include="tests\quaternion.h" />
<ClInclude Include="tests\quaternion\quaternion_copy.h" />
<ClInclude Include="tests\quaternion\quaternion_is_unit.h" />
<ClInclude Include="tests\quaternion\quaternion_is_zero.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" />
@ -193,12 +200,14 @@
<ClInclude Include="tests\utilities\is_unit.h" />
<ClInclude Include="tests\utilities\is_zero.h" />
<ClInclude Include="tests\vector2.h" />
<ClInclude Include="tests\vector2\vector2_is_unit.h" />
<ClInclude Include="tests\vector2\vector2_is_zero.h" />
<ClInclude Include="tests\vector2\vector2_copy.h" />
<ClInclude Include="tests\vector2\vector2_reset.h" />
<ClInclude Include="tests\vector2\vector2_set_values.h" />
<ClInclude Include="tests\vector2\vector2_swap.h" />
<ClInclude Include="tests\vector3.h" />
<ClInclude Include="tests\vector3\vector3_is_unit.h" />
<ClInclude Include="tests\vector3\vector3_is_zero.h" />
<ClInclude Include="tests\vector3\vector3_copy.h" />
<ClInclude Include="tests\vector3\vector3_swap.h" />
@ -206,6 +215,7 @@
<ClInclude Include="tests\vector3\vector3_set_values.h" />
<ClInclude Include="tests\versor.h" />
<ClInclude Include="tests\versor\versor_copy.h" />
<ClInclude Include="tests\versor\versor_is_identity.h" />
<ClInclude Include="tests\versor\versor_swap.h" />
<ClInclude Include="tests\versor\versor_combine.h" />
<ClInclude Include="tests\versor\versor_reset.h" />

View file

@ -90,6 +90,21 @@
<ClCompile Include="tests\vector2\vector2_is_zero.c">
<Filter>tests\vector2</Filter>
</ClCompile>
<ClCompile Include="tests\quaternion\quaternion_is_zero.c">
<Filter>tests\quaternion</Filter>
</ClCompile>
<ClCompile Include="tests\quaternion\quaternion_is_unit.c">
<Filter>tests\quaternion</Filter>
</ClCompile>
<ClCompile Include="tests\vector3\vector3_is_unit.c">
<Filter>tests\vector3</Filter>
</ClCompile>
<ClCompile Include="tests\vector2\vector2_is_unit.c">
<Filter>tests\vector2</Filter>
</ClCompile>
<ClCompile Include="tests\versor\versor_is_identity.c">
<Filter>tests\versor</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="helpers.h" />
@ -180,6 +195,21 @@
<ClInclude Include="tests\vector2\vector2_is_zero.h">
<Filter>tests\vector2</Filter>
</ClInclude>
<ClInclude Include="tests\quaternion\quaternion_is_zero.h">
<Filter>tests\quaternion</Filter>
</ClInclude>
<ClInclude Include="tests\quaternion\quaternion_is_unit.h">
<Filter>tests\quaternion</Filter>
</ClInclude>
<ClInclude Include="tests\vector3\vector3_is_unit.h">
<Filter>tests\vector3</Filter>
</ClInclude>
<ClInclude Include="tests\vector2\vector2_is_unit.h">
<Filter>tests\vector2</Filter>
</ClInclude>
<ClInclude Include="tests\versor\versor_is_identity.h">
<Filter>tests\versor</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="tests">

View file

@ -4,23 +4,31 @@ int test_quaternion()
{
print_testing_section("BGC Quaternion");
if (test_bgc_quaternion_reset() != TEST_SUCCES) {
if (test_quaternion_reset() != TEST_SUCCES) {
return TEST_FAILED;
}
if (test_bgc_quaternion_set_to_identity() != TEST_SUCCES) {
if (test_quaternion_set_to_identity() != TEST_SUCCES) {
return TEST_FAILED;
}
if (test_bgc_quaternion_set_values() != TEST_SUCCES) {
if (test_quaternion_set_values() != TEST_SUCCES) {
return TEST_FAILED;
}
if (test_bgc_quaternion_copy() != TEST_SUCCES) {
if (test_quaternion_copy() != TEST_SUCCES) {
return TEST_FAILED;
}
if (test_bgc_quaternion_swap() != TEST_SUCCES) {
if (test_quaternion_swap() != TEST_SUCCES) {
return TEST_FAILED;
}
if (test_quaternion_is_zero() != TEST_SUCCES) {
return TEST_FAILED;
}
if (test_quaternion_is_unit() != TEST_SUCCES) {
return TEST_FAILED;
}

View file

@ -7,6 +7,8 @@
#include "./quaternion/quaternion_set_values.h"
#include "./quaternion/quaternion_copy.h"
#include "./quaternion/quaternion_swap.h"
#include "./quaternion/quaternion_is_zero.h"
#include "./quaternion/quaternion_is_unit.h"
int test_quaternion();

View file

@ -14,7 +14,7 @@ static const BgcQuaternionFP32 _TEST_FP32_QUATERNION_LIST[] = {
{ 0.001f, -100.0f, 100.0f, -0.001f }
};
int test_bgc_quaternion_copy_fp32()
int test_quaternion_copy_fp32()
{
BgcQuaternionFP32 vector;
@ -48,7 +48,7 @@ static const BgcQuaternionFP64 _TEST_FP64_QUATERNION_LIST[] = {
{ 0.001, -100.0, 100.0, -0.001 }
};
int test_bgc_quaternion_copy_fp64()
int test_quaternion_copy_fp64()
{
BgcQuaternionFP64 vector;
@ -72,13 +72,13 @@ int test_bgc_quaternion_copy_fp64()
return TEST_SUCCES;
}
int test_bgc_quaternion_copy()
int test_quaternion_copy()
{
if (test_bgc_quaternion_copy_fp32() != TEST_SUCCES) {
if (test_quaternion_copy_fp32() != TEST_SUCCES) {
return TEST_FAILED;
}
if (test_bgc_quaternion_copy_fp64() != TEST_SUCCES) {
if (test_quaternion_copy_fp64() != TEST_SUCCES) {
return TEST_FAILED;
}

View file

@ -1,10 +1,10 @@
#ifndef _TEST_QUATERNION_COPY_H_
#define _TEST_QUATERNION_COPY_H_
int test_bgc_quaternion_copy_fp32();
int test_quaternion_copy_fp32();
int test_bgc_quaternion_copy_fp64();
int test_quaternion_copy_fp64();
int test_bgc_quaternion_copy();
int test_quaternion_copy();
#endif

View file

@ -0,0 +1,140 @@
#include "./quaternion_is_unit.h"
#include "./../../helpers.h"
// ==================== FP32 ==================== //
static const int _TEST_FP32_UNIT_QUATERNION_AMOUNT = 16;
static const int _TEST_FP32_NONUNIT_QUATERNION_AMOUNT = 10;
static const BgcQuaternionFP32 _TEST_FP32_UNIT_QUATERNION_LIST[] = {
{ 1.0f, 0.0f, 0.0f, 0.0f },
{ -1.0f, 0.0f, 0.0f, 0.0f },
{ 0.0f, -0.8f, 0.6f, 0.0f },
{ 1.0f + 0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f },
{ 1.0f - 0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f },
{ 0.0f, 1.0f + 0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f },
{ 0.0f, 1.0f - 0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f },
{ 0.0f, 0.0f, 1.0f + 0.75f * BGC_EPSYLON_FP32, 0.0f },
{ 0.0f, 0.0f, 1.0f - 0.75f * BGC_EPSYLON_FP32, 0.0f },
{ 0.0f, 0.0f, 0.0f, 1.0f + 0.75f * BGC_EPSYLON_FP32 },
{ 0.0f, 0.0f, 0.0f, 1.0f - 0.75f * BGC_EPSYLON_FP32 },
{ 0.5f, 0.5f, 0.5f, 0.5f },
{ 0.5f + 0.75f * BGC_EPSYLON_FP32, 0.5f, 0.5f, 0.5f },
{ 0.5f, 0.5f - 0.75f * BGC_EPSYLON_FP32, 0.5f, 0.5f },
{ 0.5f, 0.5f, 0.5f + 0.75f * BGC_EPSYLON_FP32, 0.5f },
{ 0.5f, 0.5f, 0.5f, 0.5f - 0.75f * BGC_EPSYLON_FP32 }
};
static const BgcQuaternionFP32 _TEST_FP32_NONUNIT_QUATERION_LIST[] = {
{ 1.0f + 1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f },
{ 1.0f - 1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f },
{ 0.0f, 1.0f + 1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f },
{ 0.0f, 1.0f - 1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f },
{ 0.0f, 0.0f, 1.0f + 1.25f * BGC_EPSYLON_FP32, 0.0f },
{ 0.0f, 0.0f, 1.0f - 1.25f * BGC_EPSYLON_FP32, 0.0f },
{ 0.0f, 0.0f, 0.0f, 1.0f + 1.25f * BGC_EPSYLON_FP32 },
{ 0.0f, 0.0f, 0.0f, 1.0f - 1.25f * BGC_EPSYLON_FP32 },
{ 0.5f + 1.25f * BGC_EPSYLON_FP32, 0.5f + 1.25f * BGC_EPSYLON_FP32, 0.5f, 0.5f },
{ 0.5f - 1.25f * BGC_EPSYLON_FP32, 0.5f - 1.25f * BGC_EPSYLON_FP32, 0.0f, 0.5f }
};
int test_quaternion_is_unit_fp32()
{
print_testing_name("bgc_quaternion_is_unit_fp32");
// Testing zero values:
for (int i = 0; i < _TEST_FP32_UNIT_QUATERNION_AMOUNT; i++) {
if (!bgc_quaternion_is_unit_fp32(&_TEST_FP32_UNIT_QUATERNION_LIST[i])) {
print_testing_failed();
return TEST_FAILED;
}
}
// Testing non-zero values:
for (int i = 0; i < _TEST_FP32_NONUNIT_QUATERNION_AMOUNT; i++) {
if (bgc_quaternion_is_unit_fp32(&_TEST_FP32_NONUNIT_QUATERION_LIST[i])) {
print_testing_failed();
return TEST_FAILED;
}
}
print_testing_success();
return TEST_SUCCES;
}
// ==================== FP64 ==================== //
static const int _TEST_FP64_UNIT_QUATERNION_AMOUNT = 16;
static const int _TEST_FP64_NONUNIT_QUATERNION_AMOUNT = 10;
static const BgcQuaternionFP64 _TEST_FP64_UNIT_QUATERNION_LIST[] = {
{ 1.0, 0.0, 0.0, 0.0 },
{ -1.0, 0.0, 0.0, 0.0 },
{ 0.0, -0.6, 0.8, 0.0 },
{ 1.0 + 0.75 * BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 },
{ 1.0 - 0.75 * BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 },
{ 0.0, 1.0 + 0.75 * BGC_EPSYLON_FP64, 0.0, 0.0 },
{ 0.0, 1.0 - 0.75 * BGC_EPSYLON_FP64, 0.0, 0.0 },
{ 0.0, 0.0, 1.0 + 0.75 * BGC_EPSYLON_FP64, 0.0 },
{ 0.0, 0.0, 1.0 - 0.75 * BGC_EPSYLON_FP64, 0.0 },
{ 0.0, 0.0, 0.0, 1.0 + 0.75 * BGC_EPSYLON_FP64 },
{ 0.0, 0.0, 0.0, 1.0 - 0.75 * BGC_EPSYLON_FP64 },
{ 0.5, 0.5, 0.5, 0.5 },
{ 0.5 + 0.75 * BGC_EPSYLON_FP64, 0.5, 0.5, 0.5 },
{ 0.5, 0.5 - 0.75 * BGC_EPSYLON_FP64, 0.5, 0.5 },
{ 0.5, 0.5, 0.5 + 0.75 * BGC_EPSYLON_FP64, 0.5 },
{ 0.5, 0.5, 0.5, 0.5 - 0.75 * BGC_EPSYLON_FP64 }
};
static const BgcQuaternionFP64 _TEST_FP64_NONUNIT_QUATERION_LIST[] = {
{ 1.0 + 1.25 * BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 },
{ 1.0 - 1.25 * BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 },
{ 0.0, 1.0 + 1.25 * BGC_EPSYLON_FP64, 0.0, 0.0 },
{ 0.0, 1.0 - 1.25 * BGC_EPSYLON_FP64, 0.0, 0.0 },
{ 0.0, 0.0, 1.0 + 1.25 * BGC_EPSYLON_FP64, 0.0 },
{ 0.0, 0.0, 1.0 - 1.25 * BGC_EPSYLON_FP64, 0.0 },
{ 0.0, 0.0, 0.0, 1.0 + 1.25 * BGC_EPSYLON_FP64 },
{ 0.0, 0.0, 0.0, 1.0 - 1.25 * BGC_EPSYLON_FP64 },
{ 0.5 + 1.25 * BGC_EPSYLON_FP64, 0.5 + 1.25 * BGC_EPSYLON_FP64, 0.5, 0.5 },
{ 0.5 - 1.25 * BGC_EPSYLON_FP64, 0.5 - 1.25 * BGC_EPSYLON_FP64, 0.0, 0.5 }
};
int test_quaternion_is_unit_fp64()
{
print_testing_name("bgc_quaternion_is_unit_fp64");
// Testing zero values:
for (int i = 0; i < _TEST_FP64_UNIT_QUATERNION_AMOUNT; i++) {
if (!bgc_quaternion_is_unit_fp64(&_TEST_FP64_UNIT_QUATERNION_LIST[i])) {
print_testing_failed();
return TEST_FAILED;
}
}
// Testing non-zero values:
for (int i = 0; i < _TEST_FP64_NONUNIT_QUATERNION_AMOUNT; i++) {
if (bgc_quaternion_is_unit_fp64(&_TEST_FP64_NONUNIT_QUATERION_LIST[i])) {
print_testing_failed();
return TEST_FAILED;
}
}
print_testing_success();
return TEST_SUCCES;
}
int test_quaternion_is_unit()
{
if (test_quaternion_is_unit_fp32() != TEST_SUCCES) {
return TEST_FAILED;
}
if (test_quaternion_is_unit_fp64() != TEST_SUCCES) {
return TEST_FAILED;
}
return TEST_SUCCES;
}

View file

@ -0,0 +1,10 @@
#ifndef _TEST_QUATERNION_IS_UNIT_H_
#define _TEST_QUATERNION_IS_UNIT_H_
int test_quaternion_is_unit_fp32();
int test_quaternion_is_unit_fp64();
int test_quaternion_is_unit();
#endif

View file

@ -19,7 +19,7 @@ static const BgcQuaternionFP32 _TEST_FP32_ZERO_QUATERNION_LIST[] = {
{ 0.0f, 0.0f, 0.0f, -BGC_EPSYLON_FP32 }
};
static const BgcQuaternionFP32 _TEST_FP32_NONZERO_NUMBERS[] = {
static const BgcQuaternionFP32 _TEST_FP32_NONZERO_QUATERION_LIST[] = {
{ 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 },
@ -33,7 +33,7 @@ static const BgcQuaternionFP32 _TEST_FP32_NONZERO_NUMBERS[] = {
{ -BGC_EPSYLON_FP32, -BGC_EPSYLON_FP32, 0.0f, 0.0f }
};
int test_bgc_quaternion_is_zero_fp32()
int test_quaternion_is_zero_fp32()
{
print_testing_name("bgc_quaternion_is_zero_fp32");
@ -47,7 +47,7 @@ int test_bgc_quaternion_is_zero_fp32()
// Testing non-zero values:
for (int i = 0; i < _TEST_FP32_NONZERO_QUATERNION_AMOUNT; i++) {
if (bgc_quaternion_is_zero_fp32(&_TEST_FP32_NONZERO_NUMBERS[i])) {
if (bgc_quaternion_is_zero_fp32(&_TEST_FP32_NONZERO_QUATERION_LIST[i])) {
print_testing_failed();
return TEST_FAILED;
}
@ -75,7 +75,7 @@ static const BgcQuaternionFP64 _TEST_FP64_ZERO_QUATERNION_LIST[] = {
{ 0.0, 0.0, 0.0, -BGC_EPSYLON_FP64 }
};
static const BgcQuaternionFP64 _TEST_FP64_NONZERO_NUMBERS[] = {
static const BgcQuaternionFP64 _TEST_FP64_NONZERO_QUATERION_LIST[] = {
{ 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 },
@ -89,13 +89,13 @@ static const BgcQuaternionFP64 _TEST_FP64_NONZERO_NUMBERS[] = {
{ -BGC_EPSYLON_FP64, -BGC_EPSYLON_FP64, 0.0, 0.0 }
};
int test_bgc_quaternion_is_zero_fp64()
int test_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])) {
if (!bgc_quaternion_is_zero_fp64(&_TEST_FP64_ZERO_QUATERNION_LIST[i])) {
print_testing_failed();
return TEST_FAILED;
}
@ -103,7 +103,7 @@ int test_bgc_quaternion_is_zero_fp64()
// Testing non-zero values:
for (int i = 0; i < _TEST_FP64_NONZERO_QUATERNION_AMOUNT; i++) {
if (test_bgc_quaternion_is_zero_fp64(&_TEST_FP64_NONZERO_NUMBERS[i])) {
if (bgc_quaternion_is_zero_fp64(&_TEST_FP64_NONZERO_QUATERION_LIST[i])) {
print_testing_failed();
return TEST_FAILED;
}
@ -114,13 +114,13 @@ int test_bgc_quaternion_is_zero_fp64()
return TEST_SUCCES;
}
int test_bgc_quaternion_is_zero()
int test_quaternion_is_zero()
{
if (test_bgc_quaternion_is_zero_fp32() != TEST_SUCCES) {
if (test_quaternion_is_zero_fp32() != TEST_SUCCES) {
return TEST_FAILED;
}
if (test_bgc_quaternion_is_zero_fp64() != TEST_SUCCES) {
if (test_quaternion_is_zero_fp64() != TEST_SUCCES) {
return TEST_FAILED;
}

View file

@ -1,10 +1,10 @@
#ifndef _TEST_QUATERNION_IS_ZERO_H_
#define _TEST_QUATERNION_IS_ZERO_H_
int test_bgc_quaternion_is_zero_fp32();
int test_quaternion_is_zero_fp32();
int test_bgc_quaternion_is_zero_fp64();
int test_quaternion_is_zero_fp64();
int test_bgc_quaternion_is_zero();
int test_quaternion_is_zero();
#endif

View file

@ -2,7 +2,7 @@
#include "./../../helpers.h"
int test_bgc_quaternion_reset_fp32()
int test_quaternion_reset_fp32()
{
BgcQuaternionFP32 vector;
@ -20,7 +20,7 @@ int test_bgc_quaternion_reset_fp32()
return TEST_SUCCES;
}
int test_bgc_quaternion_reset_fp64()
int test_quaternion_reset_fp64()
{
BgcQuaternionFP64 vector;
@ -38,13 +38,13 @@ int test_bgc_quaternion_reset_fp64()
return TEST_SUCCES;
}
int test_bgc_quaternion_reset()
int test_quaternion_reset()
{
if (test_bgc_quaternion_reset_fp32() != TEST_SUCCES) {
if (test_quaternion_reset_fp32() != TEST_SUCCES) {
return TEST_FAILED;
}
if (test_bgc_quaternion_reset_fp64() != TEST_SUCCES) {
if (test_quaternion_reset_fp64() != TEST_SUCCES) {
return TEST_FAILED;
}

View file

@ -1,10 +1,10 @@
#ifndef _TEST_QUATERNION_RESET_H_
#define _TEST_QUATERNION_RESET_H_
int test_bgc_quaternion_reset_fp32();
int test_quaternion_reset_fp32();
int test_bgc_quaternion_reset_fp64();
int test_quaternion_reset_fp64();
int test_bgc_quaternion_reset();
int test_quaternion_reset();
#endif

View file

@ -2,7 +2,7 @@
#include "./../../helpers.h"
int test_bgc_quaternion_set_to_identity_fp32()
int test_quaternion_set_to_identity_fp32()
{
BgcQuaternionFP32 vector;
@ -20,7 +20,7 @@ int test_bgc_quaternion_set_to_identity_fp32()
return TEST_SUCCES;
}
int test_bgc_quaternion_set_to_identity_fp64()
int test_quaternion_set_to_identity_fp64()
{
BgcQuaternionFP64 vector;
@ -38,13 +38,13 @@ int test_bgc_quaternion_set_to_identity_fp64()
return TEST_SUCCES;
}
int test_bgc_quaternion_set_to_identity()
int test_quaternion_set_to_identity()
{
if (test_bgc_quaternion_set_to_identity_fp32() != TEST_SUCCES) {
if (test_quaternion_set_to_identity_fp32() != TEST_SUCCES) {
return TEST_FAILED;
}
if (test_bgc_quaternion_set_to_identity_fp64() != TEST_SUCCES) {
if (test_quaternion_set_to_identity_fp64() != TEST_SUCCES) {
return TEST_FAILED;
}

View file

@ -1,10 +1,10 @@
#ifndef _TEST_QUATERNION_SET_TO_IDENTITY_H_
#define _TEST_QUATERNION_SET_TO_IDENTITY_H_
int test_bgc_quaternion_set_to_identity_fp32();
int test_quaternion_set_to_identity_fp32();
int test_bgc_quaternion_set_to_identity_fp64();
int test_quaternion_set_to_identity_fp64();
int test_bgc_quaternion_set_to_identity();
int test_quaternion_set_to_identity();
#endif

View file

@ -6,7 +6,7 @@
// ==================== FP32 ==================== //
int test_bgc_quaternion_set_values_fp32()
int test_quaternion_set_values_fp32()
{
BgcQuaternionFP32 vector;
@ -40,7 +40,7 @@ int test_bgc_quaternion_set_values_fp32()
// ==================== FP64 ==================== //
int test_bgc_quaternion_set_values_fp64()
int test_quaternion_set_values_fp64()
{
BgcQuaternionFP64 vector;
@ -72,13 +72,13 @@ int test_bgc_quaternion_set_values_fp64()
return TEST_SUCCES;
}
int test_bgc_quaternion_set_values()
int test_quaternion_set_values()
{
if (test_bgc_quaternion_set_values_fp32() != TEST_SUCCES) {
if (test_quaternion_set_values_fp32() != TEST_SUCCES) {
return TEST_FAILED;
}
if (test_bgc_quaternion_set_values_fp64() != TEST_SUCCES) {
if (test_quaternion_set_values_fp64() != TEST_SUCCES) {
return TEST_FAILED;
}

View file

@ -1,10 +1,10 @@
#ifndef _TEST_QUATERNION_SET_VALUES_H_
#define _TEST_QUATERNION_SET_VALUES_H_
int test_bgc_quaternion_set_values_fp32();
int test_quaternion_set_values_fp32();
int test_bgc_quaternion_set_values_fp64();
int test_quaternion_set_values_fp64();
int test_bgc_quaternion_set_values();
int test_quaternion_set_values();
#endif

View file

@ -22,7 +22,7 @@ static const BgcQuaternionFP32 _TEST_FP32_QUATERNION_LIST2[] = {
{ 1000.0f, -0.00025f, -0.419f, 0.844f }
};
int test_bgc_quaternion_swap_fp32()
int test_quaternion_swap_fp32()
{
BgcQuaternionFP32 quaternion1, quaternion2;
@ -70,7 +70,7 @@ static const BgcQuaternionFP64 _TEST_FP64_QUATERNION_LIST2[] = {
{ 1000.0, -0.00025, -0.419, 0.844 }
};
int test_bgc_quaternion_swap_fp64()
int test_quaternion_swap_fp64()
{
BgcQuaternionFP64 quaternion1, quaternion2;
@ -100,13 +100,13 @@ int test_bgc_quaternion_swap_fp64()
return TEST_SUCCES;
}
int test_bgc_quaternion_swap()
int test_quaternion_swap()
{
if (test_bgc_quaternion_swap_fp32() != TEST_SUCCES) {
if (test_quaternion_swap_fp32() != TEST_SUCCES) {
return TEST_FAILED;
}
if (test_bgc_quaternion_swap_fp64() != TEST_SUCCES) {
if (test_quaternion_swap_fp64() != TEST_SUCCES) {
return TEST_FAILED;
}

View file

@ -1,10 +1,10 @@
#ifndef _TEST_QUATERNION_SWAP_H_
#define _TEST_QUATERNION_SWAP_H_
int test_bgc_quaternion_swap_fp32();
int test_quaternion_swap_fp32();
int test_bgc_quaternion_swap_fp64();
int test_quaternion_swap_fp64();
int test_bgc_quaternion_swap();
int test_quaternion_swap();
#endif

View file

@ -6,15 +6,15 @@ int test_utilities()
{
print_testing_section("BGC Utilities");
if (test_bgc_is_zero() != TEST_SUCCES) {
if (test_is_zero() != TEST_SUCCES) {
return TEST_FAILED;
}
if (test_bgc_is_unit() != TEST_SUCCES) {
if (test_is_unit() != TEST_SUCCES) {
return TEST_FAILED;
}
if (test_bgc_are_close() != TEST_SUCCES) {
if (test_are_close() != TEST_SUCCES) {
return TEST_FAILED;
}

View file

@ -61,7 +61,7 @@ static const _TestNumberPairFP32 _TEST_FP32_DATA_DIFFERENT[] = {
{-100.0f, -100.0f * (1.0f - 1.25f * BGC_EPSYLON_FP32)}
};
int test_bgc_are_close_fp32()
int test_are_close_fp32()
{
print_testing_name("bgc_are_close_fp32");
@ -137,7 +137,7 @@ static const _TestNumberPairFP64 _TEST_FP64_DATA_DIFFERENT[] = {
{-100.0, -100.0 * (1.0 - 1.25 * BGC_EPSYLON_FP64)}
};
int test_bgc_are_close_fp64()
int test_are_close_fp64()
{
print_testing_name("bgc_are_close_fp64");
@ -162,13 +162,13 @@ int test_bgc_are_close_fp64()
return TEST_SUCCES;
}
int test_bgc_are_close()
int test_are_close()
{
if (test_bgc_are_close_fp32() != TEST_SUCCES) {
if (test_are_close_fp32() != TEST_SUCCES) {
return TEST_FAILED;
}
if (test_bgc_are_close_fp64() != TEST_SUCCES) {
if (test_are_close_fp64() != TEST_SUCCES) {
return TEST_FAILED;
}

View file

@ -1,10 +1,10 @@
#ifndef _TEST_UTILITIES_ARE_CLOSE_H_
#define _TEST_UTILITIES_ARE_CLOSE_H_
int test_bgc_are_close_fp32();
int test_are_close_fp32();
int test_bgc_are_close_fp64();
int test_are_close_fp64();
int test_bgc_are_close();
int test_are_close();
#endif

View file

@ -20,7 +20,7 @@ static const float _TEST_FP32_NONUNIT_NUMBERS[] = {
1.0f - 2.0f * BGC_EPSYLON_FP32
};
int test_bgc_is_unit_fp32()
int test_is_unit_fp32()
{
print_testing_name("bgc_is_unit_fp32");
@ -63,7 +63,7 @@ static const double _TEST_FP64_NONUNIT_NUMBERS[] = {
1.0 - 2.0 * BGC_EPSYLON_FP64
};
int test_bgc_is_unit_fp64()
int test_is_unit_fp64()
{
print_testing_name("bgc_is_unit_fp64");
@ -108,7 +108,7 @@ static const float _TEST_FP32_DATA_SQUARE_NONUNIT[] = {
1.0f - 2.5f * BGC_EPSYLON_FP32
};
int test_bgc_is_sqare_value_unit_fp32()
int test_is_sqare_value_unit_fp32()
{
print_testing_name("bgc_is_sqare_value_unit_fp32");
@ -153,7 +153,7 @@ static const double _TEST_FP64_DATA_SQUARE_NONUNIT[] = {
1.0 - 2.5 * BGC_EPSYLON_FP64
};
int test_bgc_is_sqare_value_unit_fp64()
int test_is_sqare_value_unit_fp64()
{
print_testing_name("bgc_is_sqare_value_unit_fp64");
@ -178,21 +178,21 @@ int test_bgc_is_sqare_value_unit_fp64()
return TEST_SUCCES;
}
int test_bgc_is_unit()
int test_is_unit()
{
if (test_bgc_is_unit_fp32() != TEST_SUCCES) {
if (test_is_unit_fp32() != TEST_SUCCES) {
return TEST_FAILED;
}
if (test_bgc_is_unit_fp64() != TEST_SUCCES) {
if (test_is_unit_fp64() != TEST_SUCCES) {
return TEST_FAILED;
}
if (test_bgc_is_sqare_value_unit_fp32() != TEST_SUCCES) {
if (test_is_sqare_value_unit_fp32() != TEST_SUCCES) {
return TEST_FAILED;
}
if (test_bgc_is_sqare_value_unit_fp64() != TEST_SUCCES) {
if (test_is_sqare_value_unit_fp64() != TEST_SUCCES) {
return TEST_FAILED;
}

View file

@ -1,14 +1,14 @@
#ifndef _TEST_UTILITIES_IS_UNIT_H_
#define _TEST_UTILITIES_IS_UNIT_H_
int test_bgc_is_unit_fp32();
int test_is_unit_fp32();
int test_bgc_is_unit_fp64();
int test_is_unit_fp64();
int test_bgc_is_sqare_value_unit_fp32();
int test_is_sqare_value_unit_fp32();
int test_bgc_is_sqare_value_unit_fp64();
int test_is_sqare_value_unit_fp64();
int test_bgc_is_unit();
int test_is_unit();
#endif

View file

@ -22,7 +22,7 @@ static const float _TEST_FP32_NONZERO_NUMBERS[] = {
-(1.5f * BGC_EPSYLON_FP32)
};
int test_bgc_is_zero_fp32()
int test_is_zero_fp32()
{
print_testing_name("bgc_is_zero_fp32");
@ -67,7 +67,7 @@ static const double _TEST_FP64_NONZERO_NUMBERS[] = {
-(1.5 * BGC_EPSYLON_FP64)
};
int test_bgc_is_zero_fp64()
int test_is_zero_fp64()
{
print_testing_name("bgc_is_zero_fp64");
@ -92,13 +92,13 @@ int test_bgc_is_zero_fp64()
return TEST_SUCCES;
}
int test_bgc_is_zero()
int test_is_zero()
{
if (test_bgc_is_zero_fp32() != TEST_SUCCES) {
if (test_is_zero_fp32() != TEST_SUCCES) {
return TEST_FAILED;
}
if (test_bgc_is_zero_fp64() != TEST_SUCCES) {
if (test_is_zero_fp64() != TEST_SUCCES) {
return TEST_FAILED;
}

View file

@ -1,10 +1,10 @@
#ifndef _TEST_UTILITIES_IS_ZERO_H_
#define _TEST_UTILITIES_IS_ZERO_H_
int test_bgc_is_zero_fp32();
int test_is_zero_fp32();
int test_bgc_is_zero_fp64();
int test_is_zero_fp64();
int test_bgc_is_zero();
int test_is_zero();
#endif

View file

@ -4,23 +4,27 @@ int test_vector2()
{
print_testing_section("BGC Vector2");
if (test_bgc_vector2_reset() != TEST_SUCCES) {
if (test_vector2_reset() != TEST_SUCCES) {
return TEST_FAILED;
}
if (test_bgc_vector2_set_values() != TEST_SUCCES) {
if (test_vector2_set_values() != TEST_SUCCES) {
return TEST_FAILED;
}
if (test_bgc_vector2_copy() != TEST_SUCCES) {
if (test_vector2_copy() != TEST_SUCCES) {
return TEST_FAILED;
}
if (test_bgc_vector2_swap() != TEST_SUCCES) {
if (test_vector2_swap() != TEST_SUCCES) {
return TEST_FAILED;
}
if (test_bgc_vector2_is_zero() != TEST_SUCCES) {
if (test_vector2_is_zero() != TEST_SUCCES) {
return TEST_FAILED;
}
if (test_vector2_is_unit() != TEST_SUCCES) {
return TEST_FAILED;
}

View file

@ -7,6 +7,7 @@
#include "./vector2/vector2_copy.h"
#include "./vector2/vector2_swap.h"
#include "./vector2/vector2_is_zero.h"
#include "./vector2/vector2_is_unit.h"
/*
int test_fp32_vector2();

View file

@ -14,7 +14,7 @@ static const BgcVector2FP32 _TEST_FP32_VECTOR2_LIST[] = {
{ -100.0f, 100.0f }
};
int test_bgc_vector2_copy_fp32()
int test_vector2_copy_fp32()
{
BgcVector2FP32 vector;
@ -45,7 +45,7 @@ static const BgcVector2FP64 _TEST_FP64_VECTOR2_LIST[] = {
{ -100.0, 100.0 }
};
int test_bgc_vector2_copy_fp64()
int test_vector2_copy_fp64()
{
BgcVector2FP64 vector;
@ -66,13 +66,13 @@ int test_bgc_vector2_copy_fp64()
return TEST_SUCCES;
}
int test_bgc_vector2_copy()
int test_vector2_copy()
{
if (test_bgc_vector2_copy_fp32() != TEST_SUCCES) {
if (test_vector2_copy_fp32() != TEST_SUCCES) {
return TEST_FAILED;
}
if (test_bgc_vector2_copy_fp64() != TEST_SUCCES) {
if (test_vector2_copy_fp64() != TEST_SUCCES) {
return TEST_FAILED;
}

View file

@ -1,10 +1,10 @@
#ifndef _TEST_VECTOR2_COPY_H_
#define _TEST_VECTOR2_COPY_H_
int test_bgc_vector2_copy_fp32();
int test_vector2_copy_fp32();
int test_bgc_vector2_copy_fp64();
int test_vector2_copy_fp64();
int test_bgc_vector2_copy();
int test_vector2_copy();
#endif

View file

@ -0,0 +1,114 @@
#include "./vector2_is_unit.h"
#include "./../../helpers.h"
// ==================== FP32 ==================== //
static const int _TEST_FP32_UNIT_VECTOR2_AMOUNT = 6;
static const int _TEST_FP32_NONUNIT_VECTOR2_AMOUNT = 7;
static const BgcVector2FP32 _TEST_FP32_UNIT_VECTOR2_LIST[] = {
{ 1.0f, 0.0f },
{ 0.0f, -1.0f },
{ 1.0f + 0.75f * BGC_EPSYLON_FP32, 0.0f },
{ 1.0f - 0.75f * BGC_EPSYLON_FP32, 0.0f },
{ 0.0f, 1.0f + 0.75f * BGC_EPSYLON_FP32 },
{ 0.0f, 1.0f - 0.75f * BGC_EPSYLON_FP32 }
};
static const BgcVector2FP32 _TEST_FP32_NONUNIT_VECTOR2_LIST[] = {
{ 0.0f, 0.0f },
{ 1.0f + 1.25f * BGC_EPSYLON_FP32, 0.0f },
{ 1.0f - 1.25f * BGC_EPSYLON_FP32, 0.0f },
{ 0.0f, 1.0f + 1.25f * BGC_EPSYLON_FP32 },
{ 0.0f, 1.0f - 1.25f * BGC_EPSYLON_FP32 },
{ 0.8f + 1.25f * BGC_EPSYLON_FP32, 0.6f + 1.25f * BGC_EPSYLON_FP32 },
{ 0.6f - 1.25f * BGC_EPSYLON_FP32, 0.8f - 1.25f * BGC_EPSYLON_FP32 }
};
int test_vector2_is_unit_fp32()
{
print_testing_name("bgc_vector2_is_unit_fp32");
// Testing zero values:
for (int i = 0; i < _TEST_FP32_UNIT_VECTOR2_AMOUNT; i++) {
if (!bgc_vector2_is_unit_fp32(&_TEST_FP32_UNIT_VECTOR2_LIST[i])) {
print_testing_failed();
return TEST_FAILED;
}
}
// Testing non-zero values:
for (int i = 0; i < _TEST_FP32_NONUNIT_VECTOR2_AMOUNT; i++) {
if (bgc_vector2_is_unit_fp32(&_TEST_FP32_NONUNIT_VECTOR2_LIST[i])) {
print_testing_failed();
return TEST_FAILED;
}
}
print_testing_success();
return TEST_SUCCES;
}
// ==================== FP64 ==================== //
static const int _TEST_FP64_UNIT_VECTOR2_AMOUNT = 6;
static const int _TEST_FP64_NONUNIT_VECTOR2_AMOUNT = 7;
static const BgcVector2FP64 _TEST_FP64_UNIT_VECTOR2_LIST[] = {
{ -1.0, 0.0 },
{ 0.0, 1.0 },
{ 1.0 + 0.75 * BGC_EPSYLON_FP64, 0.0 },
{ 1.0 - 0.75 * BGC_EPSYLON_FP64, 0.0 },
{ 0.0, 1.0 + 0.75 * BGC_EPSYLON_FP64 },
{ 0.0, 1.0 - 0.75 * BGC_EPSYLON_FP64 }
};
static const BgcVector2FP64 _TEST_FP64_NONUNIT_VECTOR2_LIST[] = {
{ 0.0, 0.0 },
{ 1.0 + 1.25 * BGC_EPSYLON_FP64, 0.0 },
{ 1.0 - 1.25 * BGC_EPSYLON_FP64, 0.0 },
{ 0.0, 1.0 + 1.25 * BGC_EPSYLON_FP64 },
{ 0.0, 1.0 - 1.25 * BGC_EPSYLON_FP64 },
{ 0.6 + 1.25 * BGC_EPSYLON_FP64, 0.8 + 1.25 * BGC_EPSYLON_FP64 },
{ 0.8 - 1.25 * BGC_EPSYLON_FP64, 0.6 - 1.25 * BGC_EPSYLON_FP64 }
};
int test_vector2_is_unit_fp64()
{
print_testing_name("bgc_vector2_is_unit_fp64");
// Testing zero values:
for (int i = 0; i < _TEST_FP64_UNIT_VECTOR2_AMOUNT; i++) {
if (!bgc_vector2_is_unit_fp64(&_TEST_FP64_UNIT_VECTOR2_LIST[i])) {
print_testing_failed();
return TEST_FAILED;
}
}
// Testing non-zero values:
for (int i = 0; i < _TEST_FP64_NONUNIT_VECTOR2_AMOUNT; i++) {
if (bgc_vector2_is_unit_fp64(&_TEST_FP64_NONUNIT_VECTOR2_LIST[i])) {
print_testing_failed();
return TEST_FAILED;
}
}
print_testing_success();
return TEST_SUCCES;
}
int test_vector2_is_unit()
{
if (test_vector2_is_unit_fp32() != TEST_SUCCES) {
return TEST_FAILED;
}
if (test_vector2_is_unit_fp64() != TEST_SUCCES) {
return TEST_FAILED;
}
return TEST_SUCCES;
}

View file

@ -0,0 +1,10 @@
#ifndef _TEST_VECTOR2_IS_UNIT_H_
#define _TEST_VECTOR2_IS_UNIT_H_
int test_vector2_is_unit_fp32();
int test_vector2_is_unit_fp64();
int test_vector2_is_unit();
#endif

View file

@ -4,42 +4,42 @@
// ==================== FP32 ==================== //
static const int _TEST_FP32_ZERO_QUATERNION_AMOUNT = 5;
static const int _TEST_FP32_NONZERO_QUATERNION_AMOUNT = 7;
static const int _TEST_FP32_ZERO_VECTOR2_AMOUNT = 5;
static const int _TEST_FP32_NONZERO_VECTOR2_AMOUNT = 7;
static const BgcVector2FP32 _TEST_FP32_ZERO_QUATERNION_LIST[] = {
static const BgcVector2FP32 _TEST_FP32_ZERO_VECTOR2_LIST[] = {
{ 0.0f, 0.0f },
{ BGC_EPSYLON_FP32, 0.0f },
{ -BGC_EPSYLON_FP32, 0.0f },
{ 0.0f, BGC_EPSYLON_FP32 },
{ 0.0f, -BGC_EPSYLON_FP32 }
{ 0.75f * BGC_EPSYLON_FP32, 0.0f },
{ -0.75f * BGC_EPSYLON_FP32, 0.0f },
{ 0.0f, 0.75f * BGC_EPSYLON_FP32 },
{ 0.0f, -0.75f * BGC_EPSYLON_FP32 }
};
static const BgcVector2FP32 _TEST_FP32_NONZERO_NUMBERS[] = {
static const BgcVector2FP32 _TEST_FP32_NONZERO_VECTOR2_LIST[] = {
{ 0.0f, 1.0f },
{ 1.5f * BGC_EPSYLON_FP32, 0.0f },
{ -1.5f * BGC_EPSYLON_FP32, 0.0f },
{ 0.0f, 1.5f * BGC_EPSYLON_FP32 },
{ 0.0f, -1.5f * BGC_EPSYLON_FP32 },
{ 1.25f * BGC_EPSYLON_FP32, 0.0f },
{ -1.25f * BGC_EPSYLON_FP32, 0.0f },
{ 0.0f, 1.25f * BGC_EPSYLON_FP32 },
{ 0.0f, -1.25f * BGC_EPSYLON_FP32 },
{ BGC_EPSYLON_FP32, BGC_EPSYLON_FP32 },
{ -BGC_EPSYLON_FP32, -BGC_EPSYLON_FP32 }
};
int test_bgc_vector2_is_zero_fp32()
int test_vector2_is_zero_fp32()
{
print_testing_name("bgc_vector2_is_zero_fp32");
// Testing zero values:
for (int i = 0; i < _TEST_FP32_ZERO_QUATERNION_AMOUNT; i++) {
if (!bgc_vector2_is_zero_fp32(&_TEST_FP32_ZERO_QUATERNION_LIST[i])) {
for (int i = 0; i < _TEST_FP32_ZERO_VECTOR2_AMOUNT; i++) {
if (!bgc_vector2_is_zero_fp32(&_TEST_FP32_ZERO_VECTOR2_LIST[i])) {
print_testing_failed();
return TEST_FAILED;
}
}
// Testing non-zero values:
for (int i = 0; i < _TEST_FP32_NONZERO_QUATERNION_AMOUNT; i++) {
if (bgc_vector2_is_zero_fp32(&_TEST_FP32_NONZERO_NUMBERS[i])) {
for (int i = 0; i < _TEST_FP32_NONZERO_VECTOR2_AMOUNT; i++) {
if (bgc_vector2_is_zero_fp32(&_TEST_FP32_NONZERO_VECTOR2_LIST[i])) {
print_testing_failed();
return TEST_FAILED;
}
@ -52,42 +52,42 @@ int test_bgc_vector2_is_zero_fp32()
// ==================== FP64 ==================== //
static const int _TEST_FP64_ZERO_QUATERNION_AMOUNT = 5;
static const int _TEST_FP64_NONZERO_QUATERNION_AMOUNT = 7;
static const int _TEST_FP64_ZERO_VECTOR2_AMOUNT = 5;
static const int _TEST_FP64_NONZERO_VECTOR2_AMOUNT = 7;
static const BgcVector2FP64 _TEST_FP64_ZERO_QUATERNION_LIST[] = {
static const BgcVector2FP64 _TEST_FP64_ZERO_VECTOR2_LIST[] = {
{ 0.0, 0.0 },
{ BGC_EPSYLON_FP64, 0.0 },
{ -BGC_EPSYLON_FP64, 0.0 },
{ 0.0, BGC_EPSYLON_FP64 },
{ 0.0, -BGC_EPSYLON_FP64 }
{ 0.75 * BGC_EPSYLON_FP64, 0.0 },
{ -0.75 * BGC_EPSYLON_FP64, 0.0 },
{ 0.0, 0.75 * BGC_EPSYLON_FP64 },
{ 0.0, -0.75 * BGC_EPSYLON_FP64 }
};
static const BgcVector2FP64 _TEST_FP64_NONZERO_NUMBERS[] = {
static const BgcVector2FP64 _TEST_FP64_NONZERO_VECTOR2_LIST[] = {
{ 0.0, 1.0 },
{ 1.5 * BGC_EPSYLON_FP64, 0.0 },
{ -1.5 * BGC_EPSYLON_FP64, 0.0 },
{ 0.0, 1.5 * BGC_EPSYLON_FP64 },
{ 0.0, -1.5 * BGC_EPSYLON_FP64 },
{ BGC_EPSYLON_FP64, BGC_EPSYLON_FP64 },
{ -BGC_EPSYLON_FP64, -BGC_EPSYLON_FP64 }
{ 1.25 * BGC_EPSYLON_FP64, 0.0 },
{ -1.25 * BGC_EPSYLON_FP64, 0.0 },
{ 0.0, 1.25 * BGC_EPSYLON_FP64 },
{ 0.0, -1.25 * BGC_EPSYLON_FP64 },
{ 1.25 * BGC_EPSYLON_FP64, 1.25 * BGC_EPSYLON_FP64 },
{ -1.25 * BGC_EPSYLON_FP64, -1.25 * BGC_EPSYLON_FP64 }
};
int test_bgc_vector2_is_zero_fp64()
int test_vector2_is_zero_fp64()
{
print_testing_name("bgc_vector2_is_zero_fp64");
// Testing zero values:
for (int i = 0; i < _TEST_FP64_ZERO_QUATERNION_AMOUNT; i++) {
if (!bgc_vector2_is_zero_fp64(&_TEST_FP64_ZERO_QUATERNION_LIST[i])) {
for (int i = 0; i < _TEST_FP64_ZERO_VECTOR2_AMOUNT; i++) {
if (!bgc_vector2_is_zero_fp64(&_TEST_FP64_ZERO_VECTOR2_LIST[i])) {
print_testing_failed();
return TEST_FAILED;
}
}
// Testing non-zero values:
for (int i = 0; i < _TEST_FP64_NONZERO_QUATERNION_AMOUNT; i++) {
if (bgc_vector2_is_zero_fp64(&_TEST_FP64_NONZERO_NUMBERS[i])) {
for (int i = 0; i < _TEST_FP64_NONZERO_VECTOR2_AMOUNT; i++) {
if (bgc_vector2_is_zero_fp64(&_TEST_FP64_NONZERO_VECTOR2_LIST[i])) {
print_testing_failed();
return TEST_FAILED;
}
@ -98,13 +98,13 @@ int test_bgc_vector2_is_zero_fp64()
return TEST_SUCCES;
}
int test_bgc_vector2_is_zero()
int test_vector2_is_zero()
{
if (test_bgc_vector2_is_zero_fp32() != TEST_SUCCES) {
if (test_vector2_is_zero_fp32() != TEST_SUCCES) {
return TEST_FAILED;
}
if (test_bgc_vector2_is_zero_fp64() != TEST_SUCCES) {
if (test_vector2_is_zero_fp64() != TEST_SUCCES) {
return TEST_FAILED;
}

View file

@ -1,10 +1,10 @@
#ifndef _TEST_VECTOR2_IS_ZERO_H_
#define _TEST_VECTOR2_IS_ZERO_H_
int test_bgc_vector2_is_zero_fp32();
int test_vector2_is_zero_fp32();
int test_bgc_vector2_is_zero_fp64();
int test_vector2_is_zero_fp64();
int test_bgc_vector2_is_zero();
int test_vector2_is_zero();
#endif

View file

@ -2,7 +2,7 @@
#include "./../../helpers.h"
int test_bgc_vector2_reset_fp32()
int test_vector2_reset_fp32()
{
BgcVector2FP32 vector;
@ -20,7 +20,7 @@ int test_bgc_vector2_reset_fp32()
return TEST_SUCCES;
}
int test_bgc_vector2_reset_fp64()
int test_vector2_reset_fp64()
{
BgcVector2FP64 vector;
@ -38,13 +38,13 @@ int test_bgc_vector2_reset_fp64()
return TEST_SUCCES;
}
int test_bgc_vector2_reset()
int test_vector2_reset()
{
if (test_bgc_vector2_reset_fp32() != TEST_SUCCES) {
if (test_vector2_reset_fp32() != TEST_SUCCES) {
return TEST_FAILED;
}
if (test_bgc_vector2_reset_fp64() != TEST_SUCCES) {
if (test_vector2_reset_fp64() != TEST_SUCCES) {
return TEST_FAILED;
}

View file

@ -1,10 +1,10 @@
#ifndef _TEST_VECTOR2_RESET_H_
#define _TEST_VECTOR2_RESET_H_
int test_bgc_vector2_reset_fp32();
int test_vector2_reset_fp32();
int test_bgc_vector2_reset_fp64();
int test_vector2_reset_fp64();
int test_bgc_vector2_reset();
int test_vector2_reset();
#endif

View file

@ -6,7 +6,7 @@
// ==================== FP32 ==================== //
int test_bgc_vector2_set_values_fp32()
int test_vector2_set_values_fp32()
{
BgcVector2FP32 vector;
@ -40,7 +40,7 @@ int test_bgc_vector2_set_values_fp32()
// ==================== FP64 ==================== //
int test_bgc_vector2_set_values_fp64()
int test_vector2_set_values_fp64()
{
BgcVector2FP64 vector;
@ -73,13 +73,13 @@ int test_bgc_vector2_set_values_fp64()
return TEST_SUCCES;
}
int test_bgc_vector2_set_values()
int test_vector2_set_values()
{
if (test_bgc_vector2_set_values_fp32() != TEST_SUCCES) {
if (test_vector2_set_values_fp32() != TEST_SUCCES) {
return TEST_FAILED;
}
if (test_bgc_vector2_set_values_fp64() != TEST_SUCCES) {
if (test_vector2_set_values_fp64() != TEST_SUCCES) {
return TEST_FAILED;
}

View file

@ -1,10 +1,10 @@
#ifndef _TEST_VECTOR2_SET_VALUES_H_
#define _TEST_VECTOR2_SET_VALUES_H_
int test_bgc_vector2_set_values_fp32();
int test_vector2_set_values_fp32();
int test_bgc_vector2_set_values_fp64();
int test_vector2_set_values_fp64();
int test_bgc_vector2_set_values();
int test_vector2_set_values();
#endif

View file

@ -22,7 +22,7 @@ static const BgcVector2FP32 _TEST_FP32_VECTOR2_LIST2[] = {
{ 1000.0f, -0.00025f }
};
int test_bgc_vector2_swap_fp32()
int test_vector2_swap_fp32()
{
BgcVector2FP32 vector1, vector2;
@ -66,7 +66,7 @@ static const BgcVector2FP64 _TEST_FP64_VECTOR2_LIST2[] = {
{ 1000.0, -0.00025 }
};
int test_bgc_vector2_swap_fp64()
int test_vector2_swap_fp64()
{
BgcVector2FP64 vector1, vector2;
@ -92,13 +92,13 @@ int test_bgc_vector2_swap_fp64()
return TEST_SUCCES;
}
int test_bgc_vector2_swap()
int test_vector2_swap()
{
if (test_bgc_vector2_swap_fp32() != TEST_SUCCES) {
if (test_vector2_swap_fp32() != TEST_SUCCES) {
return TEST_FAILED;
}
if (test_bgc_vector2_swap_fp64() != TEST_SUCCES) {
if (test_vector2_swap_fp64() != TEST_SUCCES) {
return TEST_FAILED;
}

View file

@ -1,10 +1,10 @@
#ifndef _TEST_VECTOR2_SWAP_H_
#define _TEST_VECTOR2_SWAP_H_
int test_bgc_vector2_swap_fp32();
int test_vector2_swap_fp32();
int test_bgc_vector2_swap_fp64();
int test_vector2_swap_fp64();
int test_bgc_vector2_swap();
int test_vector2_swap();
#endif

View file

@ -4,23 +4,27 @@ int test_vector3()
{
print_testing_section("BGC Vector3");
if (test_bgc_vector3_reset() != TEST_SUCCES) {
if (test_vector3_reset() != TEST_SUCCES) {
return TEST_FAILED;
}
if (test_bgc_vector3_set_values() != TEST_SUCCES) {
if (test_vector3_set_values() != TEST_SUCCES) {
return TEST_FAILED;
}
if (test_bgc_vector3_copy() != TEST_SUCCES) {
if (test_vector3_copy() != TEST_SUCCES) {
return TEST_FAILED;
}
if (test_bgc_vector3_swap() != TEST_SUCCES) {
if (test_vector3_swap() != TEST_SUCCES) {
return TEST_FAILED;
}
if (test_bgc_vector3_is_zero() != TEST_SUCCES) {
if (test_vector3_is_zero() != TEST_SUCCES) {
return TEST_FAILED;
}
if (test_vector3_is_unit() != TEST_SUCCES) {
return TEST_FAILED;
}

View file

@ -7,6 +7,7 @@
#include "./vector3/vector3_copy.h"
#include "./vector3/vector3_swap.h"
#include "./vector3/vector3_is_zero.h"
#include "./vector3/vector3_is_unit.h"
int test_vector3();

View file

@ -14,7 +14,7 @@ static const BgcVector3FP32 _TEST_FP32_VECTOR3_LIST[] = {
{ -100.0f, 100.0f, -0.001f }
};
int test_bgc_vector3_copy_fp32()
int test_vector3_copy_fp32()
{
BgcVector3FP32 vector;
@ -47,7 +47,7 @@ static const BgcVector3FP64 _TEST_FP64_VECTOR3_LIST[] = {
{ -100.0, 100.0, -0.001 }
};
int test_bgc_vector3_copy_fp64()
int test_vector3_copy_fp64()
{
BgcVector3FP64 vector;
@ -70,13 +70,13 @@ int test_bgc_vector3_copy_fp64()
return TEST_SUCCES;
}
int test_bgc_vector3_copy()
int test_vector3_copy()
{
if (test_bgc_vector3_copy_fp32() != TEST_SUCCES) {
if (test_vector3_copy_fp32() != TEST_SUCCES) {
return TEST_FAILED;
}
if (test_bgc_vector3_copy_fp64() != TEST_SUCCES) {
if (test_vector3_copy_fp64() != TEST_SUCCES) {
return TEST_FAILED;
}

View file

@ -1,10 +1,10 @@
#ifndef _TEST_VECTOR3_COPY_H_
#define _TEST_VECTOR3_COPY_H_
int test_bgc_vector3_copy_fp32();
int test_vector3_copy_fp32();
int test_bgc_vector3_copy_fp64();
int test_vector3_copy_fp64();
int test_bgc_vector3_copy();
int test_vector3_copy();
#endif

View file

@ -0,0 +1,126 @@
#include "./vector3_is_unit.h"
#include "./../../helpers.h"
// ==================== FP32 ==================== //
static const int _TEST_FP32_UNIT_VECTOR3_AMOUNT = 10;
static const int _TEST_FP32_NONUNIT_VECTOR3_AMOUNT = 9;
static const BgcVector3FP32 _TEST_FP32_UNIT_VECTOR3_LIST[] = {
{ 1.0f, 0.0f, 0.0f },
{ 0.0f, -1.0f, 0.0f },
{ 0.0f, -0.8f, 0.6f },
{ -0.6f, 0.0f, 0.8f },
{ 1.0f + 0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f },
{ 1.0f - 0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f },
{ 0.0f, -1.0f + 0.75f * BGC_EPSYLON_FP32, 0.0f },
{ 0.0f, -1.0f - 0.75f * BGC_EPSYLON_FP32, 0.0f },
{ 0.0f, 0.0f, 1.0f + 0.75f * BGC_EPSYLON_FP32 },
{ 0.0f, 0.0f, 1.0f - 0.75f * BGC_EPSYLON_FP32 }
};
static const BgcVector3FP32 _TEST_FP32_NONUNIT_VECTOR3_LIST[] = {
{ 0.0f, 0.0f, 0.0f },
{ 1.0f + 1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f },
{ 1.0f - 1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f },
{ 0.0f, 1.0f + 1.25f * BGC_EPSYLON_FP32, 0.0f },
{ 0.0f, 1.0f - 1.25f * BGC_EPSYLON_FP32, 0.0f },
{ 0.0f, 0.0f, 1.0f + 1.25f * BGC_EPSYLON_FP32 },
{ 0.0f, 0.0f, 1.0f - 1.25f * BGC_EPSYLON_FP32 },
{ 0.8f + 1.25f * BGC_EPSYLON_FP32, -0.6f - 1.25f * BGC_EPSYLON_FP32, 0.0f },
{ 0.6f - 1.25f * BGC_EPSYLON_FP32, -0.8f + 1.25f * BGC_EPSYLON_FP32, 0.0f }
};
int test_vector3_is_unit_fp32()
{
print_testing_name("bgc_vector3_is_unit_fp32");
// Testing zero values:
for (int i = 0; i < _TEST_FP32_UNIT_VECTOR3_AMOUNT; i++) {
if (!bgc_vector3_is_unit_fp32(&_TEST_FP32_UNIT_VECTOR3_LIST[i])) {
print_testing_failed();
return TEST_FAILED;
}
}
// Testing non-zero values:
for (int i = 0; i < _TEST_FP32_NONUNIT_VECTOR3_AMOUNT; i++) {
if (bgc_vector3_is_unit_fp32(&_TEST_FP32_NONUNIT_VECTOR3_LIST[i])) {
print_testing_failed();
return TEST_FAILED;
}
}
print_testing_success();
return TEST_SUCCES;
}
// ==================== FP64 ==================== //
static const int _TEST_FP64_UNIT_VECTOR3_AMOUNT = 10;
static const int _TEST_FP64_NONUNIT_VECTOR3_AMOUNT = 9;
static const BgcVector3FP64 _TEST_FP64_UNIT_VECTOR3_LIST[] = {
{ 1.0, 0.0, 0.0 },
{ 0.0, -1.0, 0.0 },
{ 0.0, -0.8, 0.6 },
{ -0.6, 0.0, 0.8 },
{ 1.0 + 0.75 * BGC_EPSYLON_FP64, 0.0, 0.0 },
{ 1.0 - 0.75 * BGC_EPSYLON_FP64, 0.0, 0.0 },
{ 0.0, -1.0 + 0.75 * BGC_EPSYLON_FP64, 0.0 },
{ 0.0, -1.0 - 0.75 * BGC_EPSYLON_FP64, 0.0 },
{ 0.0, 0.0, 1.0 + 0.75 * BGC_EPSYLON_FP64 },
{ 0.0, 0.0, 1.0 - 0.75 * BGC_EPSYLON_FP64 }
};
static const BgcVector3FP64 _TEST_FP64_NONUNIT_VECTOR3_LIST[] = {
{ 0.0, 0.0, 0.0 },
{ 1.0 + 1.25 * BGC_EPSYLON_FP64, 0.0, 0.0 },
{ 1.0 - 1.25 * BGC_EPSYLON_FP64, 0.0, 0.0 },
{ 0.0, 1.0 + 1.25 * BGC_EPSYLON_FP64, 0.0 },
{ 0.0, 1.0 - 1.25 * BGC_EPSYLON_FP64, 0.0 },
{ 0.0, 0.0, 1.0 + 1.25 * BGC_EPSYLON_FP64 },
{ 0.0, 0.0, 1.0 - 1.25 * BGC_EPSYLON_FP64 },
{ 0.8 + 1.25 * BGC_EPSYLON_FP64, -0.6 - 1.25 * BGC_EPSYLON_FP64, 0.0 },
{ 0.6 - 1.25 * BGC_EPSYLON_FP64, -0.8 + 1.25 * BGC_EPSYLON_FP64, 0.0 }
};
int test_vector3_is_unit_fp64()
{
print_testing_name("bgc_vector3_is_unit_fp64");
// Testing zero values:
for (int i = 0; i < _TEST_FP64_UNIT_VECTOR3_AMOUNT; i++) {
if (!bgc_vector3_is_unit_fp64(&_TEST_FP64_UNIT_VECTOR3_LIST[i])) {
print_testing_failed();
return TEST_FAILED;
}
}
// Testing non-zero values:
for (int i = 0; i < _TEST_FP64_NONUNIT_VECTOR3_AMOUNT; i++) {
if (bgc_vector3_is_unit_fp64(&_TEST_FP64_NONUNIT_VECTOR3_LIST[i])) {
print_testing_failed();
return TEST_FAILED;
}
}
print_testing_success();
return TEST_SUCCES;
}
int test_vector3_is_unit()
{
if (test_vector3_is_unit_fp32() != TEST_SUCCES) {
return TEST_FAILED;
}
if (test_vector3_is_unit_fp64() != TEST_SUCCES) {
return TEST_FAILED;
}
return TEST_SUCCES;
}

View file

@ -0,0 +1,10 @@
#ifndef _TEST_VECTOR3_IS_UNIT_H_
#define _TEST_VECTOR3_IS_UNIT_H_
int test_vector3_is_unit_fp32();
int test_vector3_is_unit_fp64();
int test_vector3_is_unit();
#endif

View file

Internal server error - Personal Git Server: Beyond coding. We Forge.

500

Internal server error

Forgejo version: 11.0.1+gitea-1.22.0

@ -4,46 +4,46 @@
// ==================== FP32 ==================== //
static const int _TEST_FP32_ZERO_QUATERNION_AMOUNT = 7;
static const int _TEST_FP32_NONZERO_QUATERNION_AMOUNT = 9;
static const int _TEST_FP32_ZERO_VECTOR3_AMOUNT = 7;
static const int _TEST_FP32_NONZERO_VECTOR3_AMOUNT = 9;
static const BgcVector3FP32 _TEST_FP32_ZERO_QUATERNION_LIST[] = {
static const BgcVector3FP32 _TEST_FP32_ZERO_VECTOR3_LIST[] = {
{ 0.0f, 0.0f, 0.0f },
{ BGC_EPSYLON_FP32, 0.0f, 0.0f },
{ -BGC_EPSYLON_FP32, 0.0f, 0.0f },
{ 0.0f, BGC_EPSYLON_FP32, 0.0f },