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

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

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

View file

@ -1,10 +1,10 @@
#ifndef _TEST_VERSOR_ARE_CLOSE_H_
#define _TEST_VERSOR_ARE_CLOSE_H_
int test_versor_are_close_fp32();
void test_versor_are_close_fp32();
int test_versor_are_close_fp64();
void test_versor_are_close_fp64();
int test_versor_are_close();
void test_versor_are_close();
#endif

View file

@ -4,19 +4,11 @@
#include "./../../helpers.h"
typedef struct {
BgcVersorFP32 first, second, result;
} _TestVersorTripletFP32;
typedef struct {
BgcVersorFP64 first, second, result;
} _TestVersorTripletFP64;
// ==================== FP32 ==================== //
static const int _TEST_FP32_VERSOR_TRIPLET_AMOUNT = 5;
static const _TestVersorTripletFP32 _TEST_FP32_VERSOR_TRIPLET_LIST[] = {
static const TestVersorTripletFP32 _TEST_FP32_VERSOR_TRIPLET_LIST[] = {
{
{ 1.0f, 0.0f, 0.0f, 0.0f },
{ 1.0f, 0.0f, 0.0f, 0.0f },
@ -44,7 +36,7 @@ static const _TestVersorTripletFP32 _TEST_FP32_VERSOR_TRIPLET_LIST[] = {
}
};
int test_versor_combine_fp32()
void test_versor_combine_fp32()
{
BgcVersorFP32 versor;
@ -55,20 +47,18 @@ int test_versor_combine_fp32()
if (!bgc_versor_are_close_fp32(&versor, &_TEST_FP32_VERSOR_TRIPLET_LIST[i].result)) {
print_testing_failed();
return TEST_FAILED;
return;
}
}
print_testing_success();
return TEST_SUCCESS;
}
// ==================== FP64 ==================== //
static const int _TEST_FP64_VERSOR_TRIPLET_AMOUNT = 5;
static const _TestVersorTripletFP64 _TEST_FP64_VERSOR_TRIPLET_LIST[] = {
static const TestVersorTripletFP64 _TEST_FP64_VERSOR_TRIPLET_LIST[] = {
{
{ 1.0, 0.0, 0.0, 0.0 },
{ 1.0, 0.0, 0.0, 0.0 },
@ -96,7 +86,7 @@ static const _TestVersorTripletFP64 _TEST_FP64_VERSOR_TRIPLET_LIST[] = {
}
};
int test_versor_combine_fp64()
void test_versor_combine_fp64()
{
BgcVersorFP64 versor;
@ -107,24 +97,15 @@ int test_versor_combine_fp64()
if (!bgc_versor_are_close_fp64(&versor, &_TEST_FP64_VERSOR_TRIPLET_LIST[i].result)) {
print_testing_failed();
return TEST_FAILED;
return;
}
}
print_testing_success();
return TEST_SUCCESS;
}
int test_versor_combine()
void test_versor_combine()
{
if (test_versor_combine_fp32() != TEST_SUCCESS) {
return TEST_FAILED;
}
if (test_versor_combine_fp64() != TEST_SUCCESS) {
return TEST_FAILED;
}
return TEST_SUCCESS;
test_versor_combine_fp32();
test_versor_combine_fp64();
}

View file

@ -1,10 +1,10 @@
#ifndef _TEST_VERSOR_COMBINE_H_
#define _TEST_VERSOR_COMBINE_H_
int test_versor_combine_fp32();
void test_versor_combine_fp32();
int test_versor_combine_fp64();
void test_versor_combine_fp64();
int test_versor_combine();
void test_versor_combine();
#endif

View file

@ -18,14 +18,14 @@ static const BgcVersorFP32 _TEST_FP32_VERSOR_LIST[] = {
{ 0.7071067812f, 0.0f, 0.0f, -0.7071067812f }
};
int test_versor_copy_fp32()
void test_versor_copy_fp32()
{
BgcVersorFP32 versor;
print_testing_name("bgc_versor_copy_fp32");
for (int i = 0; i < _TEST_FP32_VERSOR_AMOUNT; i++) {
bgc_versor_copy_fp32(&_TEST_FP32_VERSOR_LIST[i], &versor);
if (versor.s0 != _TEST_FP32_VERSOR_LIST[i].s0 ||
@ -33,13 +33,11 @@ int test_versor_copy_fp32()
versor.x2 != _TEST_FP32_VERSOR_LIST[i].x2 ||
versor.x3 != _TEST_FP32_VERSOR_LIST[i].x3) {
print_testing_failed();
return TEST_FAILED;
return;
}
}
print_testing_success();
return TEST_SUCCESS;
}
// ==================== FP64 ==================== //
@ -56,7 +54,7 @@ static const BgcVersorFP64 _TEST_FP64_VERSOR_LIST[] = {
{ 0.7071067811865475, 0.0, 0.0, -0.7071067811865475 }
};
int test_versor_copy_fp64()
void test_versor_copy_fp64()
{
BgcVersorFP64 versor;
@ -71,24 +69,15 @@ int test_versor_copy_fp64()
versor.x2 != _TEST_FP64_VERSOR_LIST[i].x2 ||
versor.x3 != _TEST_FP64_VERSOR_LIST[i].x3) {
print_testing_failed();
return TEST_FAILED;
return;
}
}
print_testing_success();
return TEST_SUCCESS;
}
int test_versor_copy()
void test_versor_copy()
{
if (test_versor_copy_fp32() != TEST_SUCCESS) {
return TEST_FAILED;
}
if (test_versor_copy_fp64() != TEST_SUCCESS) {
return TEST_FAILED;
}
return TEST_SUCCESS;
test_versor_copy_fp32();
test_versor_copy_fp64();
}

View file

@ -1,10 +1,10 @@
#ifndef _TEST_VERSOR_COPY_H_
#define _TEST_VERSOR_COPY_H_
int test_versor_copy_fp32();
void test_versor_copy_fp32();
int test_versor_copy_fp64();
void test_versor_copy_fp64();
int test_versor_copy();
void test_versor_copy();
#endif

View file

@ -27,29 +27,27 @@ static const BgcVersorFP32 _TEST_FP32_NON_IDENTIYTY_VERSOR_LIST[] = {
{ 1.0f - 1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f }
};
int test_versor_is_identity_fp32()
void test_versor_is_identity_fp32()
{
print_testing_name("bgc_versor_is_identity_fp32");
// Testing zero values:
for (int i = 0; i < _TEST_FP32_IDENTIYTY_VERSOR_AMOUNT; i++) {
if (!bgc_versor_is_identity_fp32(&_TEST_FP32_IDENTIYTY_VERSOR_LIST[i])) {
print_testing_failed();
return TEST_FAILED;
print_testing_error("An identity versor was not recognized");
return;
}
}
// Testing non-zero values:
for (int i = 0; i < _TEST_FP32_NON_IDENTIYTY_VERSOR_AMOUNT; i++) {
if (bgc_versor_is_identity_fp32(&_TEST_FP32_NON_IDENTIYTY_VERSOR_LIST[i])) {
print_testing_failed();
return TEST_FAILED;
print_testing_error("A non-identity versor was recognized as an identity versor");
return;
}
}
print_testing_success();
return TEST_SUCCESS;
}
// ==================== FP64 ==================== //
@ -77,40 +75,31 @@ static const BgcVersorFP64 _TEST_FP64_NON_IDENTIYTY_VERSOR_LIST[] = {
{ 1.0 - 1.25 * BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 }
};
int test_versor_is_identity_fp64()
void test_versor_is_identity_fp64()
{
print_testing_name("bgc_versor_is_identity_fp64");
// Testing zero values:
for (int i = 0; i < _TEST_FP64_IDENTIYTY_VERSOR_AMOUNT; i++) {
if (!bgc_versor_is_identity_fp64(&_TEST_FP64_IDENTIYTY_VERSOR_LIST[i])) {
print_testing_failed();
return TEST_FAILED;
print_testing_error("An identity versor was not recognized");
return;
}
}
// Testing non-zero values:
for (int i = 0; i < _TEST_FP64_NON_IDENTIYTY_VERSOR_AMOUNT; i++) {
if (bgc_versor_is_identity_fp64(&_TEST_FP64_NON_IDENTIYTY_VERSOR_LIST[i])) {
print_testing_failed();
return TEST_FAILED;
print_testing_error("A non-identity versor was recognized as an identity versor");
return;
}
}
print_testing_success();
return TEST_SUCCESS;
}
int test_versor_is_identity()
void test_versor_is_identity()
{
if (test_versor_is_identity_fp32() != TEST_SUCCESS) {
return TEST_FAILED;
}
if (test_versor_is_identity_fp64() != TEST_SUCCESS) {
return TEST_FAILED;
}
return TEST_SUCCESS;
test_versor_is_identity_fp32();
test_versor_is_identity_fp64();
}

View file

@ -1,10 +1,10 @@
#ifndef _TEST_VERSOR_IS_IDENTITY_H_
#define _TEST_VERSOR_IS_IDENTITY_H_
int test_versor_is_identity_fp32();
void test_versor_is_identity_fp32();
int test_versor_is_identity_fp64();
void test_versor_is_identity_fp64();
int test_versor_is_identity();
void test_versor_is_identity();
#endif

View file

@ -2,25 +2,23 @@
#include "./../../helpers.h"
int test_versor_reset_fp32()
void test_versor_reset_fp32()
{
BgcVersorFP32 versor;
print_testing_name("bgc_versor_reset_fp32");
bgc_versor_reset_fp32(&versor);
if (versor.s0 != 1.0f || versor.x1 != 0.0f || versor.x2 != 0.0f || versor.x3 != 0.0f) {
print_testing_failed();
return TEST_FAILED;
return;
}
print_testing_success();
return TEST_SUCCESS;
}
int test_versor_reset_fp64()
void test_versor_reset_fp64()
{
BgcVersorFP64 versor;
@ -30,23 +28,14 @@ int test_versor_reset_fp64()
if (versor.s0 != 1.0 || versor.x1 != 0.0 || versor.x2 != 0.0 || versor.x3 != 0.0) {
print_testing_failed();
return TEST_FAILED;
return;
}
print_testing_success();
return TEST_SUCCESS;
}
int test_versor_reset()
void test_versor_reset()
{
if (test_versor_reset_fp32() != TEST_SUCCESS) {
return TEST_FAILED;
}
if (test_versor_reset_fp64() != TEST_SUCCESS) {
return TEST_FAILED;
}
return TEST_SUCCESS;
test_versor_reset_fp32();
test_versor_reset_fp64();
}

View file

@ -1,10 +1,10 @@
#ifndef _TEST_VERSOR_RESET_H_
#define _TEST_VERSOR_RESET_H_
int test_versor_reset_fp32();
void test_versor_reset_fp32();
int test_versor_reset_fp64();
void test_versor_reset_fp64();
int test_versor_reset();
void test_versor_reset();
#endif

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();
}

View file

@ -1,10 +1,10 @@
#ifndef _TEST_VERSOR_SET_VALUES_H_
#define _TEST_VERSOR_SET_VALUES_H_
int test_versor_set_values_fp32();
void test_versor_set_values_fp32();
int test_versor_set_values_fp64();
void test_versor_set_values_fp64();
int test_versor_set_values();
void test_versor_set_values();
#endif

View file

@ -4,31 +4,23 @@
#include "./../../helpers.h"
typedef struct {
float s0, x1, x2, x3;
} _TestVersorDataFP32;
typedef struct {
double s0, x1, x2, x3;
} _TestVersorDataFP64;
// ==================== FP32 ==================== //
static const int _TEST_FP32_VERSOR_AMOUNT = 3;
static const _TestVersorDataFP32 _TEST_FP32_VERSOR_LIST1[] = {
static const BgcQuaternionFP32 _TEST_FP32_VERSOR_LIST1[] = {
{ 1.0f, 2.0f, 3.0f, 4.0f },
{ -4.0f, -3.0f, -2.0f, -1.0f },
{ 0.5f, -0.5f, -0.5f, -0.5f }
};
static const _TestVersorDataFP32 _TEST_FP32_VERSOR_LIST2[] = {
static const BgcQuaternionFP32 _TEST_FP32_VERSOR_LIST2[] = {
{ -0.5f, 0.5f, 0.5f, 0.5f },
{ -1.0f, -2.0f, -3.0f, -4.0f },
{ 4.0f, 3.0f, 2.0f, 1.0f }
};
int test_versor_swap_fp32()
void test_versor_swap_fp32()
{
BgcVersorFP32 versor1a, versor2a, versor1b, versor2b;
@ -59,18 +51,16 @@ int test_versor_swap_fp32()
if (versor1a.s0 != versor2b.s0 || versor1a.x1 != versor2b.x1 || versor1a.x2 != versor2b.x2 || versor1a.x3 != versor2b.x3 ||
versor2a.s0 != versor1b.s0 || versor2a.x1 != versor1b.x1 || versor2a.x2 != versor1b.x2 || versor2a.x3 != versor1b.x3) {
print_testing_failed();
return TEST_FAILED;
return;
}
}
print_testing_success();
return TEST_SUCCESS;
}
// ==================== FP64 ==================== //
int test_versor_swap_fp64()
void test_versor_swap_fp64()
{
BgcVersorFP64 versor1a, versor2a, versor1b, versor2b;
@ -101,24 +91,15 @@ int test_versor_swap_fp64()
if (versor1a.s0 != versor2b.s0 || versor1a.x1 != versor2b.x1 || versor1a.x2 != versor2b.x2 || versor1a.x3 != versor2b.x3 ||
versor2a.s0 != versor1b.s0 || versor2a.x1 != versor1b.x1 || versor2a.x2 != versor1b.x2 || versor2a.x3 != versor1b.x3) {
print_testing_failed();
return TEST_FAILED;
return;
}
}
print_testing_success();
return TEST_SUCCESS;
}
int test_versor_swap()
void test_versor_swap()
{
if (test_versor_swap_fp32() != TEST_SUCCESS) {
return TEST_FAILED;
}
if (test_versor_swap_fp64() != TEST_SUCCESS) {
return TEST_FAILED;
}
return TEST_SUCCESS;
test_versor_swap_fp32();
test_versor_swap_fp64();
}

View file

@ -1,10 +1,10 @@
#ifndef _TEST_VERSOR_SWAP_H_
#define _TEST_VERSOR_SWAP_H_
int test_versor_swap_fp32();
void test_versor_swap_fp32();
int test_versor_swap_fp64();
void test_versor_swap_fp64();
int test_versor_swap();
void test_versor_swap();
#endif