Большое переименование
This commit is contained in:
parent
e354b2425c
commit
e7616ae80c
30 changed files with 1356 additions and 1348 deletions
150
test/fp32_vector2_test.c
Normal file
150
test/fp32_vector2_test.c
Normal file
|
@ -0,0 +1,150 @@
|
|||
#include "sp_vector2_test.h"
|
||||
|
||||
const int TEST_BG_FP32_VECTOR2_AMOUNT_1 = 5;
|
||||
|
||||
const BgFP32Vector2 TEST_BG_FP32_VECTOR2_COMMON_1[] = {
|
||||
{ 3.0f, 4.0f },
|
||||
{ -3.0f, -4.0f },
|
||||
{ 10000.0f, -20000.0f },
|
||||
{ 0.1f, -10.0f },
|
||||
{ -123.5f, 3.7283f }
|
||||
};
|
||||
|
||||
const BgFP32Vector2 TEST_BG_FP32_VECTOR2_COMMON_2[] = {
|
||||
{ -3.0f, -4.0f },
|
||||
{ -3.0f, -4.0f },
|
||||
{ 0.002f, -0.05f },
|
||||
{ -0.2f, 12.0f },
|
||||
{ 1.5f, -23.35f }
|
||||
};
|
||||
|
||||
// =============== Square module ================ //
|
||||
|
||||
const float BG_FP32_VECTOR2_SQUARE_MODULE_1[] = { 25.0f, 25.0f, 500000000.0f, 100.01f, 15266.150221f };
|
||||
|
||||
int test_sp_vector2_square_module()
|
||||
{
|
||||
print_test_name("BgFP32Vector2 square module");
|
||||
|
||||
float 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)) {
|
||||
print_test_failed();
|
||||
return TEST_RESULT_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
print_test_success();
|
||||
return TEST_RESULT_SUCCES;
|
||||
}
|
||||
|
||||
// =================== Module =================== //
|
||||
|
||||
const float BG_FP32_VECTOR2_MODULE_1[] = { 5.0f, 5.0f, 22360.68f, 10.0005f, 123.55626338f };
|
||||
|
||||
int test_sp_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]);
|
||||
|
||||
if (!test_sp_are_equal(square_module, BG_FP32_VECTOR2_MODULE_1[i], TEST_BG_FP32_EPSYLON)) {
|
||||
print_test_failed();
|
||||
return TEST_RESULT_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
print_test_success();
|
||||
return TEST_RESULT_SUCCES;
|
||||
}
|
||||
|
||||
// ===================== Add ==================== //
|
||||
|
||||
const BgFP32Vector2 TEST_BG_FP32_VECTOR2_COMMON_1_2_SUM[] = {
|
||||
{ 0.0f, 0.0f },
|
||||
{ -6.0f, -8.0f },
|
||||
{ 10000.002f, -20000.05f },
|
||||
{ -0.1f, 2.0f },
|
||||
{ -122.0f, -19.6217f }
|
||||
};
|
||||
|
||||
int test_sp_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);
|
||||
|
||||
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)) {
|
||||
print_test_failed();
|
||||
return TEST_RESULT_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
print_test_success();
|
||||
return TEST_RESULT_SUCCES;
|
||||
}
|
||||
|
||||
// ================== Subtract ================== //
|
||||
|
||||
const BgFP32Vector2 TEST_BG_FP32_VECTOR2_COMMON_1_2_DIFF[] = {
|
||||
{ 6.0f, 8.0f },
|
||||
{ 0.0f, 0.0f },
|
||||
{ 9999.998f, -19999.95f },
|
||||
{ 0.3f, -22.0f },
|
||||
{ -125.0f, 27.0783f }
|
||||
};
|
||||
|
||||
int test_sp_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);
|
||||
|
||||
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)) {
|
||||
print_test_failed();
|
||||
return TEST_RESULT_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
print_test_success();
|
||||
return TEST_RESULT_SUCCES;
|
||||
}
|
||||
|
||||
// ==================== 1234 ==================== //
|
||||
|
||||
int test_sp_vector2()
|
||||
{
|
||||
print_test_section("BgFP32Vector2");
|
||||
|
||||
if (test_sp_vector2_square_module() != TEST_RESULT_SUCCES) {
|
||||
return TEST_RESULT_FAILED;
|
||||
}
|
||||
|
||||
if (test_sp_vector2_module() != TEST_RESULT_SUCCES) {
|
||||
return TEST_RESULT_FAILED;
|
||||
}
|
||||
|
||||
if (test_sp_vector2_add() != TEST_RESULT_SUCCES) {
|
||||
return TEST_RESULT_FAILED;
|
||||
}
|
||||
|
||||
if (test_sp_vector2_subtract() != TEST_RESULT_SUCCES) {
|
||||
return TEST_RESULT_FAILED;
|
||||
}
|
||||
|
||||
return TEST_RESULT_SUCCES;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue