Добавленные модульные тесты для модулей двумерных и трёхмерных векторов и кватернионов

This commit is contained in:
Andrey Pokidov 2025-02-15 00:48:17 +07:00
parent 7f242c4b63
commit 5754c5747c
17 changed files with 435 additions and 33 deletions

View file

@ -11,4 +11,5 @@ void test_quaternion()
test_quaternion_swap();
test_quaternion_is_zero();
test_quaternion_is_unit();
test_quaternion_modulus();
}

View file

@ -9,6 +9,7 @@
#include "./quaternion/quaternion_swap.h"
#include "./quaternion/quaternion_is_zero.h"
#include "./quaternion/quaternion_is_unit.h"
#include "./quaternion/quaternion_modulus.h"
void test_quaternion();

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,117 @@
#include "./quaternion_modulus.h"
#include "./../../helpers.h"
// ==================== FP32 ==================== //
static const int _TEST_FP32_QUATERNION_AMOUNT = 4;
static const BgcQuaternionFP32 _TEST_FP32_QUATERNION_LIST[] = {
{ 0.0f, 4.0f, 3.0f, 0.0f },
{ -1.0f, 1.0f, -1.0f, 1.0f },
{ 100.0f, -100.0f, 0.0f, 100.0f },
{ -0.86602540378f, 0.5f, -1.0f, 1.0f }
};
static const float _TEST_FP32_SQUARE_MODULUS_LIST[] = {
25.0f,
4.0f,
30000.0f,
3.0f
};
static const float _TEST_FP32_MODULUS_LIST[] = {
5.0f,
2.0f,
173.20508076f,
1.7320508076f
};
void test_quaternion_square_modulus_fp32()
{
print_testing_name("bgc_quaternion_get_square_modulus_fp32");
for (int i = 0; i < _TEST_FP32_QUATERNION_AMOUNT; i++) {
if (!bgc_are_close_fp32(bgc_quaternion_get_square_modulus_fp32(&_TEST_FP32_QUATERNION_LIST[i]), _TEST_FP32_SQUARE_MODULUS_LIST[i])) {
print_testing_failed();
return;
}
}
print_testing_success();
}
void test_quaternion_modulus_fp32()
{
print_testing_name("bgc_quaternion_get_modulus_fp32");