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

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

@ -65,3 +65,16 @@ int test_bgc_vector2_copy_fp64()
return TEST_SUCCES;
}
int test_bgc_vector2_copy()
{
if (test_bgc_vector2_copy_fp32() != TEST_SUCCES) {
return TEST_FAILED;
}
if (test_bgc_vector2_copy_fp64() != TEST_SUCCES) {
return TEST_FAILED;
}
return TEST_SUCCES;
}

View file

@ -5,4 +5,6 @@ int test_bgc_vector2_copy_fp32();
int test_bgc_vector2_copy_fp64();
int test_bgc_vector2_copy();
#endif

View file

@ -0,0 +1,112 @@
#include "./vector2_is_zero.h"
#include "./../../helpers.h"
// ==================== FP32 ==================== //
static const int _TEST_FP32_ZERO_QUATERNION_AMOUNT = 5;
static const int _TEST_FP32_NONZERO_QUATERNION_AMOUNT = 7;
static const BgcVector2FP32 _TEST_FP32_ZERO_QUATERNION_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 }
};
static const BgcVector2FP32 _TEST_FP32_NONZERO_NUMBERS[] = {
{ 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 },
{ BGC_EPSYLON_FP32, BGC_EPSYLON_FP32 },
{ -BGC_EPSYLON_FP32, -BGC_EPSYLON_FP32 }
};
int test_bgc_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])) {
print_testing_failed();
return TEST_FAILED;
}
}
// Testing non-zero values:
for (int i = 0; i < _TEST_FP32_ZERO_QUATERNION_AMOUNT; i++) {
if (bgc_vector2_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 = 5;
static const int _TEST_FP64_NONZERO_QUATERNION_AMOUNT = 7;
static const BgcVector2FP64 _TEST_FP64_ZERO_QUATERNION_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 }
};
static const BgcVector2FP64 _TEST_FP64_NONZERO_NUMBERS[] = {
{ 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 }
};
int test_bgc_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])) {
print_testing_failed();
return TEST_FAILED;
}
}
// Testing non-zero values:
for (int i = 0; i < _TEST_FP64_ZERO_QUATERNION_AMOUNT; i++) {
if (bgc_vector2_is_zero_fp64(&_TEST_FP64_NONZERO_NUMBERS[i])) {
print_testing_failed();
return TEST_FAILED;
}
}
print_testing_success();
return TEST_SUCCES;
}
int test_bgc_vector2_is_zero()
{
if (test_bgc_vector2_is_zero_fp32() != TEST_SUCCES) {
return TEST_FAILED;
}
if (test_bgc_vector2_is_zero_fp64() != TEST_SUCCES) {
return TEST_FAILED;
}
return TEST_SUCCES;
}

View file

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

View file

@ -37,3 +37,16 @@ int test_bgc_vector2_reset_fp64()
return TEST_SUCCES;
}
int test_bgc_vector2_reset()
{
if (test_bgc_vector2_reset_fp32() != TEST_SUCCES) {
return TEST_FAILED;
}
if (test_bgc_vector2_reset_fp64() != TEST_SUCCES) {
return TEST_FAILED;
}
return TEST_SUCCES;
}

View file

@ -5,4 +5,6 @@ int test_bgc_vector2_reset_fp32();
int test_bgc_vector2_reset_fp64();
int test_bgc_vector2_reset();
#endif

View file

@ -72,3 +72,16 @@ int test_bgc_vector2_set_values_fp64()
return TEST_SUCCES;
}
int test_bgc_vector2_set_values()
{
if (test_bgc_vector2_set_values_fp32() != TEST_SUCCES) {
return TEST_FAILED;
}
if (test_bgc_vector2_set_values_fp64() != TEST_SUCCES) {
return TEST_FAILED;
}
return TEST_SUCCES;
}

View file

@ -5,4 +5,6 @@ int test_bgc_vector2_set_values_fp32();
int test_bgc_vector2_set_values_fp64();
int test_bgc_vector2_set_values();
#endif

View file

@ -4,8 +4,6 @@
#include "./../../helpers.h"
// ==================== FP32 ==================== //
static const int _TEST_FP32_VECTOR2_AMOUNT = 4;
@ -93,3 +91,16 @@ int test_bgc_vector2_swap_fp64()
return TEST_SUCCES;
}
int test_bgc_vector2_swap()
{
if (test_bgc_vector2_swap_fp32() != TEST_SUCCES) {
return TEST_FAILED;
}
if (test_bgc_vector2_swap_fp64() != TEST_SUCCES) {
return TEST_FAILED;
}
return TEST_SUCCES;
}

View file

@ -5,4 +5,6 @@ int test_bgc_vector2_swap_fp32();
int test_bgc_vector2_swap_fp64();
int test_bgc_vector2_swap();
#endif