Добавлено несколько модульных тестов для Vector2, Vector3, Versor

This commit is contained in:
Andrey Pokidov 2025-02-09 03:18:08 +07:00
parent ab4a589e21
commit 86426c9bd5
30 changed files with 1148 additions and 3 deletions

View file

@ -0,0 +1,67 @@
#include "./vector2_copy.h"
#include <math.h>
#include "./../../helpers.h"
// ==================== FP32 ==================== //
static const int _TEST_FP32_VECTOR2_AMOUNT = 4;
static const BgcVector2FP32 _TEST_FP32_VECTOR2_LIST[] = {
{ 1.0f, 2.0f },
{ -2.0f, -1.0f },
{ 100.0f, -100.0f },
{ -100.0f, 100.0f }
};
int test_bgc_vector2_copy_fp32()
{
BgcVector2FP32 vector;
print_testing_name("bgc_vector2_copy_fp32");
for (int i = 0; i < _TEST_FP32_VECTOR2_AMOUNT; i++) {
bgc_vector2_copy_fp32(&_TEST_FP32_VECTOR2_LIST[i], &vector);
if (vector.x1 != _TEST_FP32_VECTOR2_LIST[i].x1 || vector.x2 != _TEST_FP32_VECTOR2_LIST[i].x2) {
print_testing_failed();
return TEST_FAILED;
}
}
print_testing_success();
return TEST_SUCCES;
}
// ==================== FP64 ==================== //
static const int _TEST_FP64_VECTOR2_AMOUNT = 4;
static const BgcVector2FP64 _TEST_FP64_VECTOR2_LIST[] = {
{ 1.0, 2.0 },
{ -2.0, -1.0 },
{ 100.0, -100.0 },
{ -100.0, 100.0 }
};
int test_bgc_vector2_copy_fp64()
{
BgcVector2FP64 vector;
print_testing_name("bgc_vector2_copy_fp64");
for (int i = 0; i < _TEST_FP64_VECTOR2_AMOUNT; i++) {
bgc_vector2_copy_fp64(&_TEST_FP64_VECTOR2_LIST[i], &vector);
if (vector.x1 != _TEST_FP64_VECTOR2_LIST[i].x1 || vector.x2 != _TEST_FP64_VECTOR2_LIST[i].x2) {
print_testing_failed();
return TEST_FAILED;
}
}
print_testing_success();
return TEST_SUCCES;
}

View file

@ -0,0 +1,8 @@
#ifndef _TEST_VECTOR2_COPY_H_
#define _TEST_VECTOR2_COPY_H_
int test_bgc_vector2_copy_fp32();
int test_bgc_vector2_copy_fp64();
#endif

View file

Internal server error - Personal Git Server: Beyond coding. We Forge.

500

Internal server error

Forgejo version: 11.0.1+gitea-1.22.0

@ -0,0 +1,39 @@
#include "./vector2_reset.h"
#include "./../../helpers.h"
int test_bgc_vector2_reset_fp32()
{
BgcVector2FP32 vector;
print_testing_name("bgc_vector2_reset_fp32");
bgc_vector2_reset_fp32(&vector);
if (vector.x1 != 0.0f || vector.x2 != 0.0f) {
print_testing_failed();
return TEST_FAILED;
}
print_testing_success();
return TEST_SUCCES;
}
int test_bgc_vector2_reset_fp64()
{
BgcVector2FP64 vector;
print_testing_name("bgc_vector2_reset_fp64");
bgc_vector2_reset_fp64(&vector);