Реорганизация тестов (в процессе)

This commit is contained in:
Andrey Pokidov 2025-02-13 01:20:29 +07:00
parent 43bf030295
commit fcf793c758
41 changed files with 252 additions and 314 deletions

View file

@ -83,7 +83,7 @@ int test_are_close_fp32()
print_testing_success();
return TEST_SUCCES;
return TEST_SUCCESS;
}
// ==================== FP64 ==================== //
@ -159,18 +159,18 @@ int test_are_close_fp64()
print_testing_success();
return TEST_SUCCES;
return TEST_SUCCESS;
}
int test_are_close()
{
if (test_are_close_fp32() != TEST_SUCCES) {
if (test_are_close_fp32() != TEST_SUCCESS) {
return TEST_FAILED;
}
if (test_are_close_fp64() != TEST_SUCCES) {
if (test_are_close_fp64() != TEST_SUCCESS) {
return TEST_FAILED;
}
return TEST_SUCCES;
return TEST_SUCCESS;
}

View file

@ -20,29 +20,27 @@ static const float _TEST_FP32_NONUNIT_NUMBERS[] = {
1.0f - 1.25f * BGC_EPSYLON_FP32
};
int test_is_unit_fp32()
void test_is_unit_fp32()
{
print_testing_name("bgc_is_unit_fp32");
// Testing unit values:
for (int i = 0; i < _TEST_FP32_UNIT_NUMBERS_AMOUNT; i++) {
if (!bgc_is_unit_fp32(_TEST_FP32_UNIT_NUMBERS[i])) {
print_testing_failed();
return TEST_FAILED;
print_testing_failed("A unit value was not recognized");
return;
}
}
// Testing non-unit values:
for (int i = 0; i < _TEST_FP32_NONUNIT_NUMBERS_AMOUNT; i++) {
if (bgc_is_unit_fp32(_TEST_FP32_NONUNIT_NUMBERS[i])) {
print_testing_failed();
return TEST_FAILED;
print_testing_failed("A non-unit value was recognized as a unit value");
return;
}
}
print_testing_success();
return TEST_SUCCES;
}
// ==================== FP64 ==================== //
@ -63,29 +61,27 @@ static const double _TEST_FP64_NONUNIT_NUMBERS[] = {
1.0 - 1.25 * BGC_EPSYLON_FP64
};
int test_is_unit_fp64()
void test_is_unit_fp64()
{
print_testing_name("bgc_is_unit_fp64");
// Testing unit values:
for (int i = 0; i < _TEST_FP64_UNIT_NUMBERS_AMOUNT; i++) {
if (!bgc_is_unit_fp64(_TEST_FP64_UNIT_NUMBERS[i])) {
print_testing_failed();
return TEST_FAILED;
print_testing_failed("A unit value was not recognized");
return;
}
}
// Testing non-unit values:
for (int i = 0; i < _TEST_FP64_NONUNIT_NUMBERS_AMOUNT; i++) {
if (bgc_is_unit_fp64(_TEST_FP64_NONUNIT_NUMBERS[i])) {
print_testing_failed();
return TEST_FAILED;
print_testing_failed("A non-unit value was recognized as a unit value");
return;
}
}
print_testing_success();
return TEST_SUCCES;
}
// ================ Square FP32 ================= //
@ -106,29 +102,27 @@ static const float _TEST_FP32_DATA_SQUARE_NONUNIT[] = {
1.0f - 2.25f * BGC_EPSYLON_FP32
};
int test_is_sqare_unit_fp32()
void test_is_sqare_unit_fp32()
{
print_testing_name("bgc_is_sqare_unit_fp32");
// Testing unit values:
for (int i = 0; i < _TEST_FP32_DATA_SQUARE_UNIT_AMOUNT; i++) {
if (!bgc_is_sqare_unit_fp32(_TEST_FP32_DATA_SQUARE_UNIT[i])) {
print_testing_failed();
return TEST_FAILED;
print_testing_failed("A unit value was not recognized");
return;
}
}
// Testing non-unit values:
for (int i = 0; i < _TEST_FP32_DATA_SQUARE_NONUNIT_AMOUNT; i++) {
if (bgc_is_sqare_unit_fp32(_TEST_FP32_DATA_SQUARE_NONUNIT[i])) {
print_testing_failed();
return TEST_FAILED;
print_testing_failed("A non-unit value was recognized as a unit value");
return;
}
}
print_testing_success();
return TEST_SUCCES;
}
// ================ Square FP64 ================= //
@ -149,7 +143,7 @@ static const double _TEST_FP64_DATA_SQUARE_NONUNIT[] = {
1.0 - 2.25 * BGC_EPSYLON_FP64
};
int test_is_sqare_unit_fp64()
void test_is_sqare_unit_fp64()
{
print_testing_name("bgc_is_sqare_unit_fp64");
@ -157,40 +151,28 @@ int test_is_sqare_unit_fp64()
for (int i = 0; i < _TEST_FP64_DATA_SQUARE_UNIT_AMOUNT; i++) {
if (!bgc_is_sqare_unit_fp64(_TEST_FP64_DATA_SQUARE_UNIT[i])) {
print_testing_failed();
return TEST_FAILED;
return;
}
}
// Testing non-unit values:
for (int i = 0; i < _TEST_FP64_DATA_SQUARE_NONUNIT_AMOUNT; i++) {
if (bgc_is_sqare_unit_fp64(_TEST_FP64_DATA_SQUARE_NONUNIT[i])) {
print_testing_failed();
return TEST_FAILED;
print_testing_failed("A non-unit value was recognized as a unit value");
return;
}
}
print_testing_success();
return TEST_SUCCES;
}
int test_is_unit()
void test_is_unit()
{
if (test_is_unit_fp32() != TEST_SUCCES) {
return TEST_FAILED;
}
test_is_unit_fp32();
test_is_unit_fp64();
if (test_is_unit_fp64() != TEST_SUCCES) {
return TEST_FAILED;
}
test_is_sqare_unit_fp32();
test_is_sqare_unit_fp64();
if (test_is_sqare_unit_fp32() != TEST_SUCCES) {
return TEST_FAILED;
}
if (test_is_sqare_unit_fp64() != TEST_SUCCES) {
return TEST_FAILED;
}
return TEST_SUCCES;
return TEST_SUCCESS;
}

View file

@ -1,14 +1,14 @@
#ifndef _TEST_UTILITIES_IS_UNIT_H_
#define _TEST_UTILITIES_IS_UNIT_H_
int test_is_unit_fp32();
void test_is_unit_fp32();
int test_is_unit_fp64();
void test_is_unit_fp64();
int test_is_sqare_unit_fp32();
void test_is_sqare_unit_fp32();
int test_is_sqare_unit_fp64();
void test_is_sqare_unit_fp64();
int test_is_unit();
void test_is_unit();
#endif

View file

@ -4,99 +4,88 @@
// ==================== FP32 ==================== //
static const int _TEST_FP32_ZERO_NUMBERS_AMOUNT = 3;
static const int _TEST_FP32_NONZERO_NUMBERS_AMOUNT = 4;
static const int _TEST_FP32_ZERO_NUMBER_AMOUNT = 3;
static const int _TEST_FP32_NONZERO_NUMBER_AMOUNT = 4;
static const float _TEST_FP32_ZERO_NUMBERS[] = {
static const float _TEST_FP32_ZERO_NUMBER_LIST[] = {
0.0f,
0.75f * BGC_EPSYLON_FP32,
-0.75f * BGC_EPSYLON_FP32
};
static const float _TEST_FP32_NONZERO_NUMBERS[] = {
static const float _TEST_FP32_NONZERO_NUMBER_LIST[] = {
1.0f,
-1.0f,
1.25f * BGC_EPSYLON_FP32,
-1.25f * BGC_EPSYLON_FP32
};
int test_is_zero_fp32()
void test_is_zero_fp32()
{
print_testing_name("bgc_is_zero_fp32");
// Testing zero values:
for (int i = 0; i < _TEST_FP32_ZERO_NUMBERS_AMOUNT; i++) {
if (!bgc_is_zero_fp32(_TEST_FP32_ZERO_NUMBERS[i])) {
print_testing_failed();
return TEST_FAILED;
for (int i = 0; i < _TEST_FP32_ZERO_NUMBER_AMOUNT; i++) {
if (!bgc_is_zero_fp32(_TEST_FP32_ZERO_NUMBER_LIST[i])) {
print_testing_failed("A zero value was not recognized");
return;
}
}
// Testing non-zero values:
for (int i = 0; i < _TEST_FP32_NONZERO_NUMBERS_AMOUNT; i++) {
if (bgc_is_zero_fp32(_TEST_FP32_NONZERO_NUMBERS[i])) {
print_testing_failed();
return TEST_FAILED;
for (int i = 0; i < _TEST_FP32_NONZERO_NUMBER_AMOUNT; i++) {
if (bgc_is_zero_fp32(_TEST_FP32_NONZERO_NUMBER_LIST[i])) {
print_testing_failed("A non-zero value was recognized as a zero value");
return;
}
}
print_testing_success();
return TEST_SUCCES;
}
// ==================== FP64 ==================== //
static const int _TEST_FP64_ZERO_NUMBERS_AMOUNT = 3;
static const int _TEST_FP64_NONZERO_NUMBERS_AMOUNT = 4;
static const int _TEST_FP64_ZERO_NUMBER_AMOUNT = 3;
static const int _TEST_FP64_NONZERO_NUMBER_AMOUNT = 4;
static const double _TEST_FP64_ZERO_NUMBERS[] = {
static const double _TEST_FP64_ZERO_NUMBER_LIST[] = {
0.0,
0.75 * BGC_EPSYLON_FP64,
-0.75 * BGC_EPSYLON_FP64
};
static const double _TEST_FP64_NONZERO_NUMBERS[] = {
static const double _TEST_FP64_NONZERO_NUMBER_LIST[] = {
1.0,
-1.0,
1.25 * BGC_EPSYLON_FP64,
-1.25 * BGC_EPSYLON_FP64
};
int test_is_zero_fp64()
void test_is_zero_fp64()
{
print_testing_name("bgc_is_zero_fp64");
// Testing zero values:
for (int i = 0; i < _TEST_FP64_ZERO_NUMBERS_AMOUNT; i++) {
if (!bgc_is_zero_fp64(_TEST_FP64_ZERO_NUMBERS[i])) {
print_testing_failed();
return TEST_FAILED;
for (int i = 0; i < _TEST_FP64_ZERO_NUMBER_AMOUNT; i++) {
if (!bgc_is_zero_fp64(_TEST_FP64_ZERO_NUMBER_LIST[i])) {
print_testing_failed("A zero value was not recognized");
return;
}
}
// Testing non-zero values:
for (int i = 0; i < _TEST_FP64_NONZERO_NUMBERS_AMOUNT; i++) {
if (bgc_is_zero_fp64(_TEST_FP64_NONZERO_NUMBERS[i])) {
print_testing_failed();
return TEST_FAILED;
for (int i = 0; i < _TEST_FP64_NONZERO_NUMBER_AMOUNT; i++) {
if (bgc_is_zero_fp64(_TEST_FP64_NONZERO_NUMBER_LIST[i])) {
print_testing_failed("A non zero value was recognized as a zero value");
return;
}
}
print_testing_success();
return TEST_SUCCES;
}
int test_is_zero()
void test_is_zero()
{
if (test_is_zero_fp32() != TEST_SUCCES) {
return TEST_FAILED;
}
if (test_is_zero_fp64() != TEST_SUCCES) {
return TEST_FAILED;
}
return TEST_SUCCES;
}
test_is_zero_fp32();
test_is_zero_fp64();
}

View file

@ -1,10 +1,10 @@
#ifndef _TEST_UTILITIES_IS_ZERO_H_
#define _TEST_UTILITIES_IS_ZERO_H_
int test_is_zero_fp32();
void test_is_zero_fp32();
int test_is_zero_fp64();
void test_is_zero_fp64();
int test_is_zero();
void test_is_zero();
#endif