Уточнение погрешности (epsylon), поддержка тестов для Code::Blocks
This commit is contained in:
parent
899ca7dd52
commit
47ba771b68
6 changed files with 92 additions and 60 deletions
|
@ -49,6 +49,30 @@
|
||||||
<Unit filename="main.c">
|
<Unit filename="main.c">
|
||||||
<Option compilerVar="CC" />
|
<Option compilerVar="CC" />
|
||||||
</Unit>
|
</Unit>
|
||||||
|
<Unit filename="tests/quaternion.c">
|
||||||
|
<Option compilerVar="CC" />
|
||||||
|
</Unit>
|
||||||
|
<Unit filename="tests/quaternion.h" />
|
||||||
|
<Unit filename="tests/quaternion/quaternion_copy.c">
|
||||||
|
<Option compilerVar="CC" />
|
||||||
|
</Unit>
|
||||||
|
<Unit filename="tests/quaternion/quaternion_copy.h" />
|
||||||
|
<Unit filename="tests/quaternion/quaternion_reset.c">
|
||||||
|
<Option compilerVar="CC" />
|
||||||
|
</Unit>
|
||||||
|
<Unit filename="tests/quaternion/quaternion_reset.h" />
|
||||||
|
<Unit filename="tests/quaternion/quaternion_set_to_identity.c">
|
||||||
|
<Option compilerVar="CC" />
|
||||||
|
</Unit>
|
||||||
|
<Unit filename="tests/quaternion/quaternion_set_to_identity.h" />
|
||||||
|
<Unit filename="tests/quaternion/quaternion_set_values.c">
|
||||||
|
<Option compilerVar="CC" />
|
||||||
|
</Unit>
|
||||||
|
<Unit filename="tests/quaternion/quaternion_set_values.h" />
|
||||||
|
<Unit filename="tests/quaternion/quaternion_swap.c">
|
||||||
|
<Option compilerVar="CC" />
|
||||||
|
</Unit>
|
||||||
|
<Unit filename="tests/quaternion/quaternion_swap.h" />
|
||||||
<Unit filename="tests/utilities.c">
|
<Unit filename="tests/utilities.c">
|
||||||
<Option compilerVar="CC" />
|
<Option compilerVar="CC" />
|
||||||
</Unit>
|
</Unit>
|
||||||
|
@ -73,6 +97,10 @@
|
||||||
<Option compilerVar="CC" />
|
<Option compilerVar="CC" />
|
||||||
</Unit>
|
</Unit>
|
||||||
<Unit filename="tests/vector2/vector2_copy.h" />
|
<Unit filename="tests/vector2/vector2_copy.h" />
|
||||||
|
<Unit filename="tests/vector2/vector2_is_zero.c">
|
||||||
|
<Option compilerVar="CC" />
|
||||||
|
</Unit>
|
||||||
|
<Unit filename="tests/vector2/vector2_is_zero.h" />
|
||||||
<Unit filename="tests/vector2/vector2_reset.c">
|
<Unit filename="tests/vector2/vector2_reset.c">
|
||||||
<Option compilerVar="CC" />
|
<Option compilerVar="CC" />
|
||||||
</Unit>
|
</Unit>
|
||||||
|
@ -93,6 +121,10 @@
|
||||||
<Option compilerVar="CC" />
|
<Option compilerVar="CC" />
|
||||||
</Unit>
|
</Unit>
|
||||||
<Unit filename="tests/vector3/vector3_copy.h" />
|
<Unit filename="tests/vector3/vector3_copy.h" />
|
||||||
|
<Unit filename="tests/vector3/vector3_is_zero.c">
|
||||||
|
<Option compilerVar="CC" />
|
||||||
|
</Unit>
|
||||||
|
<Unit filename="tests/vector3/vector3_is_zero.h" />
|
||||||
<Unit filename="tests/vector3/vector3_reset.c">
|
<Unit filename="tests/vector3/vector3_reset.c">
|
||||||
<Option compilerVar="CC" />
|
<Option compilerVar="CC" />
|
||||||
</Unit>
|
</Unit>
|
||||||
|
|
|
@ -46,7 +46,7 @@ int test_bgc_quaternion_is_zero_fp32()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Testing non-zero values:
|
// Testing non-zero values:
|
||||||
for (int i = 0; i < _TEST_FP32_ZERO_QUATERNION_AMOUNT; i++) {
|
for (int i = 0; i < _TEST_FP32_NONZERO_QUATERNION_AMOUNT; i++) {
|
||||||
if (bgc_quaternion_is_zero_fp32(&_TEST_FP32_NONZERO_NUMBERS[i])) {
|
if (bgc_quaternion_is_zero_fp32(&_TEST_FP32_NONZERO_NUMBERS[i])) {
|
||||||
print_testing_failed();
|
print_testing_failed();
|
||||||
return TEST_FAILED;
|
return TEST_FAILED;
|
||||||
|
@ -102,7 +102,7 @@ int test_bgc_quaternion_is_zero_fp64()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Testing non-zero values:
|
// Testing non-zero values:
|
||||||
for (int i = 0; i < _TEST_FP64_ZERO_QUATERNION_AMOUNT; i++) {
|
for (int i = 0; i < _TEST_FP64_NONZERO_QUATERNION_AMOUNT; i++) {
|
||||||
if (test_bgc_quaternion_is_zero_fp64(&_TEST_FP64_NONZERO_NUMBERS[i])) {
|
if (test_bgc_quaternion_is_zero_fp64(&_TEST_FP64_NONZERO_NUMBERS[i])) {
|
||||||
print_testing_failed();
|
print_testing_failed();
|
||||||
return TEST_FAILED;
|
return TEST_FAILED;
|
||||||
|
|
|
@ -20,22 +20,22 @@ static const _TestNumberPairFP32 _TEST_FP32_DATA_CLOSE[] = {
|
||||||
{1.0f, 1.0f},
|
{1.0f, 1.0f},
|
||||||
{-1.0f, -1.0f},
|
{-1.0f, -1.0f},
|
||||||
|
|
||||||
{-0.5f * BGC_EPSYLON_FP32, 0.5f * BGC_EPSYLON_FP32},
|
{-0.4f * BGC_EPSYLON_FP32, 0.4f * BGC_EPSYLON_FP32},
|
||||||
|
|
||||||
{1.0f, 1.0f + BGC_EPSYLON_FP32},
|
{1.0f, 1.0f + 0.75f * BGC_EPSYLON_FP32},
|
||||||
{1.0f, 1.0f - BGC_EPSYLON_FP32},
|
{1.0f, 1.0f - 0.75f * BGC_EPSYLON_FP32},
|
||||||
{1.0f + BGC_EPSYLON_FP32, 1.0f},
|
{1.0f + 0.75f * BGC_EPSYLON_FP32, 1.0f},
|
||||||
{1.0f - BGC_EPSYLON_FP32, 1.0f},
|
{1.0f - 0.75f * BGC_EPSYLON_FP32, 1.0f},
|
||||||
|
|
||||||
{-1.0f, -1.0f + BGC_EPSYLON_FP32},
|
{-1.0f, -1.0f + 0.75f * BGC_EPSYLON_FP32},
|
||||||
{-1.0f, -1.0f - BGC_EPSYLON_FP32},
|
{-1.0f, -1.0f - 0.75f * BGC_EPSYLON_FP32},
|
||||||
{-1.0f + BGC_EPSYLON_FP32, -1.0f},
|
{-1.0f + 0.75f * BGC_EPSYLON_FP32, -1.0f},
|
||||||
{-1.0f - BGC_EPSYLON_FP32, -1.0f},
|
{-1.0f - 0.75f * BGC_EPSYLON_FP32, -1.0f},
|
||||||
|
|
||||||
{100.0f, 100.0f * (1.0f + BGC_EPSYLON_FP32)},
|
{100.0f, 100.0f * (1.0f + 0.75f * BGC_EPSYLON_FP32)},
|
||||||
{100.0f, 100.0f * (1.0f - BGC_EPSYLON_FP32)},
|
{100.0f, 100.0f * (1.0f - 0.75f * BGC_EPSYLON_FP32)},
|
||||||
{-100.0f, -100.0f * (1.0f + BGC_EPSYLON_FP32)},
|
{-100.0f, -100.0f * (1.0f + 0.75f * BGC_EPSYLON_FP32)},
|
||||||
{-100.0f, -100.0f * (1.0f - BGC_EPSYLON_FP32)}
|
{-100.0f, -100.0f * (1.0f - 0.75f * BGC_EPSYLON_FP32)}
|
||||||
};
|
};
|
||||||
|
|
||||||
static const _TestNumberPairFP32 _TEST_FP32_DATA_DIFFERENT[] = {
|
static const _TestNumberPairFP32 _TEST_FP32_DATA_DIFFERENT[] = {
|
||||||
|
@ -45,20 +45,20 @@ static const _TestNumberPairFP32 _TEST_FP32_DATA_DIFFERENT[] = {
|
||||||
|
|
||||||
{-0.6f * BGC_EPSYLON_FP32, 0.6f * BGC_EPSYLON_FP32},
|
{-0.6f * BGC_EPSYLON_FP32, 0.6f * BGC_EPSYLON_FP32},
|
||||||
|
|
||||||
{1.0f, 1.0f + 1.5f * BGC_EPSYLON_FP32},
|
{1.0f, 1.0f + 1.25f * BGC_EPSYLON_FP32},
|
||||||
{1.0f, 1.0f - 1.5f * BGC_EPSYLON_FP32},
|
{1.0f, 1.0f - 1.25f * BGC_EPSYLON_FP32},
|
||||||
{1.0f + 1.5f * BGC_EPSYLON_FP32, 1.0f},
|
{1.0f + 1.25f * BGC_EPSYLON_FP32, 1.0f},
|
||||||
{1.0f - 1.5f * BGC_EPSYLON_FP32, 1.0f},
|
{1.0f - 1.25f * BGC_EPSYLON_FP32, 1.0f},
|
||||||
|
|
||||||
{-1.0f, -1.0f + 1.5f * BGC_EPSYLON_FP32},
|
{-1.0f, -1.0f + 1.25f * BGC_EPSYLON_FP32},
|
||||||
{-1.0f, -1.0f - 1.5f * BGC_EPSYLON_FP32},
|
{-1.0f, -1.0f - 1.25f * BGC_EPSYLON_FP32},
|
||||||
{-1.0f + 1.5f * BGC_EPSYLON_FP32, -1.0f},
|
{-1.0f + 1.25f * BGC_EPSYLON_FP32, -1.0f},
|
||||||
{-1.0f - 1.5f * BGC_EPSYLON_FP32, -1.0f},
|
{-1.0f - 1.25f * BGC_EPSYLON_FP32, -1.0f},
|
||||||
|
|
||||||
{100.0f, 100.0f * (1.0f + 1.5f * BGC_EPSYLON_FP32)},
|
{100.0f, 100.0f * (1.0f + 1.25f * BGC_EPSYLON_FP32)},
|
||||||
{100.0f, 100.0f * (1.0f - 1.5f * BGC_EPSYLON_FP32)},
|
{100.0f, 100.0f * (1.0f - 1.25f * BGC_EPSYLON_FP32)},
|
||||||
{-100.0f, -100.0f * (1.0f + 1.5f * BGC_EPSYLON_FP32)},
|
{-100.0f, -100.0f * (1.0f + 1.25f * BGC_EPSYLON_FP32)},
|
||||||
{-100.0f, -100.0f * (1.0f - 1.5f * BGC_EPSYLON_FP32)}
|
{-100.0f, -100.0f * (1.0f - 1.25f * BGC_EPSYLON_FP32)}
|
||||||
};
|
};
|
||||||
|
|
||||||
int test_bgc_are_close_fp32()
|
int test_bgc_are_close_fp32()
|
||||||
|
@ -96,22 +96,22 @@ static const _TestNumberPairFP64 _TEST_FP64_DATA_CLOSE[] = {
|
||||||
{1.0, 1.0},
|
{1.0, 1.0},
|
||||||
{-1.0, -1.0},
|
{-1.0, -1.0},
|
||||||
|
|
||||||
{-0.5 * BGC_EPSYLON_FP64, 0.5 * BGC_EPSYLON_FP64},
|
{-0.4 * BGC_EPSYLON_FP64, 0.4 * BGC_EPSYLON_FP64},
|
||||||
|
|
||||||
{1.0, 1.0 + BGC_EPSYLON_FP64},
|
{1.0, 1.0 + 0.75 * BGC_EPSYLON_FP64},
|
||||||
{1.0, 1.0 - BGC_EPSYLON_FP64},
|
{1.0, 1.0 - 0.75 * BGC_EPSYLON_FP64},
|
||||||
{1.0 + BGC_EPSYLON_FP64, 1.0},
|
{1.0 + 0.75 * BGC_EPSYLON_FP64, 1.0},
|
||||||
{1.0 - BGC_EPSYLON_FP64, 1.0},
|
{1.0 - 0.75 * BGC_EPSYLON_FP64, 1.0},
|
||||||
|
|
||||||
{-1.0, -1.0 + BGC_EPSYLON_FP64},
|
{-1.0, -1.0 + 0.75 * BGC_EPSYLON_FP64},
|
||||||
{-1.0, -1.0 - BGC_EPSYLON_FP64},
|
{-1.0, -1.0 - 0.75 * BGC_EPSYLON_FP64},
|
||||||
{-1.0 + BGC_EPSYLON_FP64, -1.0},
|
{-1.0 + 0.75 * BGC_EPSYLON_FP64, -1.0},
|
||||||
{-1.0 - BGC_EPSYLON_FP64, -1.0},
|
{-1.0 - 0.75 * BGC_EPSYLON_FP64, -1.0},
|
||||||
|
|
||||||
{100.0, 100.0 + 99.0 * BGC_EPSYLON_FP64},
|
{100.0, 100.0 * (1.0 + 0.75 * BGC_EPSYLON_FP64)},
|
||||||
{100.0, 100.0 - 99.0 * BGC_EPSYLON_FP64},
|
{100.0, 100.0 * (1.0 - 0.75 * BGC_EPSYLON_FP64)},
|
||||||
{-100.0, -100.0 + 99.0 * BGC_EPSYLON_FP64},
|
{-100.0, -100.0 * (1.0 + 0.75 * BGC_EPSYLON_FP64)},
|
||||||
{-100.0, -100.0 - 99.0 * BGC_EPSYLON_FP64}
|
{-100.0, -100.0 * (1.0 - 0.75 * BGC_EPSYLON_FP64)}
|
||||||
};
|
};
|
||||||
|
|
||||||
static const _TestNumberPairFP64 _TEST_FP64_DATA_DIFFERENT[] = {
|
static const _TestNumberPairFP64 _TEST_FP64_DATA_DIFFERENT[] = {
|
||||||
|
@ -121,20 +121,20 @@ static const _TestNumberPairFP64 _TEST_FP64_DATA_DIFFERENT[] = {
|
||||||
|
|
||||||
{-0.6 * BGC_EPSYLON_FP64, 0.6 * BGC_EPSYLON_FP64},
|
{-0.6 * BGC_EPSYLON_FP64, 0.6 * BGC_EPSYLON_FP64},
|
||||||
|
|
||||||
{1.0, 1.0 + 1.5 * BGC_EPSYLON_FP64},
|
{1.0, 1.0 + 1.25 * BGC_EPSYLON_FP64},
|
||||||
{1.0, 1.0 - 1.5 * BGC_EPSYLON_FP64},
|
{1.0, 1.0 - 1.25 * BGC_EPSYLON_FP64},
|
||||||
{1.0 + 1.5 * BGC_EPSYLON_FP64, 1.0},
|
{1.0 + 1.25 * BGC_EPSYLON_FP64, 1.0},
|
||||||
{1.0 - 1.5 * BGC_EPSYLON_FP64, 1.0},
|
{1.0 - 1.25 * BGC_EPSYLON_FP64, 1.0},
|
||||||
|
|
||||||
{-1.0, -1.0 + 1.5 * BGC_EPSYLON_FP64},
|
{-1.0, -1.0 + 1.25 * BGC_EPSYLON_FP64},
|
||||||
{-1.0, -1.0 - 1.5 * BGC_EPSYLON_FP64},
|
{-1.0, -1.0 - 1.25 * BGC_EPSYLON_FP64},
|
||||||
{-1.0 + 1.5 * BGC_EPSYLON_FP64, -1.0},
|
{-1.0 + 1.25 * BGC_EPSYLON_FP64, -1.0},
|
||||||
{-1.0 - 1.5 * BGC_EPSYLON_FP64, -1.0},
|
{-1.0 - 1.25 * BGC_EPSYLON_FP64, -1.0},
|
||||||
|
|
||||||
{100.0, 100.0 + 101.0 * BGC_EPSYLON_FP64},
|
{100.0, 100.0 * (1.0 + 1.25 * BGC_EPSYLON_FP64)},
|
||||||
{100.0, 100.0 - 101.0 * BGC_EPSYLON_FP64},
|
{100.0, 100.0 * (1.0 - 1.25 * BGC_EPSYLON_FP64)},
|
||||||
{-100.0, -100.0 + 101.0 * BGC_EPSYLON_FP64},
|
{-100.0, -100.0 * (1.0 + 1.25 * BGC_EPSYLON_FP64)},
|
||||||
{-100.0, -100.0 - 101.0 * BGC_EPSYLON_FP64}
|
{-100.0, -100.0 * (1.0 - 1.25 * BGC_EPSYLON_FP64)}
|
||||||
};
|
};
|
||||||
|
|
||||||
int test_bgc_are_close_fp64()
|
int test_bgc_are_close_fp64()
|
||||||
|
|
|
@ -38,7 +38,7 @@ int test_bgc_vector2_is_zero_fp32()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Testing non-zero values:
|
// Testing non-zero values:
|
||||||
for (int i = 0; i < _TEST_FP32_ZERO_QUATERNION_AMOUNT; i++) {
|
for (int i = 0; i < _TEST_FP32_NONZERO_QUATERNION_AMOUNT; i++) {
|
||||||
if (bgc_vector2_is_zero_fp32(&_TEST_FP32_NONZERO_NUMBERS[i])) {
|
if (bgc_vector2_is_zero_fp32(&_TEST_FP32_NONZERO_NUMBERS[i])) {
|
||||||
print_testing_failed();
|
print_testing_failed();
|
||||||
return TEST_FAILED;
|
return TEST_FAILED;
|
||||||
|
@ -86,7 +86,7 @@ int test_bgc_vector2_is_zero_fp64()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Testing non-zero values:
|
// Testing non-zero values:
|
||||||
for (int i = 0; i < _TEST_FP64_ZERO_QUATERNION_AMOUNT; i++) {
|
for (int i = 0; i < _TEST_FP64_NONZERO_QUATERNION_AMOUNT; i++) {
|
||||||
if (bgc_vector2_is_zero_fp64(&_TEST_FP64_NONZERO_NUMBERS[i])) {
|
if (bgc_vector2_is_zero_fp64(&_TEST_FP64_NONZERO_NUMBERS[i])) {
|
||||||
print_testing_failed();
|
print_testing_failed();
|
||||||
return TEST_FAILED;
|
return TEST_FAILED;
|
||||||
|
|
|
@ -42,7 +42,7 @@ int test_bgc_vector3_is_zero_fp32()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Testing non-zero values:
|
// Testing non-zero values:
|
||||||
for (int i = 0; i < _TEST_FP32_ZERO_QUATERNION_AMOUNT; i++) {
|
for (int i = 0; i < _TEST_FP32_NONZERO_QUATERNION_AMOUNT; i++) {
|
||||||
if (bgc_vector3_is_zero_fp32(&_TEST_FP32_NONZERO_NUMBERS[i])) {
|
if (bgc_vector3_is_zero_fp32(&_TEST_FP32_NONZERO_NUMBERS[i])) {
|
||||||
print_testing_failed();
|
print_testing_failed();
|
||||||
return TEST_FAILED;
|
return TEST_FAILED;
|
||||||
|
@ -94,7 +94,7 @@ int test_bgc_vector3_is_zero_fp64()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Testing non-zero values:
|
// Testing non-zero values:
|
||||||
for (int i = 0; i < _TEST_FP64_ZERO_QUATERNION_AMOUNT; i++) {
|
for (int i = 0; i < _TEST_FP64_NONZERO_QUATERNION_AMOUNT; i++) {
|
||||||
if (bgc_vector3_is_zero_fp64(&_TEST_FP64_NONZERO_NUMBERS[i])) {
|
if (bgc_vector3_is_zero_fp64(&_TEST_FP64_NONZERO_NUMBERS[i])) {
|
||||||
print_testing_failed();
|
print_testing_failed();
|
||||||
return TEST_FAILED;
|
return TEST_FAILED;
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
|
|
||||||
#define BGC_EPSYLON_EFFECTIVENESS_LIMIT_FP32 1.0f
|
#define BGC_EPSYLON_EFFECTIVENESS_LIMIT_FP32 1.0f
|
||||||
|
|
||||||
#define BGC_EPSYLON_FP32 5E-7f
|
#define BGC_EPSYLON_FP32 4.76837E-7f
|
||||||
#define BGC_SQUARE_EPSYLON_FP32 2.5E-13f
|
#define BGC_SQUARE_EPSYLON_FP32 2.27373906E-13f
|
||||||
|
|
||||||
#define BGC_ONE_THIRD_FP32 0.333333333f
|
#define BGC_ONE_THIRD_FP32 0.333333333f
|
||||||
#define BGC_ONE_SIXTH_FP32 0.166666667f
|
#define BGC_ONE_SIXTH_FP32 0.166666667f
|
||||||
|
@ -15,8 +15,8 @@
|
||||||
|
|
||||||
#define BGC_EPSYLON_EFFECTIVENESS_LIMIT_FP64 1.0
|
#define BGC_EPSYLON_EFFECTIVENESS_LIMIT_FP64 1.0
|
||||||
|
|
||||||
#define BGC_EPSYLON_FP64 5E-14
|
#define BGC_EPSYLON_FP64 4.996003611E-14
|
||||||
#define BGC_SQUARE_EPSYLON_FP64 2.5E-27
|
#define BGC_SQUARE_EPSYLON_FP64 2.496005208112504E-27
|
||||||
|
|
||||||
#define BGC_ONE_THIRD_FP64 0.333333333333333333
|
#define BGC_ONE_THIRD_FP64 0.333333333333333333
|
||||||
#define BGC_ONE_SIXTH_FP64 0.166666666666666667
|
#define BGC_ONE_SIXTH_FP64 0.166666666666666667
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue