Добавлено несколько модульных тестов для Vector2, Vector3, Versor
This commit is contained in:
parent
ab4a589e21
commit
86426c9bd5
30 changed files with 1148 additions and 3 deletions
71
basic-geometry-test/tests/vector3/vector3_copy.c
Normal file
71
basic-geometry-test/tests/vector3/vector3_copy.c
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
#include "./vector3_copy.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include "./../../helpers.h"
|
||||
|
||||
// ==================== FP32 ==================== //
|
||||
|
||||
static const int _TEST_FP32_VECTOR3_AMOUNT = 4;
|
||||
static const BgcVector3FP32 _TEST_FP32_VECTOR3_LIST[] = {
|
||||
{ 1.0f, 2.0f, 3.0 },
|
||||
{ -3.0, -2.0f, -1.0f },
|
||||
{ 100.0f, -100.0f, 0.001f },
|
||||
{ -100.0f, 100.0f, -0.001f }
|
||||
};
|
||||
|
||||
int test_bgc_vector3_copy_fp32()
|
||||
{
|
||||
BgcVector3FP32 vector;
|
||||
|
||||
print_testing_name("bgc_vector3_copy_fp32");
|
||||
|
||||
for (int i = 0; i < _TEST_FP32_VECTOR3_AMOUNT; i++) {
|
||||
|
||||
bgc_vector3_copy_fp32(&_TEST_FP32_VECTOR3_LIST[i], &vector);
|
||||
|
||||
if (vector.x1 != _TEST_FP32_VECTOR3_LIST[i].x1 ||
|
||||
vector.x2 != _TEST_FP32_VECTOR3_LIST[i].x2 ||
|
||||
vector.x3 != _TEST_FP32_VECTOR3_LIST[i].x3) {
|
||||
print_testing_failed();
|
||||
return TEST_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
print_testing_success();
|
||||
|
||||
return TEST_SUCCES;
|
||||
}
|
||||
|
||||
// ==================== FP64 ==================== //
|
||||
|
||||
static const int _TEST_FP64_VECTOR3_AMOUNT = 4;
|
||||
static const BgcVector3FP64 _TEST_FP64_VECTOR3_LIST[] = {
|
||||
{ 1.0, 2.0, 3.0 },
|
||||
{ -3.0, -2.0, -1.0 },
|
||||
{ 100.0, -100.0, 0.001f },
|
||||
{ -100.0, 100.0, -0.001f }
|
||||
};
|
||||
|
||||
int test_bgc_vector3_copy_fp64()
|
||||
{
|
||||
BgcVector3FP64 vector;
|
||||
|
||||
print_testing_name("bgc_vector3_copy_fp64");
|
||||
|
||||
for (int i = 0; i < _TEST_FP64_VECTOR3_AMOUNT; i++) {
|
||||
|
||||
bgc_vector3_copy_fp64(&_TEST_FP64_VECTOR3_LIST[i], &vector);
|
||||
|
||||
if (vector.x1 != _TEST_FP64_VECTOR3_LIST[i].x1 ||
|
||||
vector.x2 != _TEST_FP64_VECTOR3_LIST[i].x2 ||
|
||||
vector.x3 != _TEST_FP64_VECTOR3_LIST[i].x3) {
|
||||
print_testing_failed();
|
||||
return TEST_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
print_testing_success();
|
||||
|
||||
return TEST_SUCCES;
|
||||
}
|
||||
8
basic-geometry-test/tests/vector3/vector3_copy.h
Normal file
8
basic-geometry-test/tests/vector3/vector3_copy.h
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
#ifndef _TEST_VECTOR3_COPY_H_
|
||||
#define _TEST_VECTOR3_COPY_H_
|
||||
|
||||
int test_bgc_vector3_copy_fp32();
|
||||
|
||||
int test_bgc_vector3_copy_fp64();
|
||||
|
||||
#endif
|
||||
39
basic-geometry-test/tests/vector3/vector3_reset.c
Normal file
39
basic-geometry-test/tests/vector3/vector3_reset.c
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
#include "./vector3_reset.h"
|
||||
|
||||
#include "./../../helpers.h"
|
||||
|
||||
int test_bgc_vector3_reset_fp32()
|
||||
{
|
||||
BgcVector3FP32 vector;
|
||||
|
||||
print_testing_name("bgc_vector3_reset_fp32");
|
||||
|
||||
bgc_vector3_reset_fp32(&vector);
|
||||
|
||||
if (vector.x1 != 0.0f || vector.x2 != 0.0f || vector.x3 != 0.0f) {
|
||||
print_testing_failed();
|
||||
return TEST_FAILED;
|
||||
}
|
||||
|
||||
print_testing_success();
|
||||
|
||||
return TEST_SUCCES;
|
||||
}
|
||||
|
||||
int test_bgc_vector3_reset_fp64()
|
||||
{
|
||||
BgcVector3FP64 vector;
|
||||
|
||||
print_testing_name("bgc_vector3_reset_fp64");
|
||||
|
||||
bgc_vector3_reset_fp64(&vector);
|
||||
|
||||
if (vector.x1 != 0.0 || vector.x2 != 0.0 || vector.x3 != 0.0) {
|
||||
print_testing_failed();
|
||||
return TEST_FAILED;
|
||||
}
|
||||
|
||||
print_testing_success();
|
||||
|
||||
return TEST_SUCCES;
|
||||
}
|
||||
8
basic-geometry-test/tests/vector3/vector3_reset.h
Normal file
8
basic-geometry-test/tests/vector3/vector3_reset.h
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
#ifndef _TEST_VECTOR3_RESET_H_
|
||||
#define _TEST_VECTOR3_RESET_H_
|
||||
|
||||
int test_bgc_vector3_reset_fp32();
|
||||
|
||||
int test_bgc_vector3_reset_fp64();
|
||||
|
||||
#endif
|
||||
74
basic-geometry-test/tests/vector3/vector3_set_values.c
Normal file
74
basic-geometry-test/tests/vector3/vector3_set_values.c
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
#include "./vector3_set_values.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include "./../../helpers.h"
|
||||
|
||||
// ==================== FP32 ==================== //
|
||||
|
||||
int test_bgc_vector3_set_values_fp32()
|
||||
{
|
||||
BgcVector3FP32 vector;
|
||||
|
||||
print_testing_name("bgc_vector3_set_values_fp32");
|
||||
|
||||
bgc_vector3_set_values_fp32(1.0f, 2.0f, 3.0f, &vector);
|
||||
|
||||
if (vector.x1 != 1.0f || vector.x2 != 2.0f || vector.x3 != 3.0f) {
|
||||
print_testing_failed();
|
||||
return TEST_FAILED;
|
||||
}
|
||||
|
||||
bgc_vector3_set_values_fp32(-3.0f, -5.0f, -7.0f, &vector);
|
||||
|
||||
if (vector.x1 != -3.0f || vector.x2 != -5.0f || vector.x3 != -7.0f) {
|
||||
print_testing_failed();
|
||||
return TEST_FAILED;
|
||||
}
|
||||
|
||||
bgc_vector3_set_values_fp32(-2.0f, 2.0f, 4.0f, &vector);
|
||||
|
||||
if (vector.x1 != -2.0f || vector.x2 != 2.0f || vector.x3 != 4.0f) {
|
||||
print_testing_failed();
|
||||
return TEST_FAILED;
|
||||
}
|
||||
|
||||
print_testing_success();
|
||||
|
||||
return TEST_SUCCES;
|
||||
}
|
||||
|
||||
// ==================== FP64 ==================== //
|
||||
|
||||
int test_bgc_vector3_set_values_fp64()
|
||||
{
|
||||
BgcVector3FP64 vector;
|
||||
|
||||
print_testing_name("bgc_vector3_set_values_fp64");
|
||||
|
||||
|
||||
bgc_vector3_set_values_fp64(1.0, 2.0, 3.0, &vector);
|
||||
|
||||
if (vector.x1 != 1.0 || vector.x2 != 2.0 || vector.x3 != 3.0) {
|
||||
print_testing_failed();
|
||||
return TEST_FAILED;
|
||||
}
|
||||
|
||||
bgc_vector3_set_values_fp64(-3.0, -5.0, -7.0, &vector);
|
||||
|
||||
if (vector.x1 != -3.0 || vector.x2 != -5.0 || vector.x3 != -7.0) {
|
||||
print_testing_failed();
|
||||
return TEST_FAILED;
|
||||
}
|
||||
|
||||
bgc_vector3_set_values_fp64(-2.0, 2.0, 4.0, &vector);
|
||||
|
||||
if (vector.x1 != -2.0 || vector.x2 != 2.0 || vector.x3 != 4.0) {
|
||||
print_testing_failed();
|
||||
return TEST_FAILED;
|
||||
}
|
||||
|
||||
print_testing_success();
|
||||
|
||||
return TEST_SUCCES;
|
||||
}
|
||||
8
basic-geometry-test/tests/vector3/vector3_set_values.h
Normal file
8
basic-geometry-test/tests/vector3/vector3_set_values.h
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
#ifndef _TEST_VECTOR3_SET_VALUES_H_
|
||||
#define _TEST_VECTOR3_SET_VALUES_H_
|
||||
|
||||
int test_bgc_vector3_set_values_fp32();
|
||||
|
||||
int test_bgc_vector3_set_values_fp64();
|
||||
|
||||
#endif
|
||||
99
basic-geometry-test/tests/vector3/vector3_swap.c
Normal file
99
basic-geometry-test/tests/vector3/vector3_swap.c
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
#include "./vector3_swap.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include "./../../helpers.h"
|
||||
|
||||
|
||||
|
||||
// ==================== FP32 ==================== //
|
||||
|
||||
static const int _TEST_FP32_VECTOR3_AMOUNT = 4;
|
||||
|
||||
static const BgcVector3FP32 _TEST_FP32_VECTOR3_LIST1[] = {
|
||||
{ 1.0f, 2.0f, 3.0f },
|
||||
{ -3.0f, -2.0f, -1.0f },
|
||||
{ 100.0f, -100.0f, 344.7f },
|
||||
{ -100.1f, 100.2f, -271.3f }
|
||||
};
|
||||
|
||||
static const BgcVector3FP32 _TEST_FP32_VECTOR3_LIST2[] = {
|
||||
{ 3.6f, 5.3f, -0.123f },
|
||||
{ 204.07f, -781.89f, 891.3f },
|
||||
{ -20.02f, -1.0003f, 0.9275f },
|
||||
{ 1000.0f, -0.00025f, -0.419f }
|
||||
};
|
||||
|
||||
int test_bgc_vector3_swap_fp32()
|
||||
{
|
||||
BgcVector3FP32 vector1, vector2;
|
||||
|
||||
print_testing_name("bgc_vector3_swap_fp32");
|
||||
|
||||
for (int i = 0; i < _TEST_FP32_VECTOR3_AMOUNT; i++) {
|
||||
bgc_vector3_copy_fp32(&_TEST_FP32_VECTOR3_LIST1[i], &vector1);
|
||||
bgc_vector3_copy_fp32(&_TEST_FP32_VECTOR3_LIST2[i], &vector2);
|
||||
|
||||
bgc_vector3_swap_fp32(&vector1, &vector2);
|
||||
|
||||
if (vector1.x1 != _TEST_FP32_VECTOR3_LIST2[i].x1 ||
|
||||
vector1.x2 != _TEST_FP32_VECTOR3_LIST2[i].x2 ||
|
||||
vector1.x3 != _TEST_FP32_VECTOR3_LIST2[i].x3 ||
|
||||
vector2.x1 != _TEST_FP32_VECTOR3_LIST1[i].x1 ||
|
||||
vector2.x2 != _TEST_FP32_VECTOR3_LIST1[i].x2 ||
|
||||
vector2.x3 != _TEST_FP32_VECTOR3_LIST1[i].x3) {
|
||||
print_testing_failed();
|
||||
return TEST_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
print_testing_success();
|
||||
|
||||
return TEST_SUCCES;
|
||||
}
|
||||
|
||||
// ==================== FP64 ==================== //
|
||||
|
||||
static const int _TEST_FP64_VECTOR3_AMOUNT = 4;
|
||||
|
||||
static const BgcVector3FP64 _TEST_FP64_VECTOR3_LIST1[] = {
|
||||
{ 1.0, 2.0, 3.0 },
|
||||
{ -3.0, -2.0, -1.0 },
|
||||
{ 100.0, -100.0, 344.7 },
|
||||
{ -100.1, 100.2, -271.3 }
|
||||
};
|
||||
|
||||
static const BgcVector3FP64 _TEST_FP64_VECTOR3_LIST2[] = {
|
||||
{ 3.6, 5.3, -0.123 },
|
||||
{ 204.07, -781.89, 891.3 },
|
||||
{ -20.02, -1.0003, 0.9275 },
|
||||
{ 1000.0, -0.00025, -0.419 }
|
||||
};
|
||||
|
||||
int test_bgc_vector3_swap_fp64()
|
||||
{
|
||||
BgcVector3FP64 vector1, vector2;
|
||||
|
||||
print_testing_name("bgc_vector3_swap_fp64");
|
||||
|
||||
for (int i = 0; i < _TEST_FP64_VECTOR3_AMOUNT; i++) {
|
||||
bgc_vector3_copy_fp64(&_TEST_FP64_VECTOR3_LIST1[i], &vector1);
|
||||
bgc_vector3_copy_fp64(&_TEST_FP64_VECTOR3_LIST2[i], &vector2);
|
||||
|
||||
bgc_vector3_swap_fp64(&vector1, &vector2);
|
||||
|
||||
if (vector1.x1 != _TEST_FP64_VECTOR3_LIST2[i].x1 ||
|
||||
vector1.x2 != _TEST_FP64_VECTOR3_LIST2[i].x2 ||
|
||||
vector1.x3 != _TEST_FP64_VECTOR3_LIST2[i].x3 ||
|
||||
vector2.x1 != _TEST_FP64_VECTOR3_LIST1[i].x1 ||
|
||||
vector2.x2 != _TEST_FP64_VECTOR3_LIST1[i].x2 ||
|
||||
vector2.x3 != _TEST_FP64_VECTOR3_LIST1[i].x3) {
|
||||
print_testing_failed();
|
||||
return TEST_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
print_testing_success();
|
||||
|
||||
return TEST_SUCCES;
|
||||
}
|
||||
8
basic-geometry-test/tests/vector3/vector3_swap.h
Normal file
8
basic-geometry-test/tests/vector3/vector3_swap.h
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
#ifndef _TEST_VECTOR3_SWAP_H_
|
||||
#define _TEST_VECTOR3_SWAP_H_
|
||||
|
||||
int test_bgc_vector3_swap_fp32();
|
||||
|
||||
int test_bgc_vector3_swap_fp64();
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue