Небольшие изменения в библиотеке геометрии и тестах

This commit is contained in:
Andrey Pokidov 2024-11-21 23:42:19 +07:00
parent 23fcdc2c28
commit da61a9bf7c
5 changed files with 44 additions and 42 deletions

View file

@ -1,4 +1,4 @@
#include "sp_vector2_test.h"
#include "fp32_vector2_test.h"
const int TEST_BG_FP32_VECTOR2_AMOUNT_1 = 5;
@ -22,7 +22,7 @@ const BgFP32Vector2 TEST_BG_FP32_VECTOR2_COMMON_2[] = {
const float BG_FP32_VECTOR2_SQUARE_MODULE_1[] = { 25.0f, 25.0f, 500000000.0f, 100.01f, 15266.150221f };
int test_sp_vector2_square_module()
int test_bg_fp32_vector2_square_module()
{
print_test_name("BgFP32Vector2 square module");
@ -31,7 +31,7 @@ int test_sp_vector2_square_module()
for (int i = 0; i < TEST_BG_FP32_VECTOR2_AMOUNT_1; i++) {
square_module = bg_fp32_vector2_get_square_module(&TEST_BG_FP32_VECTOR2_COMMON_1[i]);
if (!test_sp_are_equal(square_module, BG_FP32_VECTOR2_SQUARE_MODULE_1[i], TEST_BG_FP32_TWO_EPSYLON)) {
if (!test_bg_fp32_are_equal(square_module, BG_FP32_VECTOR2_SQUARE_MODULE_1[i], TEST_BG_FP32_TWO_EPSYLON)) {
print_test_failed();
return TEST_RESULT_FAILED;
}
@ -45,16 +45,16 @@ int test_sp_vector2_square_module()
const float BG_FP32_VECTOR2_MODULE_1[] = { 5.0f, 5.0f, 22360.68f, 10.0005f, 123.55626338f };
int test_sp_vector2_module()
int test_bg_fp32_vector2_module()
{
print_test_name("BgFP32Vector2 module");
float square_module;
for (int i = 0; i < TEST_BG_FP32_VECTOR2_AMOUNT_1; i++) {
square_module = sp_vector2_get_module(&TEST_BG_FP32_VECTOR2_COMMON_1[i]);
square_module = bg_fp32_vector2_get_module(&TEST_BG_FP32_VECTOR2_COMMON_1[i]);
if (!test_sp_are_equal(square_module, BG_FP32_VECTOR2_MODULE_1[i], TEST_BG_FP32_EPSYLON)) {
if (!test_bg_fp32_are_equal(square_module, BG_FP32_VECTOR2_MODULE_1[i], TEST_BG_FP32_EPSYLON)) {
print_test_failed();
return TEST_RESULT_FAILED;
}
@ -74,17 +74,17 @@ const BgFP32Vector2 TEST_BG_FP32_VECTOR2_COMMON_1_2_SUM[] = {
{ -122.0f, -19.6217f }
};
int test_sp_vector2_add()
int test_bg_fp32_vector2_add()
{
print_test_name("BgFP32Vector2 add");
BgFP32Vector2 vector;
for (int i = 0; i < TEST_BG_FP32_VECTOR2_AMOUNT_1; i++) {
sp_vector2_add(&TEST_BG_FP32_VECTOR2_COMMON_1[i], &TEST_BG_FP32_VECTOR2_COMMON_2[i], &vector);
bg_fp32_vector2_add(&TEST_BG_FP32_VECTOR2_COMMON_1[i], &TEST_BG_FP32_VECTOR2_COMMON_2[i], &vector);
if (!test_sp_are_equal(vector.x1, TEST_BG_FP32_VECTOR2_COMMON_1_2_SUM[i].x1, TEST_BG_FP32_EPSYLON) ||
!test_sp_are_equal(vector.x2, TEST_BG_FP32_VECTOR2_COMMON_1_2_SUM[i].x2, TEST_BG_FP32_EPSYLON)) {
if (!test_bg_fp32_are_equal(vector.x1, TEST_BG_FP32_VECTOR2_COMMON_1_2_SUM[i].x1, TEST_BG_FP32_EPSYLON) ||
!test_bg_fp32_are_equal(vector.x2, TEST_BG_FP32_VECTOR2_COMMON_1_2_SUM[i].x2, TEST_BG_FP32_EPSYLON)) {
print_test_failed();
return TEST_RESULT_FAILED;
}
@ -104,17 +104,17 @@ const BgFP32Vector2 TEST_BG_FP32_VECTOR2_COMMON_1_2_DIFF[] = {
{ -125.0f, 27.0783f }
};
int test_sp_vector2_subtract()
int test_bg_fp32_vector2_subtract()
{
print_test_name("BgFP32Vector2 subtract");
BgFP32Vector2 vector;
for (int i = 0; i < TEST_BG_FP32_VECTOR2_AMOUNT_1; i++) {
sp_vector2_subtract(&TEST_BG_FP32_VECTOR2_COMMON_1[i], &TEST_BG_FP32_VECTOR2_COMMON_2[i], &vector);
bg_fp32_vector2_subtract(&TEST_BG_FP32_VECTOR2_COMMON_1[i], &TEST_BG_FP32_VECTOR2_COMMON_2[i], &vector);
if (!test_sp_are_equal(vector.x1, TEST_BG_FP32_VECTOR2_COMMON_1_2_DIFF[i].x1, TEST_BG_FP32_EPSYLON) ||
!test_sp_are_equal(vector.x2, TEST_BG_FP32_VECTOR2_COMMON_1_2_DIFF[i].x2, TEST_BG_FP32_EPSYLON)) {
if (!test_bg_fp32_are_equal(vector.x1, TEST_BG_FP32_VECTOR2_COMMON_1_2_DIFF[i].x1, TEST_BG_FP32_EPSYLON) ||
!test_bg_fp32_are_equal(vector.x2, TEST_BG_FP32_VECTOR2_COMMON_1_2_DIFF[i].x2, TEST_BG_FP32_EPSYLON)) {
print_test_failed();
return TEST_RESULT_FAILED;
}
@ -126,23 +126,23 @@ int test_sp_vector2_subtract()
// ==================== 1234 ==================== //
int test_sp_vector2()
int test_bg_fp32_vector2()
{
print_test_section("BgFP32Vector2");
if (test_sp_vector2_square_module() != TEST_RESULT_SUCCES) {
if (test_bg_fp32_vector2_square_module() != TEST_RESULT_SUCCES) {
return TEST_RESULT_FAILED;
}
if (test_sp_vector2_module() != TEST_RESULT_SUCCES) {
if (test_bg_fp32_vector2_module() != TEST_RESULT_SUCCES) {
return TEST_RESULT_FAILED;
}
if (test_sp_vector2_add() != TEST_RESULT_SUCCES) {
if (test_bg_fp32_vector2_add() != TEST_RESULT_SUCCES) {
return TEST_RESULT_FAILED;
}
if (test_sp_vector2_subtract() != TEST_RESULT_SUCCES) {
if (test_bg_fp32_vector2_subtract() != TEST_RESULT_SUCCES) {
return TEST_RESULT_FAILED;
}