Упрощение тестов
This commit is contained in:
parent
fcf793c758
commit
7f242c4b63
71 changed files with 518 additions and 943 deletions
|
|
@ -2,19 +2,11 @@
|
|||
|
||||
#include "../../helpers.h"
|
||||
|
||||
typedef struct {
|
||||
BgcVersorFP32 versor1, versor2;
|
||||
} _TestVersorPairFP32;
|
||||
|
||||
typedef struct {
|
||||
BgcVersorFP64 versor1, versor2;
|
||||
} _TestVersorPairFP64;
|
||||
|
||||
// ==================== FP32 ==================== //
|
||||
|
||||
static const int _TEST_FP32_CLOSE_VERSOR_PAIR_AMOUNT = 10;
|
||||
|
||||
static const _TestVersorPairFP32 _TEST_FP32_CLOSE_VERSOR_PAIR_LIST[] = {
|
||||
static const TestVersorPairFP32 _TEST_FP32_CLOSE_VERSOR_PAIR_LIST[] = {
|
||||
{
|
||||
{ 1.0f, 0.0f, 0.0f, 0.0f },
|
||||
{ 1.0f + 0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f }
|
||||
|
|
@ -59,7 +51,7 @@ static const _TestVersorPairFP32 _TEST_FP32_CLOSE_VERSOR_PAIR_LIST[] = {
|
|||
|
||||
static const int _TEST_FP32_DIFFERENT_VERSOR_PAIR_AMOUNT = 10;
|
||||
|
||||
static const _TestVersorPairFP32 _TEST_FP32_DIFFERENT_VERSOR_PAIR_LIST[] = {
|
||||
static const TestVersorPairFP32 _TEST_FP32_DIFFERENT_VERSOR_PAIR_LIST[] = {
|
||||
{
|
||||
{ 1.0f, 0.0f, 0.0f, 0.0f },
|
||||
{ 1.0f + 1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f }
|
||||
|
|
@ -102,29 +94,27 @@ static const _TestVersorPairFP32 _TEST_FP32_DIFFERENT_VERSOR_PAIR_LIST[] = {
|
|||
}
|
||||
};
|
||||
|
||||
int test_versor_are_close_fp32()
|
||||
void test_versor_are_close_fp32()
|
||||
{
|
||||
print_testing_name("bgc_versor_are_close_fp32");
|
||||
|
||||
// Testing close pairs of versors:
|
||||
for (int i = 0; i < _TEST_FP32_CLOSE_VERSOR_PAIR_AMOUNT; i++) {
|
||||
if (!bgc_versor_are_close_fp32(&_TEST_FP32_CLOSE_VERSOR_PAIR_LIST[i].versor1, &_TEST_FP32_CLOSE_VERSOR_PAIR_LIST[i].versor2)) {
|
||||
print_testing_failed();
|
||||
return TEST_FAILED;
|
||||
if (!bgc_versor_are_close_fp32(&_TEST_FP32_CLOSE_VERSOR_PAIR_LIST[i].first, &_TEST_FP32_CLOSE_VERSOR_PAIR_LIST[i].second)) {
|
||||
print_testing_error("A pair of close versors was not recognized");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Testing different pairs of versors:
|
||||
for (int i = 0; i < _TEST_FP32_DIFFERENT_VERSOR_PAIR_AMOUNT; i++) {
|
||||
if (bgc_versor_are_close_fp32(&_TEST_FP32_DIFFERENT_VERSOR_PAIR_LIST[i].versor1, &_TEST_FP32_DIFFERENT_VERSOR_PAIR_LIST[i].versor2)) {
|
||||
print_testing_failed();
|
||||
return TEST_FAILED;
|
||||
if (bgc_versor_are_close_fp32(&_TEST_FP32_DIFFERENT_VERSOR_PAIR_LIST[i].first, &_TEST_FP32_DIFFERENT_VERSOR_PAIR_LIST[i].second)) {
|
||||
print_testing_error("A pair of different versors was recognized as close versors");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
print_testing_success();
|
||||
|
||||
return TEST_SUCCESS;
|
||||
}
|
||||
|
||||
// ==================== FP64 ==================== //
|
||||
|
|
@ -132,7 +122,7 @@ int test_versor_are_close_fp32()
|
|||
|
||||
static const int _TEST_FP64_CLOSE_VERSOR_PAIR_AMOUNT = 10;
|
||||
|
||||
static const _TestVersorPairFP64 _TEST_FP64_CLOSE_VERSOR_PAIR_LIST[] = {
|
||||
static const TestVersorPairFP64 _TEST_FP64_CLOSE_VERSOR_PAIR_LIST[] = {
|
||||
{
|
||||
{ 1.0, 0.0, 0.0, 0.0 },
|
||||
{ 1.0 + 0.75 * BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 }
|
||||
|
|
@ -177,7 +167,7 @@ static const _TestVersorPairFP64 _TEST_FP64_CLOSE_VERSOR_PAIR_LIST[] = {
|
|||
|
||||
static const int _TEST_FP64_DIFFERENT_VERSOR_PAIR_AMOUNT = 10;
|
||||
|
||||
static const _TestVersorPairFP64 _TEST_FP64_DIFFERENT_VERSOR_PAIR_LIST[] = {
|
||||
static const TestVersorPairFP64 _TEST_FP64_DIFFERENT_VERSOR_PAIR_LIST[] = {
|
||||
{
|
||||
{ 1.0, 0.0, 0.0, 0.0 },
|
||||
{ 1.0 + 1.25 * BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 }
|
||||
|
|
@ -220,40 +210,31 @@ static const _TestVersorPairFP64 _TEST_FP64_DIFFERENT_VERSOR_PAIR_LIST[] = {
|
|||
}
|
||||
};
|
||||
|
||||
int test_versor_are_close_fp64()
|
||||
void test_versor_are_close_fp64()
|
||||
{
|
||||
print_testing_name("bgc_versor_are_close_fp64");
|
||||
|
||||
// Testing close pairs of versors:
|
||||
for (int i = 0; i < _TEST_FP64_CLOSE_VERSOR_PAIR_AMOUNT; i++) {
|
||||
if (!bgc_versor_are_close_fp64(&_TEST_FP64_CLOSE_VERSOR_PAIR_LIST[i].versor1, &_TEST_FP64_CLOSE_VERSOR_PAIR_LIST[i].versor2)) {
|
||||
print_testing_failed();
|
||||
return TEST_FAILED;
|
||||
if (!bgc_versor_are_close_fp64(&_TEST_FP64_CLOSE_VERSOR_PAIR_LIST[i].first, &_TEST_FP64_CLOSE_VERSOR_PAIR_LIST[i].second)) {
|
||||
print_testing_error("A pair of close versors was not recognized");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Testing different pairs of versors:
|
||||
for (int i = 0; i < _TEST_FP64_DIFFERENT_VERSOR_PAIR_AMOUNT; i++) {
|
||||
if (bgc_versor_are_close_fp64(&_TEST_FP64_DIFFERENT_VERSOR_PAIR_LIST[i].versor1, &_TEST_FP64_DIFFERENT_VERSOR_PAIR_LIST[i].versor2)) {
|
||||
print_testing_failed();
|
||||
return TEST_FAILED;
|
||||
if (bgc_versor_are_close_fp64(&_TEST_FP64_DIFFERENT_VERSOR_PAIR_LIST[i].first, &_TEST_FP64_DIFFERENT_VERSOR_PAIR_LIST[i].second)) {
|
||||
print_testing_error("A pair of different versors was recognized as close versors");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
print_testing_success();
|
||||
|
||||
return TEST_SUCCESS;
|
||||
}
|
||||
|
||||
int test_versor_are_close()
|
||||
void test_versor_are_close()
|
||||
{
|
||||
if (test_versor_are_close_fp32() != TEST_SUCCESS) {
|
||||
return TEST_FAILED;
|
||||
}
|
||||
|
||||
if (test_versor_are_close_fp64() != TEST_SUCCESS) {
|
||||
return TEST_FAILED;
|
||||
}
|
||||
|
||||
return TEST_SUCCESS;
|
||||
test_versor_are_close_fp32();
|
||||
test_versor_are_close_fp64();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue