Добавлено несколько модульных тестов (покрыто примерно 3,2%), небольшое исправление, переименование tantent в tangent pair (тангенсная пара)
This commit is contained in:
parent
9864653787
commit
ab4a589e21
30 changed files with 1433 additions and 155 deletions
163
basic-geometry-test/tests/utilities/are_close.c
Normal file
163
basic-geometry-test/tests/utilities/are_close.c
Normal file
|
@ -0,0 +1,163 @@
|
|||
#include "./are_close.h"
|
||||
|
||||
#include "./../../helpers.h"
|
||||
|
||||
typedef struct {
|
||||
float number1, number2;
|
||||
} _TestNumberPairFP32;
|
||||
|
||||
typedef struct {
|
||||
double number1, number2;
|
||||
} _TestNumberPairFP64;
|
||||
|
||||
// ==================== FP32 ==================== //
|
||||
|
||||
static const int _TEST_FP32_CLOSE_NUMBERS_AMOUNT = 16;
|
||||
static const int _TEST_FP32_DIFFERENT_NUMBERS_AMOUNT = 16;
|
||||
|
||||
static const _TestNumberPairFP32 _TEST_FP32_DATA_CLOSE[] = {
|
||||
{0.0f, 0.0f},
|
||||
{1.0f, 1.0f},
|
||||
{-1.0f, -1.0f},
|
||||
|
||||
{-0.5f * BGC_EPSYLON_FP32, 0.5f * BGC_EPSYLON_FP32},
|
||||
|
||||
{1.0f, 1.0f + BGC_EPSYLON_FP32},
|
||||
{1.0f, 1.0f - BGC_EPSYLON_FP32},
|
||||
{1.0f + BGC_EPSYLON_FP32, 1.0f},
|
||||
{1.0f - BGC_EPSYLON_FP32, 1.0f},
|
||||
|
||||
{-1.0f, -1.0f + BGC_EPSYLON_FP32},
|
||||
{-1.0f, -1.0f - BGC_EPSYLON_FP32},
|
||||
{-1.0f + BGC_EPSYLON_FP32, -1.0f},
|
||||
{-1.0f - BGC_EPSYLON_FP32, -1.0f},
|
||||
|
||||
{100.0f, 100.0f + 99.0f * BGC_EPSYLON_FP32},
|
||||
{100.0f, 100.0f - 99.0f * BGC_EPSYLON_FP32},
|
||||
{-100.0f, -100.0f + 99.0f * BGC_EPSYLON_FP32},
|
||||
{-100.0f, -100.0f - 99.0f * BGC_EPSYLON_FP32}
|
||||
};
|
||||
|
||||
static const _TestNumberPairFP32 _TEST_FP32_DATA_DIFFERENT[] = {
|
||||
{0.0f, 0.001f},
|
||||
{1.0f, 0.999f},
|
||||
{-1.0f, -0.999f},
|
||||
|
||||
{-0.6f * BGC_EPSYLON_FP32, 0.6f * BGC_EPSYLON_FP32},
|
||||
|
||||
{1.0f, 1.0f + 1.5f * BGC_EPSYLON_FP32},
|
||||
{1.0f, 1.0f - 1.5f * BGC_EPSYLON_FP32},
|
||||
{1.0f + 1.5f * BGC_EPSYLON_FP32, 1.0f},
|
||||
{1.0f - 1.5f * BGC_EPSYLON_FP32, 1.0f},
|
||||
|
||||
{-1.0f, -1.0f + 1.5f * BGC_EPSYLON_FP32},
|
||||
{-1.0f, -1.0f - 1.5f * BGC_EPSYLON_FP32},
|
||||
{-1.0f + 1.5f * BGC_EPSYLON_FP32, -1.0f},
|
||||
{-1.0f - 1.5f * BGC_EPSYLON_FP32, -1.0f},
|
||||
|
||||
{100.0f, 100.0f + 101.0f * BGC_EPSYLON_FP32},
|
||||
{100.0f, 100.0f - 101.0f * BGC_EPSYLON_FP32},
|
||||
{-100.0f, -100.0f + 101.0f * BGC_EPSYLON_FP32},
|
||||
{-100.0f, -100.0f - 101.0f * BGC_EPSYLON_FP32}
|
||||
};
|
||||
|
||||
int test_bgc_are_close_fp32()
|
||||
{
|
||||
print_testing_name("bgc_are_close_fp32");
|
||||
|
||||
// Testing close pairs of values:
|
||||
for (int i = 0; i < _TEST_FP32_CLOSE_NUMBERS_AMOUNT; i++) {
|
||||
if (!bgc_are_close_fp32(_TEST_FP32_DATA_CLOSE[i].number1, _TEST_FP32_DATA_CLOSE[i].number2)) {
|
||||
print_testing_failed();
|
||||
return TEST_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
// Testing different pairs of values:
|
||||
for (int i = 0; i < _TEST_FP32_DIFFERENT_NUMBERS_AMOUNT; i++) {
|
||||
if (bgc_are_close_fp32(_TEST_FP32_DATA_DIFFERENT[i].number1, _TEST_FP32_DATA_DIFFERENT[i].number2)) {
|
||||
print_testing_failed();
|
||||
return TEST_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
print_testing_success();
|
||||
|
||||
return TEST_SUCCES;
|
||||
}
|
||||
|
||||
// ==================== FP64 ==================== //
|
||||
|
||||
static const int _TEST_FP64_CLOSE_NUMBERS_AMOUNT = 16;
|
||||
static const int _TEST_FP64_DIFFERENT_NUMBERS_AMOUNT = 16;
|
||||
|
||||
static const _TestNumberPairFP64 _TEST_FP64_DATA_CLOSE[] = {
|
||||
{0.0, 0.0},
|
||||
{1.0, 1.0},
|
||||
{-1.0, -1.0},
|
||||
|
||||
{-0.5 * BGC_EPSYLON_FP64, 0.5 * BGC_EPSYLON_FP64},
|
||||
|
||||
{1.0, 1.0 + BGC_EPSYLON_FP64},
|
||||
{1.0, 1.0 - BGC_EPSYLON_FP64},
|
||||
{1.0 + BGC_EPSYLON_FP64, 1.0},
|
||||
{1.0 - BGC_EPSYLON_FP64, 1.0},
|
||||
|
||||
{-1.0, -1.0 + BGC_EPSYLON_FP64},
|
||||
{-1.0, -1.0 - BGC_EPSYLON_FP64},
|
||||
{-1.0 + BGC_EPSYLON_FP64, -1.0},
|
||||
{-1.0 - BGC_EPSYLON_FP64, -1.0},
|
||||
|
||||
{100.0, 100.0 + 99.0 * BGC_EPSYLON_FP64},
|
||||
{100.0, 100.0 - 99.0 * BGC_EPSYLON_FP64},
|
||||
{-100.0, -100.0 + 99.0 * BGC_EPSYLON_FP64},
|
||||
{-100.0, -100.0 - 99.0 * BGC_EPSYLON_FP64}
|
||||
};
|
||||
|
||||
static const _TestNumberPairFP64 _TEST_FP64_DATA_DIFFERENT[] = {
|
||||
{0.0, 0.000001},
|
||||
{1.0, 0.999999},
|
||||
{-1.0, -0.999999},
|
||||
|
||||
{-0.6 * BGC_EPSYLON_FP64, 0.6 * BGC_EPSYLON_FP64},
|
||||
|
||||
{1.0, 1.0 + 1.5 * BGC_EPSYLON_FP64},
|
||||
{1.0, 1.0 - 1.5 * BGC_EPSYLON_FP64},
|
||||
{1.0 + 1.5 * BGC_EPSYLON_FP64, 1.0},
|
||||
{1.0 - 1.5 * BGC_EPSYLON_FP64, 1.0},
|
||||
|
||||
{-1.0, -1.0 + 1.5 * BGC_EPSYLON_FP64},
|
||||
{-1.0, -1.0 - 1.5 * BGC_EPSYLON_FP64},
|
||||
{-1.0 + 1.5 * BGC_EPSYLON_FP64, -1.0},
|
||||
{-1.0 - 1.5 * BGC_EPSYLON_FP64, -1.0},
|
||||
|
||||
{100.0, 100.0 + 101.0 * BGC_EPSYLON_FP64},
|
||||
{100.0, 100.0 - 101.0 * BGC_EPSYLON_FP64},
|
||||
{-100.0, -100.0 + 101.0 * BGC_EPSYLON_FP64},
|
||||
{-100.0, -100.0 - 101.0 * BGC_EPSYLON_FP64}
|
||||
};
|
||||
|
||||
int test_bgc_are_close_fp64()
|
||||
{
|
||||
print_testing_name("bgc_are_close_fp64");
|
||||
|
||||
// Testing close pairs of values:
|
||||
for (int i = 0; i < _TEST_FP64_CLOSE_NUMBERS_AMOUNT; i++) {
|
||||
if (!bgc_are_close_fp64(_TEST_FP64_DATA_CLOSE[i].number1, _TEST_FP64_DATA_CLOSE[i].number2)) {
|
||||
print_testing_failed();
|
||||
return TEST_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
// Testing different pairs of values:
|
||||
for (int i = 0; i < _TEST_FP64_DIFFERENT_NUMBERS_AMOUNT; i++) {
|
||||
if (bgc_are_close_fp64(_TEST_FP64_DATA_DIFFERENT[i].number1, _TEST_FP64_DATA_DIFFERENT[i].number2)) {
|
||||
print_testing_failed();
|
||||
return TEST_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
print_testing_success();
|
||||
|
||||
return TEST_SUCCES;
|
||||
}
|
8
basic-geometry-test/tests/utilities/are_close.h
Normal file
8
basic-geometry-test/tests/utilities/are_close.h
Normal file
|
@ -0,0 +1,8 @@
|
|||
#ifndef _TEST_UTILITIES_ARE_CLOSE_H_
|
||||
#define _TEST_UTILITIES_ARE_CLOSE_H_
|
||||
|
||||
int test_bgc_are_close_fp32();
|
||||
|
||||
int test_bgc_are_close_fp64();
|
||||
|
||||
#endif
|
179
basic-geometry-test/tests/utilities/is_unit.c
Normal file
179
basic-geometry-test/tests/utilities/is_unit.c
Normal file
|
@ -0,0 +1,179 @@
|
|||
#include "./is_unit.h"
|
||||
|
||||
#include "./../../helpers.h"
|
||||
|
||||
// ==================== FP32 ==================== //
|
||||
|
||||
static const int _TEST_FP32_UNIT_NUMBERS_AMOUNT = 3;
|
||||
static const int _TEST_FP32_NONUNIT_NUMBERS_AMOUNT = 4;
|
||||
|
||||
static const float _TEST_FP32_UNIT_NUMBERS[] = {
|
||||
1.0f,
|
||||
1.0f + BGC_EPSYLON_FP32,
|
||||
1.0f - BGC_EPSYLON_FP32
|
||||
};
|
||||
|
||||
static const float _TEST_FP32_NONUNIT_NUMBERS[] = {
|
||||
0.0f,
|
||||
-1.0f,
|
||||
1.0f + 2.0f * BGC_EPSYLON_FP32,
|
||||
1.0f - 2.0f * BGC_EPSYLON_FP32
|
||||
};
|
||||
|
||||
int test_bgc_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;
|
||||
}
|
||||
}
|
||||
|
||||
// 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_success();
|
||||
|
||||
return TEST_SUCCES;
|
||||
}
|
||||
|
||||
// ==================== FP64 ==================== //
|
||||
|
||||
static const int _TEST_FP64_UNIT_NUMBERS_AMOUNT = 3;
|
||||
static const int _TEST_FP64_NONUNIT_NUMBERS_AMOUNT = 4;
|
||||
|
||||
static const double _TEST_FP64_UNIT_NUMBERS[] = {
|
||||
1.0,
|
||||
1.0 + BGC_EPSYLON_FP64,
|
||||
1.0 - BGC_EPSYLON_FP64
|
||||
};
|
||||
|
||||
static const double _TEST_FP64_NONUNIT_NUMBERS[] = {
|
||||
0.0,
|
||||
-1.0,
|
||||
1.0 + 2.0 * BGC_EPSYLON_FP64,
|
||||
1.0 - 2.0 * BGC_EPSYLON_FP64
|
||||
};
|
||||
|
||||
int test_bgc_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;
|
||||
}
|
||||
}
|
||||
|
||||
// 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_success();
|
||||
|
||||
return TEST_SUCCES;
|
||||
}
|
||||
|
||||
// ================ Square FP32 ================= //
|
||||
|
||||
static const int _TEST_FP32_DATA_SQUARE_UNIT_AMOUNT = 5;
|
||||
static const int _TEST_FP32_DATA_SQUARE_NONUNIT_AMOUNT = 4;
|
||||
|
||||
static const float _TEST_FP32_DATA_SQUARE_UNIT[] = {
|
||||
1.0f,
|
||||
1.0f + BGC_EPSYLON_FP32,
|
||||
1.0f - 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[] = {
|
||||
0.0f,
|
||||
-1.0f,
|
||||
1.0f + 2.5f * BGC_EPSYLON_FP32,
|
||||
1.0f - 2.5f * BGC_EPSYLON_FP32
|
||||
};
|
||||
|
||||
int test_bgc_is_sqare_value_unit_fp32()
|
||||
{
|
||||
print_testing_name("bgc_is_sqare_value_unit_fp32");
|
||||
|
||||
// Testing unit values:
|
||||
for (int i = 0; i < _TEST_FP32_DATA_SQUARE_UNIT_AMOUNT; i++) {
|
||||
if (!bgc_is_sqare_value_unit_fp32(_TEST_FP32_DATA_SQUARE_UNIT[i])) {
|
||||
print_testing_failed();
|
||||
return TEST_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
// Testing non-unit values:
|
||||
for (int i = 0; i < _TEST_FP32_DATA_SQUARE_NONUNIT_AMOUNT; i++) {
|
||||
if (bgc_is_sqare_value_unit_fp32(_TEST_FP32_DATA_SQUARE_NONUNIT[i])) {
|
||||
print_testing_failed();
|
||||
return TEST_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
print_testing_success();
|
||||
|
||||
return TEST_SUCCES;
|
||||
}
|
||||
|
||||
// ================ Square FP64 ================= //
|
||||
|
||||
static const int _TEST_FP64_DATA_SQUARE_UNIT_AMOUNT = 5;
|
||||
static const int _TEST_FP64_DATA_SQUARE_NONUNIT_AMOUNT = 4;
|
||||
|
||||
static const double _TEST_FP64_DATA_SQUARE_UNIT[] = {
|
||||
1.0,
|
||||
1.0 + BGC_EPSYLON_FP64,
|
||||
1.0 - BGC_EPSYLON_FP64,
|
||||
1.0 + 2.0 * BGC_EPSYLON_FP64,
|
||||
1.0 - 2.0 * BGC_EPSYLON_FP64
|
||||
};
|
||||
|
||||
static const double _TEST_FP64_DATA_SQUARE_NONUNIT[] = {
|
||||
0.0,
|
||||
-1.0,
|
||||
1.0 + 2.5 * BGC_EPSYLON_FP64,
|
||||
1.0 - 2.5 * BGC_EPSYLON_FP64
|
||||
};
|
||||
|
||||
int test_bgc_is_sqare_value_unit_fp64()
|
||||
{
|
||||
print_testing_name("bgc_is_sqare_value_unit_fp64");
|
||||
|
||||
// Testing unit values:
|
||||
for (int i = 0; i < _TEST_FP64_DATA_SQUARE_UNIT_AMOUNT; i++) {
|
||||
if (!bgc_is_sqare_value_unit_fp64(_TEST_FP64_DATA_SQUARE_UNIT[i])) {
|
||||
print_testing_failed();
|
||||
return TEST_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
// Testing non-unit values:
|
||||
for (int i = 0; i < _TEST_FP64_DATA_SQUARE_NONUNIT_AMOUNT; i++) {
|
||||
if (bgc_is_sqare_value_unit_fp64(_TEST_FP64_DATA_SQUARE_NONUNIT[i])) {
|
||||
print_testing_failed();
|
||||
return TEST_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
print_testing_success();
|
||||
|
||||
return TEST_SUCCES;
|
||||
}
|
12
basic-geometry-test/tests/utilities/is_unit.h
Normal file
12
basic-geometry-test/tests/utilities/is_unit.h
Normal file
|
@ -0,0 +1,12 @@
|
|||
#ifndef _TEST_UTILITIES_IS_UNIT_H_
|
||||
#define _TEST_UTILITIES_IS_UNIT_H_
|
||||
|
||||
int test_bgc_is_unit_fp32();
|
||||
|
||||
int test_bgc_is_unit_fp64();
|
||||
|
||||
int test_bgc_is_sqare_value_unit_fp32();
|
||||
|
||||
int test_bgc_is_sqare_value_unit_fp64();
|
||||
|
||||
#endif
|
93
basic-geometry-test/tests/utilities/is_zero.c
Normal file
93
basic-geometry-test/tests/utilities/is_zero.c
Normal file
|
@ -0,0 +1,93 @@
|
|||
#include "./is_zero.h"
|
||||
|
||||
#include "./../../helpers.h"
|
||||
|
||||
// ==================== FP32 ==================== //
|
||||
|
||||
static const int _TEST_FP32_ZERO_NUMBERS_AMOUNT = 5;
|
||||
static const int _TEST_FP32_NONZERO_NUMBERS_AMOUNT = 4;
|
||||
|
||||
static const float _TEST_FP32_ZERO_NUMBERS[] = {
|
||||
0.0f,
|
||||
BGC_EPSYLON_FP32,
|
||||
-BGC_EPSYLON_FP32,
|
||||
BGC_SQUARE_EPSYLON_FP32,
|
||||
-BGC_SQUARE_EPSYLON_FP32
|
||||
};
|
||||
|
||||
static const float _TEST_FP32_NONZERO_NUMBERS[] = {
|
||||
1.0f,
|
||||
-1.0f,
|
||||
(1.5f * BGC_EPSYLON_FP32),
|
||||
-(1.5f * BGC_EPSYLON_FP32)
|
||||
};
|
||||
|
||||
int test_bgc_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;
|
||||
}
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
print_testing_success();
|
||||
|
||||
return TEST_SUCCES;
|
||||
}
|
||||
|
||||
// ==================== FP64 ==================== //
|
||||
|
||||
static const int _TEST_FP64_ZERO_NUMBERS_AMOUNT = 5;
|
||||
static const int _TEST_FP64_NONZERO_NUMBERS_AMOUNT = 4;
|
||||
|
||||
static const double _TEST_FP64_ZERO_NUMBERS[] = {
|
||||
0.0,
|
||||
BGC_EPSYLON_FP64,
|
||||
-BGC_EPSYLON_FP64,
|
||||
BGC_SQUARE_EPSYLON_FP64,
|
||||
-BGC_SQUARE_EPSYLON_FP64
|
||||
};
|
||||
|
||||
static const double _TEST_FP64_NONZERO_NUMBERS[] = {
|
||||
1.0,
|
||||
-1.0,
|
||||
(1.5 * BGC_EPSYLON_FP64),
|
||||
-(1.5 * BGC_EPSYLON_FP64)
|
||||
};
|
||||
|
||||
int test_bgc_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;
|
||||
}
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
print_testing_success();
|
||||
|
||||
return TEST_SUCCES;
|
||||
}
|
8
basic-geometry-test/tests/utilities/is_zero.h
Normal file
8
basic-geometry-test/tests/utilities/is_zero.h
Normal file
|
@ -0,0 +1,8 @@
|
|||
#ifndef _TEST_UTILITIES_IS_ZERO_H_
|
||||
#define _TEST_UTILITIES_IS_ZERO_H_
|
||||
|
||||
int test_bgc_is_zero_fp32();
|
||||
|
||||
int test_bgc_is_zero_fp64();
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue