Модульные тесты для кватернионов

This commit is contained in:
Andrey Pokidov 2025-02-11 00:01:29 +07:00
parent 2fae0154ac
commit 899ca7dd52
63 changed files with 1233 additions and 284 deletions

View file

@ -8,8 +8,8 @@
static const int _TEST_FP32_VECTOR3_AMOUNT = 4;
static const BgcVector3FP32 _TEST_FP32_VECTOR3_LIST[] = {
{ 1.0f, 2.0f, 3.0 },
{ -3.0, -2.0f, -1.0f },
{ 1.0f, 2.0f, 3.0f },
{ -3.0f, -2.0f, -1.0f },
{ 100.0f, -100.0f, 0.001f },
{ -100.0f, 100.0f, -0.001f }
};
@ -43,8 +43,8 @@ static const int _TEST_FP64_VECTOR3_AMOUNT = 4;
static const BgcVector3FP64 _TEST_FP64_VECTOR3_LIST[] = {
{ 1.0, 2.0, 3.0 },
{ -3.0, -2.0, -1.0 },
{ 100.0, -100.0, 0.001f },
{ -100.0, 100.0, -0.001f }
{ 100.0, -100.0, 0.001 },
{ -100.0, 100.0, -0.001 }
};
int test_bgc_vector3_copy_fp64()
@ -69,3 +69,16 @@ int test_bgc_vector3_copy_fp64()
return TEST_SUCCES;
}
int test_bgc_vector3_copy()
{
if (test_bgc_vector3_copy_fp32() != TEST_SUCCES) {
return TEST_FAILED;
}
if (test_bgc_vector3_copy_fp64() != TEST_SUCCES) {
return TEST_FAILED;
}
return TEST_SUCCES;
}

View file

@ -5,4 +5,6 @@ int test_bgc_vector3_copy_fp32();
int test_bgc_vector3_copy_fp64();
int test_bgc_vector3_copy();
#endif

View file

