Небольшие исправления в модульных тестах

This commit is contained in:
Andrey Pokidov 2025-02-12 12:35:10 +07:00
parent 2d8240265c
commit fffe2be43b
8 changed files with 132 additions and 92 deletions

View file

@ -77,6 +77,10 @@
<Option compilerVar="CC" /> <Option compilerVar="CC" />
</Unit> </Unit>
<Unit filename="tests/quaternion/quaternion_set_values.h" /> <Unit filename="tests/quaternion/quaternion_set_values.h" />
<Unit filename="tests/quaternion/quaternion_square_modulus.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="tests/quaternion/quaternion_square_modulus.h" />
<Unit filename="tests/quaternion/quaternion_swap.c"> <Unit filename="tests/quaternion/quaternion_swap.c">
<Option compilerVar="CC" /> <Option compilerVar="CC" />
</Unit> </Unit>

View file

@ -9,28 +9,28 @@ static const int _TEST_FP32_NONZERO_QUATERNION_AMOUNT = 11;
static const BgcQuaternionFP32 _TEST_FP32_ZERO_QUATERNION_LIST[] = { static const BgcQuaternionFP32 _TEST_FP32_ZERO_QUATERNION_LIST[] = {
{ 0.0f, 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f, 0.0f },
{ BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f }, { 0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f },
{ -BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f }, { -0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f },
{ 0.0f, BGC_EPSYLON_FP32, 0.0f, 0.0f }, { 0.0f, 0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f },
{ 0.0f, -BGC_EPSYLON_FP32, 0.0f, 0.0f }, { 0.0f, -0.75f * BGC_EPSYLON_FP32, 0.0f, 0.0f },
{ 0.0f, 0.0f, BGC_EPSYLON_FP32, 0.0f }, { 0.0f, 0.0f, 0.75f * BGC_EPSYLON_FP32, 0.0f },
{ 0.0f, 0.0f, -BGC_EPSYLON_FP32, 0.0f }, { 0.0f, 0.0f, -0.75f * BGC_EPSYLON_FP32, 0.0f },
{ 0.0f, 0.0f, 0.0f, BGC_EPSYLON_FP32 }, { 0.0f, 0.0f, 0.0f, 0.75f * BGC_EPSYLON_FP32 },
{ 0.0f, 0.0f, 0.0f, -BGC_EPSYLON_FP32 } { 0.0f, 0.0f, 0.0f, -0.75f * BGC_EPSYLON_FP32 }
}; };
static const BgcQuaternionFP32 _TEST_FP32_NONZERO_QUATERION_LIST[] = { static const BgcQuaternionFP32 _TEST_FP32_NONZERO_QUATERION_LIST[] = {
{ 0.0f, 1.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f, 0.0f },
{ 1.5f * BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f }, { 1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f },
{ -1.5f * BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f }, { -1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f, 0.0f },
{ 0.0f, 1.5f * BGC_EPSYLON_FP32, 0.0f, 0.0f }, { 0.0f, 1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f },
{ 0.0f, -1.5f * BGC_EPSYLON_FP32, 0.0f, 0.0f }, { 0.0f, -1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f },
{ 0.0f, 0.0f, 1.5f * BGC_EPSYLON_FP32, 0.0f }, { 0.0f, 0.0f, 1.25f * BGC_EPSYLON_FP32, 0.0f },
{ 0.0f, 0.0f, -1.5f * BGC_EPSYLON_FP32, 0.0f }, { 0.0f, 0.0f, -1.25f * BGC_EPSYLON_FP32, 0.0f },
{ 0.0f, 0.0f, 0.0f, 1.5f * BGC_EPSYLON_FP32 }, { 0.0f, 0.0f, 0.0f, 1.25f * BGC_EPSYLON_FP32 },
{ 0.0f, 0.0f, 0.0f, -1.5f * BGC_EPSYLON_FP32 }, { 0.0f, 0.0f, 0.0f, -1.25f * BGC_EPSYLON_FP32 },
{ BGC_EPSYLON_FP32, BGC_EPSYLON_FP32, 0.0f, 0.0f }, { 1.25f * BGC_EPSYLON_FP32, 1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f },
{ -BGC_EPSYLON_FP32, -BGC_EPSYLON_FP32, 0.0f, 0.0f } { -1.25f * BGC_EPSYLON_FP32, -1.25f * BGC_EPSYLON_FP32, 0.0f, 0.0f }
}; };
int test_quaternion_is_zero_fp32() int test_quaternion_is_zero_fp32()
@ -65,28 +65,28 @@ static const int _TEST_FP64_NONZERO_QUATERNION_AMOUNT = 11;
static const BgcQuaternionFP64 _TEST_FP64_ZERO_QUATERNION_LIST[] = { static const BgcQuaternionFP64 _TEST_FP64_ZERO_QUATERNION_LIST[] = {
{ 0.0, 0.0, 0.0, 0.0 }, { 0.0, 0.0, 0.0, 0.0 },
{ BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 }, { 0.75 * BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 },
{ -BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 }, { -0.75 * BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 },
{ 0.0, BGC_EPSYLON_FP64, 0.0, 0.0 }, { 0.0, 0.75 * BGC_EPSYLON_FP64, 0.0, 0.0 },
{ 0.0, -BGC_EPSYLON_FP64, 0.0, 0.0 }, { 0.0, -0.75 * BGC_EPSYLON_FP64, 0.0, 0.0 },
{ 0.0, 0.0, BGC_EPSYLON_FP64, 0.0 }, { 0.0, 0.0, 0.75 * BGC_EPSYLON_FP64, 0.0 },
{ 0.0, 0.0, -BGC_EPSYLON_FP64, 0.0 }, { 0.0, 0.0, -0.75 * BGC_EPSYLON_FP64, 0.0 },
{ 0.0, 0.0, 0.0, BGC_EPSYLON_FP64 }, { 0.0, 0.0, 0.0, 0.75 * BGC_EPSYLON_FP64 },
{ 0.0, 0.0, 0.0, -BGC_EPSYLON_FP64 } { 0.0, 0.0, 0.0, -0.75 * BGC_EPSYLON_FP64 }
}; };
static const BgcQuaternionFP64 _TEST_FP64_NONZERO_QUATERION_LIST[] = { static const BgcQuaternionFP64 _TEST_FP64_NONZERO_QUATERION_LIST[] = {
{ 0.0, 1.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0, 0.0 },
{ 1.5 * BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 }, { 1.25 * BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 },
{ -1.5 * BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 }, { -1.25 * BGC_EPSYLON_FP64, 0.0, 0.0, 0.0 },
{ 0.0, 1.5 * BGC_EPSYLON_FP64, 0.0, 0.0 }, { 0.0, 1.25 * BGC_EPSYLON_FP64, 0.0, 0.0 },
{ 0.0, -1.5 * BGC_EPSYLON_FP64, 0.0, 0.0 }, { 0.0, -1.25 * BGC_EPSYLON_FP64, 0.0, 0.0 },
{ 0.0, 0.0, 1.5 * BGC_EPSYLON_FP64, 0.0 }, { 0.0, 0.0, 1.25 * BGC_EPSYLON_FP64, 0.0 },
{ 0.0, 0.0, -1.5 * BGC_EPSYLON_FP64, 0.0 }, { 0.0, 0.0, -1.25 * BGC_EPSYLON_FP64, 0.0 },
{ 0.0, 0.0, 0.0, 1.5 * BGC_EPSYLON_FP64 }, { 0.0, 0.0, 0.0, 1.25 * BGC_EPSYLON_FP64 },
{ 0.0, 0.0, 0.0, -1.5 * BGC_EPSYLON_FP64 }, { 0.0, 0.0, 0.0, -1.25 * BGC_EPSYLON_FP64 },
{ BGC_EPSYLON_FP64, BGC_EPSYLON_FP64, 0.0, 0.0 }, { 1.25 * BGC_EPSYLON_FP64, 1.25 * BGC_EPSYLON_FP64, 0.0, 0.0 },
{ -BGC_EPSYLON_FP64, -BGC_EPSYLON_FP64, 0.0, 0.0 } { -1.25 * BGC_EPSYLON_FP64, -1.25 * BGC_EPSYLON_FP64, 0.0, 0.0 }
}; };
int test_quaternion_is_zero_fp64() int test_quaternion_is_zero_fp64()

View file

@ -0,0 +1,34 @@
#include "./quaternion_square_modulus.h"
#include "./../../helpers.h"
int test_quaternion_square_modulus_fp32()
{
print_testing_name("bgc_quaternion_is_zero_fp32");
print_testing_success();
return TEST_SUCCES;
}
int test_quaternion_square_modulus_fp64()
{
print_testing_name("bgc_quaternion_is_zero_fp64");
print_testing_success();
return TEST_SUCCES;
}
int test_quaternion_square_modulus()
{
if (test_quaternion_square_modulus_fp32() != TEST_SUCCES) {
return TEST_FAILED;
}
if (test_quaternion_square_modulus_fp64() != TEST_SUCCES) {
return TEST_FAILED;
}
return TEST_SUCCES;
}

View file

@ -0,0 +1,10 @@
#ifndef _TEST_QUATERNION_SQUARE_MODULUS_H_
#define _TEST_QUATERNION_SQUARE_MODULUS_H_
int test_quaternion_square_modulus_fp32();
int test_quaternion_square_modulus_fp64();
int test_quaternion_square_modulus();
#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

@ -9,15 +9,15 @@ static const int _TEST_FP32_NONUNIT_NUMBERS_AMOUNT = 4;
static const float _TEST_FP32_UNIT_NUMBERS[] = { static const float _TEST_FP32_UNIT_NUMBERS[] = {
1.0f, 1.0f,
1.0f + BGC_EPSYLON_FP32, 1.0f + 0.75f * BGC_EPSYLON_FP32,
1.0f - BGC_EPSYLON_FP32 1.0f - 0.75f * BGC_EPSYLON_FP32
}; };
static const float _TEST_FP32_NONUNIT_NUMBERS[] = { static const float _TEST_FP32_NONUNIT_NUMBERS[] = {
0.0f, 0.0f,
-1.0f, -1.0f,
1.0f + 2.0f * BGC_EPSYLON_FP32, 1.0f + 1.25f * BGC_EPSYLON_FP32,
1.0f - 2.0f * BGC_EPSYLON_FP32 1.0f - 1.25f * BGC_EPSYLON_FP32
}; };
int test_is_unit_fp32() int test_is_unit_fp32()
@ -52,15 +52,15 @@ static const int _TEST_FP64_NONUNIT_NUMBERS_AMOUNT = 4;
static const double _TEST_FP64_UNIT_NUMBERS[] = { static const double _TEST_FP64_UNIT_NUMBERS[] = {
1.0, 1.0,
1.0 + BGC_EPSYLON_FP64, 1.0 + 0.75 * BGC_EPSYLON_FP64,
1.0 - BGC_EPSYLON_FP64 1.0 - 0.75 * BGC_EPSYLON_FP64
}; };
static const double _TEST_FP64_NONUNIT_NUMBERS[] = { static const double _TEST_FP64_NONUNIT_NUMBERS[] = {
0.0, 0.0,
-1.0, -1.0,
1.0 + 2.0 * BGC_EPSYLON_FP64, 1.0 + 1.25 * BGC_EPSYLON_FP64,
1.0 - 2.0 * BGC_EPSYLON_FP64 1.0 - 1.25 * BGC_EPSYLON_FP64
}; };
int test_is_unit_fp64() int test_is_unit_fp64()
@ -90,22 +90,20 @@ int test_is_unit_fp64()
// ================ Square FP32 ================= // // ================ Square FP32 ================= //
static const int _TEST_FP32_DATA_SQUARE_UNIT_AMOUNT = 5; static const int _TEST_FP32_DATA_SQUARE_UNIT_AMOUNT = 3;
static const int _TEST_FP32_DATA_SQUARE_NONUNIT_AMOUNT = 4; static const int _TEST_FP32_DATA_SQUARE_NONUNIT_AMOUNT = 4;
static const float _TEST_FP32_DATA_SQUARE_UNIT[] = { static const float _TEST_FP32_DATA_SQUARE_UNIT[] = {
1.0f, 1.0f,
1.0f + BGC_EPSYLON_FP32, 1.0f + 1.75f * BGC_EPSYLON_FP32,
1.0f - BGC_EPSYLON_FP32, 1.0f - 1.75f * BGC_EPSYLON_FP32
1.0f + 2.0f * BGC_EPSYLON_FP32,
1.0f - 2.0f * BGC_EPSYLON_FP32
}; };
static const float _TEST_FP32_DATA_SQUARE_NONUNIT[] = { static const float _TEST_FP32_DATA_SQUARE_NONUNIT[] = {
0.0f, 0.0f,
-1.0f, -1.0f,