Переименование типов в соответствии со стилем POSIX, отказ от префикса bg_
This commit is contained in:
parent
d2a25823a5
commit
605afabd94
25 changed files with 1109 additions and 1035 deletions
|
@ -1,8 +1,8 @@
|
|||
#include "fp32_vector2_test.h"
|
||||
|
||||
const int TEST_BG_FP32_VECTOR2_AMOUNT_1 = 5;
|
||||
const int TEST_FP32_VECTOR2_AMOUNT_1 = 5;
|
||||
|
||||
const BgFP32Vector2 TEST_BG_FP32_VECTOR2_COMMON_1[] = {
|
||||
const fp32_vector2_t TEST_FP32_VECTOR2_COMMON_1[] = {
|
||||
{ 3.0f, 4.0f },
|
||||
{ -3.0f, -4.0f },
|
||||
{ 10000.0f, -20000.0f },
|
||||
|
@ -10,7 +10,7 @@ const BgFP32Vector2 TEST_BG_FP32_VECTOR2_COMMON_1[] = {
|
|||
{ -123.5f, 3.7283f }
|
||||
};
|
||||
|
||||
const BgFP32Vector2 TEST_BG_FP32_VECTOR2_COMMON_2[] = {
|
||||
const fp32_vector2_t TEST_FP32_VECTOR2_COMMON_2[] = {
|
||||
{ -3.0f, -4.0f },
|
||||
{ -3.0f, -4.0f },
|
||||
{ 0.002f, -0.05f },
|
||||
|
@ -20,18 +20,18 @@ const BgFP32Vector2 TEST_BG_FP32_VECTOR2_COMMON_2[] = {
|
|||
|
||||
// =============== Square modulus =============== //
|
||||
|
||||
const float BG_FP32_VECTOR2_SQUARE_MODULUS_1[] = { 25.0f, 25.0f, 500000000.0f, 100.01f, 15266.150221f };
|
||||
const float FP32_VECTOR2_SQUARE_MODULUS_1[] = { 25.0f, 25.0f, 500000000.0f, 100.01f, 15266.150221f };
|
||||
|
||||
int test_bg_fp32_vector2_square_modulus()
|
||||
int test_fp32_vector2_square_modulus()
|
||||
{
|
||||
print_test_name("BgFP32Vector2 square modulus");
|
||||
print_test_name("fp32_vector2_t square modulus");
|
||||
|
||||
float square_modulus;
|
||||
|
||||
for (int i = 0; i < TEST_BG_FP32_VECTOR2_AMOUNT_1; i++) {
|
||||
square_modulus = bg_fp32_vector2_get_square_modulus(&TEST_BG_FP32_VECTOR2_COMMON_1[i]);
|
||||
for (int i = 0; i < TEST_FP32_VECTOR2_AMOUNT_1; i++) {
|
||||
square_modulus = fp32_vector2_get_square_modulus(&TEST_FP32_VECTOR2_COMMON_1[i]);
|
||||
|
||||
if (!test_bg_fp32_are_equal(square_modulus, BG_FP32_VECTOR2_SQUARE_MODULUS_1[i], TEST_BG_FP32_TWO_EPSYLON)) {
|
||||
if (!test_fp32_are_equal(square_modulus, FP32_VECTOR2_SQUARE_MODULUS_1[i], TEST_FP32_TWO_EPSYLON)) {
|
||||
print_test_failed();
|
||||
return TEST_RESULT_FAILED;
|
||||
}
|
||||
|
@ -43,18 +43,18 @@ int test_bg_fp32_vector2_square_modulus()
|
|||
|
||||
// =================== Module =================== //
|
||||
|
||||
const float BG_FP32_VECTOR2_MODULUS_1[] = { 5.0f, 5.0f, 22360.68f, 10.0005f, 123.55626338f };
|
||||
const float FP32_VECTOR2_MODULUS_1[] = { 5.0f, 5.0f, 22360.68f, 10.0005f, 123.55626338f };
|
||||
|
||||
int test_bg_fp32_vector2_modulus()
|
||||
int test_fp32_vector2_modulus()
|
||||
{
|
||||
print_test_name("BgFP32Vector2 modulus");
|
||||
print_test_name("fp32_vector2_t modulus");
|
||||
|
||||
float square_modulus;
|
||||
|
||||
for (int i = 0; i < TEST_BG_FP32_VECTOR2_AMOUNT_1; i++) {
|
||||
square_modulus = bg_fp32_vector2_get_modulus(&TEST_BG_FP32_VECTOR2_COMMON_1[i]);
|
||||
for (int i = 0; i < TEST_FP32_VECTOR2_AMOUNT_1; i++) {
|
||||
square_modulus = fp32_vector2_get_modulus(&TEST_FP32_VECTOR2_COMMON_1[i]);
|
||||
|
||||
if (!test_bg_fp32_are_equal(square_modulus, BG_FP32_VECTOR2_MODULUS_1[i], TEST_BG_FP32_EPSYLON)) {
|
||||
if (!test_fp32_are_equal(square_modulus, FP32_VECTOR2_MODULUS_1[i], TEST_FP32_EPSYLON)) {
|
||||
print_test_failed();
|
||||
return TEST_RESULT_FAILED;
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ int test_bg_fp32_vector2_modulus()
|
|||
|
||||
// ===================== Add ==================== //
|
||||
|
||||
const BgFP32Vector2 TEST_BG_FP32_VECTOR2_COMMON_1_2_SUM[] = {
|
||||
const fp32_vector2_t TEST_FP32_VECTOR2_COMMON_1_2_SUM[] = {
|
||||
{ 0.0f, 0.0f },
|
||||
{ -6.0f, -8.0f },
|
||||
{ 10000.002f, -20000.05f },
|
||||
|
@ -74,17 +74,17 @@ const BgFP32Vector2 TEST_BG_FP32_VECTOR2_COMMON_1_2_SUM[] = {
|
|||
{ -122.0f, -19.6217f }
|
||||
};
|
||||
|
||||
int test_bg_fp32_vector2_add()
|
||||
int test_fp32_vector2_add()
|
||||
{
|
||||
print_test_name("BgFP32Vector2 add");
|
||||
print_test_name("fp32_vector2_t add");
|
||||
|
||||
BgFP32Vector2 vector;
|
||||
fp32_vector2_t vector;
|
||||
|
||||
for (int i = 0; i < TEST_BG_FP32_VECTOR2_AMOUNT_1; i++) {
|
||||
bg_fp32_vector2_add(&TEST_BG_FP32_VECTOR2_COMMON_1[i], &TEST_BG_FP32_VECTOR2_COMMON_2[i], &vector);
|
||||
for (int i = 0; i < TEST_FP32_VECTOR2_AMOUNT_1; i++) {
|
||||
fp32_vector2_add(&TEST_FP32_VECTOR2_COMMON_1[i], &TEST_FP32_VECTOR2_COMMON_2[i], &vector);
|
||||
|
||||
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)) {
|
||||
if (!test_fp32_are_equal(vector.x1, TEST_FP32_VECTOR2_COMMON_1_2_SUM[i].x1, TEST_FP32_EPSYLON) ||
|
||||
!test_fp32_are_equal(vector.x2, TEST_FP32_VECTOR2_COMMON_1_2_SUM[i].x2, TEST_FP32_EPSYLON)) {
|
||||
print_test_failed();
|
||||
return TEST_RESULT_FAILED;
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ int test_bg_fp32_vector2_add()
|
|||
|
||||
// ================== Subtract ================== //
|
||||
|
||||
const BgFP32Vector2 TEST_BG_FP32_VECTOR2_COMMON_1_2_DIFF[] = {
|
||||
const fp32_vector2_t TEST_FP32_VECTOR2_COMMON_1_2_DIFF[] = {
|
||||
{ 6.0f, 8.0f },
|
||||
{ 0.0f, 0.0f },
|
||||
{ 9999.998f, -19999.95f },
|
||||
|
@ -104,17 +104,17 @@ const BgFP32Vector2 TEST_BG_FP32_VECTOR2_COMMON_1_2_DIFF[] = {
|
|||
{ -125.0f, 27.0783f }
|
||||
};
|
||||
|
||||
int test_bg_fp32_vector2_subtract()
|
||||
int test_fp32_vector2_subtract()
|
||||
{
|
||||
print_test_name("BgFP32Vector2 subtract");
|
||||
print_test_name("fp32_vector2_t subtract");
|
||||
|
||||
BgFP32Vector2 vector;
|
||||
fp32_vector2_t vector;
|
||||
|
||||
for (int i = 0; i < TEST_BG_FP32_VECTOR2_AMOUNT_1; i++) {
|
||||
bg_fp32_vector2_subtract(&TEST_BG_FP32_VECTOR2_COMMON_1[i], &TEST_BG_FP32_VECTOR2_COMMON_2[i], &vector);
|
||||
for (int i = 0; i < TEST_FP32_VECTOR2_AMOUNT_1; i++) {
|
||||
fp32_vector2_subtract(&TEST_FP32_VECTOR2_COMMON_1[i], &TEST_FP32_VECTOR2_COMMON_2[i], &vector);
|
||||
|
||||
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)) {
|
||||
if (!test_fp32_are_equal(vector.x1, TEST_FP32_VECTOR2_COMMON_1_2_DIFF[i].x1, TEST_FP32_EPSYLON) ||
|
||||
!test_fp32_are_equal(vector.x2, TEST_FP32_VECTOR2_COMMON_1_2_DIFF[i].x2, TEST_FP32_EPSYLON)) {
|
||||
print_test_failed();
|
||||
return TEST_RESULT_FAILED;
|
||||
}
|
||||
|
@ -126,23 +126,23 @@ int test_bg_fp32_vector2_subtract()
|
|||
|
||||
// ==================== 1234 ==================== //
|
||||
|
||||
int test_bg_fp32_vector2()
|
||||
int test_fp32_vector2()
|
||||
{
|
||||
print_test_section("BgFP32Vector2");
|
||||
print_test_section("fp32_vector2_t");
|
||||
|
||||
if (test_bg_fp32_vector2_square_modulus() != TEST_RESULT_SUCCES) {
|
||||
if (test_fp32_vector2_square_modulus() != TEST_RESULT_SUCCES) {
|
||||
return TEST_RESULT_FAILED;
|
||||
}
|
||||
|
||||
if (test_bg_fp32_vector2_modulus() != TEST_RESULT_SUCCES) {
|
||||
if (test_fp32_vector2_modulus() != TEST_RESULT_SUCCES) {
|
||||
return TEST_RESULT_FAILED;
|
||||
}
|
||||
|
||||
if (test_bg_fp32_vector2_add() != TEST_RESULT_SUCCES) {
|
||||
if (test_fp32_vector2_add() != TEST_RESULT_SUCCES) {
|
||||
return TEST_RESULT_FAILED;
|
||||
}
|
||||
|
||||
if (test_bg_fp32_vector2_subtract() != TEST_RESULT_SUCCES) {
|
||||
if (test_fp32_vector2_subtract() != TEST_RESULT_SUCCES) {
|
||||
return TEST_RESULT_FAILED;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,14 +3,14 @@
|
|||
|
||||
#include "geometry_test.h"
|
||||
|
||||
int test_bg_fp32_vector2();
|
||||
int test_fp32_vector2();
|
||||
|
||||
int test_bg_fp32_vector2_square_modulus();
|
||||
int test_fp32_vector2_square_modulus();
|
||||
|
||||
int test_bg_fp32_vector2_modulus();
|
||||
int test_fp32_vector2_modulus();
|
||||
|
||||
int test_bg_fp32_vector2_add();
|
||||
int test_fp32_vector2_add();
|
||||
|
||||
int test_bg_fp32_vector2_subtract();
|
||||
int test_fp32_vector2_subtract();
|
||||
|
||||
#endif
|
||||
|
|
|
@ -6,13 +6,13 @@
|
|||
#define TEST_RESULT_SUCCES 0
|
||||
#define TEST_RESULT_FAILED 100
|
||||
|
||||
#define TEST_BG_FP32_EPSYLON 1E-6f
|
||||
#define TEST_BG_FP32_TWO_EPSYLON 2E-6f
|
||||
#define TEST_BG_FP32_SQUARE_EPSYLON 1E-12f
|
||||
#define TEST_FP32_EPSYLON 1E-6f
|
||||
#define TEST_FP32_TWO_EPSYLON 2E-6f
|
||||
#define TEST_FP32_SQUARE_EPSYLON 1E-12f
|
||||
|
||||
#define TEST_BG_FP64_EPSYLON 1E-13f
|
||||
#define TEST_BG_FP64_TWO_EPSYLON 2E-13f
|
||||
#define TEST_BG_FP64_SQUARE_EPSYLON 1E-26f
|
||||
#define TEST_FP64_EPSYLON 1E-13f
|
||||
#define TEST_FP64_TWO_EPSYLON 2E-13f
|
||||
#define TEST_FP64_SQUARE_EPSYLON 1E-26f
|
||||
|
||||
void print_test_section(const char * name);
|
||||
|
||||
|
@ -22,7 +22,7 @@ void print_test_success();
|
|||
|
||||
void print_test_failed();
|
||||
|
||||
inline int test_bg_fp32_are_equal(const float value1, const float value2, const float epsylon)
|
||||
inline int test_fp32_are_equal(const float value1, const float value2, const float epsylon)
|
||||
{
|
||||
if (-1.0f <= value1 && value1 <= 1.0f) {
|
||||
const float difference = value1 - value2;
|
||||
|
@ -36,7 +36,7 @@ inline int test_bg_fp32_are_equal(const float value1, const float value2, const
|
|||
return value1 * (1.0f + epsylon) <= value2 && value2 * (1.0f + epsylon) <= value1;
|
||||
}
|
||||
|
||||
inline int test_bg_fp64_are_equal(const double value1, const double value2, const double epsylon)
|
||||
inline int test_fp64_are_equal(const double value1, const double value2, const double epsylon)
|
||||
{
|
||||
if (-1.0 <= value1 && value1 <= 1.0) {
|
||||
const double difference = value1 - value2;
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
int main()
|
||||
{
|
||||
if (test_bg_fp32_vector2() == TEST_RESULT_FAILED) {
|
||||
if (test_fp32_vector2() == TEST_RESULT_FAILED) {
|
||||
return PROGRAM_RESULT_FAILED;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue