Тесты для комплексных чисел, исправление в файле проекта для Visual Studio

This commit is contained in:
Andrey Pokidov 2025-02-27 00:37:44 +07:00
parent 1b0fd7ef26
commit f85039a556
22 changed files with 816 additions and 3 deletions

View file

@ -0,0 +1,71 @@
#include "./complex_copy.h"
#include <math.h>
#include "./../../helpers.h"
// ==================== FP32 ==================== //
static const int _TEST_FP32_COMPLEX_AMOUNT = 4;
static const BgcComplexFP32 _TEST_FP32_COMPLEX_LIST[] = {
{ 1.0f, 2.0f },
{ -4.0f, -3.0f },
{ -0.001f, 100.0f },
{ 0.001f, -100.0f }
};
void test_complex_copy_fp32()
{
BgcComplexFP32 vector;
print_testing_name("bgc_complex_copy_fp32");
for (int i = 0; i < _TEST_FP32_COMPLEX_AMOUNT; i++) {
bgc_complex_copy_fp32(&_TEST_FP32_COMPLEX_LIST[i], &vector);
if (vector.real != _TEST_FP32_COMPLEX_LIST[i].real ||
vector.imaginary != _TEST_FP32_COMPLEX_LIST[i].imaginary) {
print_testing_failed();
return;
}
}
print_testing_success();
}
// ==================== FP64 ==================== //
static const int _TEST_FP64_COMPLEX_AMOUNT = 4;
static const BgcComplexFP64 _TEST_FP64_COMPLEX_LIST[] = {
{ 1.0, 2.0 },
{ -4.0, -3.0 },
{ -0.001, 100.0 },
{ 0.001, -100.0 }
};
void test_complex_copy_fp64()
{
BgcComplexFP64 vector;
print_testing_name("bgc_complex_copy_fp64");
for (int i = 0; i < _TEST_FP64_COMPLEX_AMOUNT; i++) {
bgc_complex_copy_fp64(&_TEST_FP64_COMPLEX_LIST[i], &vector);
if (vector.real != _TEST_FP64_COMPLEX_LIST[i].real ||
vector.imaginary != _TEST_FP64_COMPLEX_LIST[i].imaginary) {
print_testing_failed();
return;
}
}
print_testing_success();
}
void test_complex_copy()
{
test_complex_copy_fp32();
test_complex_copy_fp64();
}