Упрощение тестов

This commit is contained in:
Andrey Pokidov 2025-02-13 19:28:40 +07:00
parent fcf793c758
commit 7f242c4b63
71 changed files with 518 additions and 943 deletions

View file

@ -4,25 +4,17 @@
#include "./../../helpers.h"
typedef struct {
float s0, x1, x2, x3;
} _TestVersorComponentsFP32;
typedef struct {
double s0, x1, x2, x3;
} _TestVersorComponentsFP64;
// ==================== FP32 ==================== //
static const int _TEST_FP32_VERSOR_DATA_AMOUNT = 4;
static const _TestVersorComponentsFP32 _TEST_FP32_VERSOR_DATA_LIST[] = {
static const BgcQuaternionFP32 _TEST_FP32_VERSOR_DATA_LIST[] = {
{ 1.0f, 2.0f, 3.0f, 4.0f },
{ 4.0f, 3.0f, 2.0f, 1.0f },
{ -1.0f, 0.0f, 0.0f, 0.0f },
{ 1.0f, 0.0f, 1.0f, 0.0f }
};
int test_versor_set_values_fp32()
void test_versor_set_values_fp32()
{
float versor_module, ratio;
BgcVersorFP32 versor;
@ -41,9 +33,8 @@ int test_versor_set_values_fp32()
versor_module = sqrtf(versor.s0 * versor.s0 + versor.x1 * versor.x1 + versor.x2 * versor.x2 + versor.x3 * versor.x3);
if (!bgc_is_unit_fp32(versor_module)) {
print_testing_failed();
print_testing_warning("Versor module is not equal to one.");
return TEST_FAILED;
print_testing_error("Versor module is not equal to one.");
return;
}
if (bgc_is_zero_fp32(_TEST_FP32_VERSOR_DATA_LIST[i].s0)) {
@ -53,40 +44,35 @@ int test_versor_set_values_fp32()
ratio = _TEST_FP32_VERSOR_DATA_LIST[i].s0 / versor.s0;
if (!bgc_is_zero_fp32(_TEST_FP32_VERSOR_DATA_LIST[i].x1) && !bgc_are_close_fp32(ratio, _TEST_FP32_VERSOR_DATA_LIST[i].x1 / versor.x1)) {
print_testing_failed();
print_testing_warning("Versor was not normalized proportionally (x1).");
return TEST_FAILED;
print_testing_error("Versor was not normalized proportionally (x1).");
return;
}
if (!bgc_is_zero_fp32(_TEST_FP32_VERSOR_DATA_LIST[i].x2) && !bgc_are_close_fp32(ratio, _TEST_FP32_VERSOR_DATA_LIST[i].x2 / versor.x2)) {
print_testing_failed();
print_testing_warning("Versor was not normalized proportionally (x2).");
return TEST_FAILED;
print_testing_error("Versor was not normalized proportionally (x2).");
return;
}
if (!bgc_is_zero_fp32(_TEST_FP32_VERSOR_DATA_LIST[i].x3) && !bgc_are_close_fp32(ratio, _TEST_FP32_VERSOR_DATA_LIST[i].x3 / versor.x3)) {
print_testing_failed();
print_testing_warning("Versor was not normalized proportionally (x3).");
return TEST_FAILED;
print_testing_error("Versor was not normalized proportionally (x3).");
return;
}
}
print_testing_success();
return TEST_SUCCESS;
}
// ==================== FP64 ==================== //
static const int _TEST_FP64_VERSOR_DATA_AMOUNT = 4;
static const _TestVersorComponentsFP64 _TEST_FP64_VERSOR_DATA_LIST[] = {
static const BgcQuaternionFP64 _TEST_FP64_VERSOR_DATA_LIST[] = {
{ 1.0, 2.0, 3.0, 4.0 },
{ 4.0, 3.0, 2.0, 1.0 },
{ -1.0, 0.0, 0.0, 0.0 },
{ 1.0, 0.0, 1.0, 0.0 }
};
int test_versor_set_values_fp64()
void test_versor_set_values_fp64()
{
double versor_module, ratio;
BgcVersorFP64 versor;
@ -105,9 +91,8 @@ int test_versor_set_values_fp64()
versor_module = sqrt(versor.s0 * versor.s0 + versor.x1 * versor.x1 + versor.x2 * versor.x2 + versor.x3 * versor.x3);
if (!bgc_is_unit_fp64(versor_module)) {
print_testing_failed();
print_testing_warning("Versor module is not equal to one.");
return TEST_SUCCESS;
print_testing_error("Versor module is not equal to one.");
return;
}
if (bgc_is_zero_fp64(_TEST_FP64_VERSOR_DATA_LIST[i].s0)) {
@ -117,38 +102,26 @@ int test_versor_set_values_fp64()
ratio = _TEST_FP64_VERSOR_DATA_LIST[i].s0 / versor.s0;
if (!bgc_is_zero_fp64(_TEST_FP64_VERSOR_DATA_LIST[i].x1) && !bgc_are_close_fp64(ratio, _TEST_FP64_VERSOR_DATA_LIST[i].x1 / versor.x1)) {
print_testing_failed();
print_testing_warning("Versor was not normalized proportionally (x1).");
return TEST_SUCCESS;
print_testing_error("Versor was not normalized proportionally (x1).");
return;
}
if (!bgc_is_zero_fp64(_TEST_FP64_VERSOR_DATA_LIST[i].x2) && !bgc_are_close_fp64(ratio, _TEST_FP64_VERSOR_DATA_LIST[i].x2 / versor.x2)) {
print_testing_failed();
print_testing_warning("Versor was not normalized proportionally (x2).");
return TEST_SUCCESS;
print_testing_error("Versor was not normalized proportionally (x2).");
return;
}
if (!bgc_is_zero_fp64(_TEST_FP64_VERSOR_DATA_LIST[i].x3) && !bgc_are_close_fp64(ratio, _TEST_FP64_VERSOR_DATA_LIST[i].x3 / versor.x3)) {
print_testing_failed();
print_testing_warning("Versor was not normalized proportionally (x3).");
return TEST_SUCCESS;
print_testing_error("Versor was not normalized proportionally (x3).");
return;
}
}
print_testing_success();
return TEST_SUCCESS;
}
int test_versor_set_values()
void test_versor_set_values()
{
if (test_versor_set_values_fp32() != TEST_SUCCESS) {
return TEST_FAILED;
}
if (test_versor_set_values_fp64() != TEST_SUCCESS) {
return TEST_FAILED;
}
return TEST_SUCCESS;
test_versor_set_values_fp32();
test_versor_set_values_fp64();
}