@ -0,0 +1,120 @@
#include "./vector3_is_zero.h"
#include "./../../helpers.h"
// ==================== FP32 ==================== //
static const int _TEST_FP32_ZERO_QUATERNION_AMOUNT = 7;
static const int _TEST_FP32_NONZERO_QUATERNION_AMOUNT = 9;
static const BgcVector3FP32 _TEST_FP32_ZERO_QUATERNION_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 },
{ 0.0f, -BGC_EPSYLON_FP32, 0.0f },
{ 0.0f, 0.0f, BGC_EPSYLON_FP32 },
{ 0.0f, 0.0f, -BGC_EPSYLON_FP32 }
};
static const BgcVector3FP32 _TEST_FP32_NONZERO_NUMBERS[] = {
{ 0.0f, 1.0f, 0.0f },
{ 1.5f * BGC_EPSYLON_FP32, 0.0f, 0.0f },
{ -1.5f * BGC_EPSYLON_FP32, 0.0f, 0.0f },
{ 0.0f, 1.5f * BGC_EPSYLON_FP32, 0.0f },
{ 0.0f, -1.5f * BGC_EPSYLON_FP32, 0.0f },
{ 0.0f, 0.0f, 1.5f * BGC_EPSYLON_FP32 },
{ 0.0f, 0.0f, -1.5f * BGC_EPSYLON_FP32 },
{ BGC_EPSYLON_FP32, BGC_EPSYLON_FP32, 0.0f },
{ -BGC_EPSYLON_FP32, -BGC_EPSYLON_FP32, 0.0f }
};
int test_bgc_vector3_is_zero_fp32()
{
print_testing_name("bgc_vector3_is_zero_fp32");
// Testing zero values:
for (int i = 0; i < _TEST_FP32_ZERO_QUATERNION_AMOUNT; i++) {
if (!bgc_vector3_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_vector3_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 = 7;
static const int _TEST_FP64_NONZERO_QUATERNION_AMOUNT = 9;
static const BgcVector3FP64 _TEST_FP64_ZERO_QUATERNION_LIST[] = {
{ 0.0, 0.0, 0.0 },
{ BGC_EPSYLON_FP64, 0.0, 0.0 },
{ -BGC_EPSYLON_FP64, 0.0, 0.0 },
{ 0.0, BGC_EPSYLON_FP64, 0.0 },
{ 0.0, -BGC_EPSYLON_FP64, 0.0 },
{ 0.0, 0.0, BGC_EPSYLON_FP64 },
{ 0.0, 0.0, -BGC_EPSYLON_FP64 }
};
static const BgcVector3FP64 _TEST_FP64_NONZERO_NUMBERS[] = {
{ 0.0, 1.0, 0.0 },
{ 1.5 * BGC_EPSYLON_FP64, 0.0, 0.0 },
{ -1.5 * BGC_EPSYLON_FP64, 0.0, 0.0 },
{ 0.0, 1.5 * BGC_EPSYLON_FP64, 0.0 },
{ 0.0, -1.5 * BGC_EPSYLON_FP64, 0.0 },
{ 0.0, 0.0, 1.5 * BGC_EPSYLON_FP64 },
{ 0.0, 0.0, -1.5 * BGC_EPSYLON_FP64 },
{ BGC_EPSYLON_FP64, BGC_EPSYLON_FP64, 0.0 },
{ -BGC_EPSYLON_FP64, -BGC_EPSYLON_FP64, 0.0 }
};
int test_bgc_vector3_is_zero_fp64()
{
print_testing_name("bgc_vector3_is_zero_fp64");
// Testing zero values:
for (int i = 0; i < _TEST_FP64_ZERO_QUATERNION_AMOUNT; i++) {
if (!bgc_vector3_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 (bgc_vector3_is_zero_fp64(&_TEST_FP64_NONZERO_NUMBERS[i])) {
print_testing_failed();
return TEST_FAILED;
}
}
print_testing_success();
return TEST_SUCCES;
}
int test_bgc_vector3_is_zero()
{
if (test_bgc_vector3_is_zero_fp32() != TEST_SUCCES) {
return TEST_FAILED;
}
if (test_bgc_vector3_is_zero_fp64() != TEST_SUCCES) {
return TEST_FAILED;
}
return TEST_SUCCES;
}

View file

@ -0,0 +1,10 @@
#ifndef _TEST_VECTOR3_IS_ZERO_H_
#define _TEST_VECTOR3_IS_ZERO_H_
int test_bgc_vector3_is_zero_fp32();
int test_bgc_vector3_is_zero_fp64();
int test_bgc_vector3_is_zero();
#endif

View file

@ -37,3 +37,16 @@ int test_bgc_vector3_reset_fp64()
return TEST_SUCCES;
}
int test_bgc_vector3_reset()
{
if (test_bgc_vector3_reset_fp32() != TEST_SUCCES) {
return TEST_FAILED;
}
if (test_bgc_vector3_reset_fp64() != TEST_SUCCES) {
return TEST_FAILED;
}
return TEST_SUCCES;
}

View file

@ -5,4 +5,6 @@ int test_bgc_vector3_reset_fp32();
int test_bgc_vector3_reset_fp64();
int test_bgc_vector3_reset();
#endif

View file

@ -72,3 +72,16 @@ int test_bgc_vector3_set_values_fp64()
return TEST_SUCCES;
}
int test_bgc_vector3_set_values()
{
if (test_bgc_vector3_set_values_fp32() != TEST_SUCCES) {
return TEST_FAILED;
}
if (test_bgc_vector3_set_values_fp64() != TEST_SUCCES) {
return TEST_FAILED;
}
return TEST_SUCCES;
}

View file

@ -5,4 +5,6 @@ int test_bgc_vector3_set_values_fp32();
int test_bgc_vector3_set_values_fp64();
int test_bgc_vector3_set_values();
#endif

View file

@ -4,8 +4,6 @@
#include "./../../helpers.h"
// ==================== FP32 ==================== //
static const int _TEST_FP32_VECTOR3_AMOUNT = 4;
@ -97,3 +95,16 @@ int test_bgc_vector3_swap_fp64()
return TEST_SUCCES;
}
int test_bgc_vector3_swap()
{
if (test_bgc_vector3_swap_fp32() != TEST_SUCCES) {
return TEST_FAILED;
}
if (test_bgc_vector3_swap_fp64() != TEST_SUCCES) {
return TEST_FAILED;
}
return TEST_SUCCES;
}

View file

@ -5,4 +5,6 @@ int test_bgc_vector3_swap_fp32();
int test_bgc_vector3_swap_fp64();
int test_bgc_vector3_swap();
#endif