Модульные тесты для 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

@ -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;
}