Упрощение тестов
This commit is contained in:
parent
fcf793c758
commit
7f242c4b63
71 changed files with 518 additions and 943 deletions
|
@ -14,25 +14,23 @@ static const BgcVector2FP32 _TEST_FP32_VECTOR2_LIST[] = {
|
|||
{ -100.0f, 100.0f }
|
||||
};
|
||||
|
||||
int test_vector2_copy_fp32()
|
||||
void test_vector2_copy_fp32()
|
||||
{
|
||||
BgcVector2FP32 vector;
|
||||
|
||||
print_testing_name("bgc_vector2_copy_fp32");
|
||||
|
||||
for (int i = 0; i < _TEST_FP32_VECTOR2_AMOUNT; i++) {
|
||||
|
||||
|
||||
bgc_vector2_copy_fp32(&_TEST_FP32_VECTOR2_LIST[i], &vector);
|
||||
|
||||
if (vector.x1 != _TEST_FP32_VECTOR2_LIST[i].x1 || vector.x2 != _TEST_FP32_VECTOR2_LIST[i].x2) {
|
||||
print_testing_failed();
|
||||
return TEST_FAILED;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
print_testing_success();
|
||||
|
||||
return TEST_SUCCESS;
|
||||
}
|
||||
|
||||
// ==================== FP64 ==================== //
|
||||
|
@ -45,7 +43,7 @@ static const BgcVector2FP64 _TEST_FP64_VECTOR2_LIST[] = {
|
|||
{ -100.0, 100.0 }
|
||||
};
|
||||
|
||||
int test_vector2_copy_fp64()
|
||||
void test_vector2_copy_fp64()
|
||||
{
|
||||
BgcVector2FP64 vector;
|
||||
|
||||
|
@ -57,24 +55,15 @@ int test_vector2_copy_fp64()
|
|||
|
||||
if (vector.x1 != _TEST_FP64_VECTOR2_LIST[i].x1 || vector.x2 != _TEST_FP64_VECTOR2_LIST[i].x2) {
|
||||
print_testing_failed();
|
||||
return TEST_FAILED;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
print_testing_success();
|
||||
|
||||
return TEST_SUCCESS;
|
||||
}
|
||||
|
||||
int test_vector2_copy()
|
||||
void test_vector2_copy()
|
||||
{
|
||||
if (test_vector2_copy_fp32() != TEST_SUCCESS) {
|
||||
return TEST_FAILED;
|
||||
}
|
||||
|
||||
if (test_vector2_copy_fp64() != TEST_SUCCESS) {
|
||||
return TEST_FAILED;
|
||||
}
|
||||
|
||||
return TEST_SUCCESS;
|
||||
test_vector2_copy_fp32();
|
||||
test_vector2_copy_fp64();
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#ifndef _TEST_VECTOR2_COPY_H_
|
||||
#define _TEST_VECTOR2_COPY_H_
|
||||
|
||||
int test_vector2_copy_fp32();
|
||||
void test_vector2_copy_fp32();
|
||||
|
||||
int test_vector2_copy_fp64();
|
||||
void test_vector2_copy_fp64();
|
||||
|
||||
int test_vector2_copy();
|
||||
void test_vector2_copy();
|
||||
|
||||
#endif
|
||||
|
|
|
@ -26,29 +26,27 @@ static const BgcVector2FP32 _TEST_FP32_NONUNIT_VECTOR2_LIST[] = {
|
|||
{ 0.6f - 1.25f * BGC_EPSYLON_FP32, 0.8f - 1.25f * BGC_EPSYLON_FP32 }
|
||||
};
|
||||
|
||||
int test_vector2_is_unit_fp32()
|
||||
void test_vector2_is_unit_fp32()
|
||||
{
|
||||
print_testing_name("bgc_vector2_is_unit_fp32");
|
||||
|
||||
// Testing zero values:
|
||||
for (int i = 0; i < _TEST_FP32_UNIT_VECTOR2_AMOUNT; i++) {
|
||||
if (!bgc_vector2_is_unit_fp32(&_TEST_FP32_UNIT_VECTOR2_LIST[i])) {
|
||||
print_testing_failed();
|
||||
return TEST_FAILED;
|
||||
print_testing_error("A unit vector was not recognized");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Testing non-zero values:
|
||||
for (int i = 0; i < _TEST_FP32_NONUNIT_VECTOR2_AMOUNT; i++) {
|
||||
if (bgc_vector2_is_unit_fp32(&_TEST_FP32_NONUNIT_VECTOR2_LIST[i])) {
|
||||
print_testing_failed();
|
||||
return TEST_FAILED;
|
||||
print_testing_error("A non-unit vector was recognized as a unit vector");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
print_testing_success();
|
||||
|
||||
return TEST_SUCCESS;
|
||||
}
|
||||
|
||||
// ==================== FP64 ==================== //
|
||||
|
@ -75,40 +73,31 @@ static const BgcVector2FP64 _TEST_FP64_NONUNIT_VECTOR2_LIST[] = {
|
|||
{ 0.8 - 1.25 * BGC_EPSYLON_FP64, 0.6 - 1.25 * BGC_EPSYLON_FP64 }
|
||||
};
|
||||
|
||||
int test_vector2_is_unit_fp64()
|
||||
void test_vector2_is_unit_fp64()
|
||||
{
|
||||
print_testing_name("bgc_vector2_is_unit_fp64");
|
||||
|
||||
// Testing zero values:
|
||||
for (int i = 0; i < _TEST_FP64_UNIT_VECTOR2_AMOUNT; i++) {
|
||||
if (!bgc_vector2_is_unit_fp64(&_TEST_FP64_UNIT_VECTOR2_LIST[i])) {
|
||||
print_testing_failed();
|
||||
return TEST_FAILED;
|
||||
print_testing_error("A unit vector was not recognized");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Testing non-zero values:
|
||||
for (int i = 0; i < _TEST_FP64_NONUNIT_VECTOR2_AMOUNT; i++) {
|
||||
if (bgc_vector2_is_unit_fp64(&_TEST_FP64_NONUNIT_VECTOR2_LIST[i])) {
|
||||
print_testing_failed();
|
||||
return TEST_FAILED;
|
||||
print_testing_error("A non-unit vector was recognized as a unit vector");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
print_testing_success();
|
||||
|
||||
return TEST_SUCCESS;
|
||||
}
|
||||
|
||||
int test_vector2_is_unit()
|
||||
void test_vector2_is_unit()
|
||||
{
|
||||
if (test_vector2_is_unit_fp32() != TEST_SUCCESS) {
|
||||
return TEST_FAILED;
|
||||
}
|
||||
|
||||
if (test_vector2_is_unit_fp64() != TEST_SUCCESS) {
|
||||
return TEST_FAILED;
|
||||
}
|
||||
|
||||
return TEST_SUCCESS;
|
||||
test_vector2_is_unit_fp32();
|
||||
test_vector2_is_unit_fp64();
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#ifndef _TEST_VECTOR2_IS_UNIT_H_
|
||||
#define _TEST_VECTOR2_IS_UNIT_H_
|
||||
|
||||
int test_vector2_is_unit_fp32();
|
||||
void test_vector2_is_unit_fp32();
|
||||
|
||||
int test_vector2_is_unit_fp64();
|
||||
void test_vector2_is_unit_fp64();
|
||||
|
||||
int test_vector2_is_unit();
|
||||
void test_vector2_is_unit();
|
||||
|
||||
#endif
|
||||
|
|
|
@ -25,29 +25,27 @@ static const BgcVector2FP32 _TEST_FP32_NONZERO_VECTOR2_LIST[] = {
|
|||
{ -1.25f * BGC_EPSYLON_FP32, -1.25f * BGC_EPSYLON_FP32 }
|
||||
};
|
||||
|
||||
int test_vector2_is_zero_fp32()
|
||||
void test_vector2_is_zero_fp32()
|
||||
{
|
||||
print_testing_name("bgc_vector2_is_zero_fp32");
|
||||
|
||||
// Testing zero values:
|
||||
for (int i = 0; i < _TEST_FP32_ZERO_VECTOR2_AMOUNT; i++) {
|
||||
if (!bgc_vector2_is_zero_fp32(&_TEST_FP32_ZERO_VECTOR2_LIST[i])) {
|
||||
print_testing_failed();
|
||||
return TEST_FAILED;
|
||||
print_testing_error("A zero vector was not recongized");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Testing non-zero values:
|
||||
for (int i = 0; i < _TEST_FP32_NONZERO_VECTOR2_AMOUNT; i++) {
|
||||
if (bgc_vector2_is_zero_fp32(&_TEST_FP32_NONZERO_VECTOR2_LIST[i])) {
|
||||
print_testing_failed();
|
||||
return TEST_FAILED;
|
||||
print_testing_error("A non-zero vector was recongized as a zero vector");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
print_testing_success();
|
||||
|
||||
return TEST_SUCCESS;
|
||||
}
|
||||
|
||||
// ==================== FP64 ==================== //
|
||||
|
@ -73,40 +71,31 @@ static const BgcVector2FP64 _TEST_FP64_NONZERO_VECTOR2_LIST[] = {
|
|||
{ -1.25 * BGC_EPSYLON_FP64, -1.25 * BGC_EPSYLON_FP64 }
|
||||
};
|
||||
|
||||
int test_vector2_is_zero_fp64()
|
||||
void test_vector2_is_zero_fp64()
|
||||
{
|
||||
print_testing_name("bgc_vector2_is_zero_fp64");
|
||||
|
||||
// Testing zero values:
|
||||
for (int i = 0; i < _TEST_FP64_ZERO_VECTOR2_AMOUNT; i++) {
|
||||
if (!bgc_vector2_is_zero_fp64(&_TEST_FP64_ZERO_VECTOR2_LIST[i])) {
|
||||
print_testing_failed();
|
||||
return TEST_FAILED;
|
||||
print_testing_error("A zero vector was not recongized");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Testing non-zero values:
|
||||
for (int i = 0; i < _TEST_FP64_NONZERO_VECTOR2_AMOUNT; i++) {
|
||||
if (bgc_vector2_is_zero_fp64(&_TEST_FP64_NONZERO_VECTOR2_LIST[i])) {
|
||||
print_testing_failed();
|
||||
return TEST_FAILED;
|
||||
print_testing_error("A non-zero vector was recongized as a zero vector");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
print_testing_success();
|
||||
|
||||
return TEST_SUCCESS;
|
||||
}
|
||||
|
||||
int test_vector2_is_zero()
|
||||
void test_vector2_is_zero()
|
||||
{
|
||||
if (test_vector2_is_zero_fp32() != TEST_SUCCESS) {
|
||||
return TEST_FAILED;
|
||||
}
|
||||
|
||||
if (test_vector2_is_zero_fp64() != TEST_SUCCESS) {
|
||||
return TEST_FAILED;
|
||||
}
|
||||
|
||||
return TEST_SUCCESS;
|
||||
test_vector2_is_zero_fp32();
|
||||
test_vector2_is_zero_fp64();
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#ifndef _TEST_VECTOR2_IS_ZERO_H_
|
||||
#define _TEST_VECTOR2_IS_ZERO_H_
|
||||
|
||||
int test_vector2_is_zero_fp32();
|
||||
void test_vector2_is_zero_fp32();
|
||||
|
||||
int test_vector2_is_zero_fp64();
|
||||
void test_vector2_is_zero_fp64();
|
||||
|
||||
int test_vector2_is_zero();
|
||||
void test_vector2_is_zero();
|
||||
|
||||
#endif
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include "./../../helpers.h"
|
||||
|
||||
int test_vector2_reset_fp32()
|
||||
void test_vector2_reset_fp32()
|
||||
{
|
||||
BgcVector2FP32 vector;
|
||||
|
||||
|
@ -12,15 +12,13 @@ int test_vector2_reset_fp32()
|
|||
|
||||
if (vector.x1 != 0.0f || vector.x2 != 0.0f) {
|
||||
print_testing_failed();
|
||||
return TEST_FAILED;
|
||||
return;
|
||||
}
|
||||
|
||||
print_testing_success();
|
||||
|
||||
return TEST_SUCCESS;
|
||||
}
|
||||
|
||||
int test_vector2_reset_fp64()
|
||||
void test_vector2_reset_fp64()
|
||||
{
|
||||
BgcVector2FP64 vector;
|
||||
|
||||
|
@ -30,23 +28,14 @@ int test_vector2_reset_fp64()
|
|||
|
||||
if (vector.x1 != 0.0 || vector.x2 != 0.0) {
|
||||
print_testing_failed();
|
||||
return TEST_FAILED;
|
||||
return;
|
||||
}
|
||||
|
||||
print_testing_success();
|
||||
|
||||
return TEST_SUCCESS;
|
||||
}
|
||||
|
||||
int test_vector2_reset()
|
||||
void test_vector2_reset()
|
||||
{
|
||||
if (test_vector2_reset_fp32() != TEST_SUCCESS) {
|
||||
return TEST_FAILED;
|
||||
}
|
||||
|
||||
if (test_vector2_reset_fp64() != TEST_SUCCESS) {
|
||||
return TEST_FAILED;
|
||||
}
|
||||
|
||||
return TEST_SUCCESS;
|
||||
test_vector2_reset_fp32();
|
||||
test_vector2_reset_fp64();
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#ifndef _TEST_VECTOR2_RESET_H_
|
||||
#define _TEST_VECTOR2_RESET_H_
|
||||
|
||||
int test_vector2_reset_fp32();
|
||||
void test_vector2_reset_fp32();
|
||||
|
||||
int test_vector2_reset_fp64();
|
||||
void test_vector2_reset_fp64();
|
||||
|
||||
int test_vector2_reset();
|
||||
void test_vector2_reset();
|
||||
|
||||
#endif
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
// ==================== FP32 ==================== //
|
||||
|
||||
int test_vector2_set_values_fp32()
|
||||
void test_vector2_set_values_fp32()
|
||||
{
|
||||
BgcVector2FP32 vector;
|
||||
|
||||
|
@ -15,32 +15,30 @@ int test_vector2_set_values_fp32()
|
|||
bgc_vector2_set_values_fp32(1.0f, 2.0f, &vector);
|
||||
|
||||
if (vector.x1 != 1.0f || vector.x2 != 2.0f) {
|
||||
print_testing_failed();
|
||||
return TEST_FAILED;
|
||||
print_testing_error("First step failed");
|
||||
return;
|
||||
}
|
||||
|
||||
bgc_vector2_set_values_fp32(-3.0f, -5.0f, &vector);
|
||||
|
||||
if (vector.x1 != -3.0f || vector.x2 != -5.0f) {
|
||||
print_testing_failed();
|
||||
return TEST_FAILED;
|
||||
print_testing_error("Second step failed");
|
||||
return;
|
||||
}
|
||||
|
||||
bgc_vector2_set_values_fp32(-2.0f, 2.0f, &vector);
|
||||
|
||||
if (vector.x1 != -2.0f || vector.x2 != 2.0f) {
|
||||
print_testing_failed();
|
||||
return TEST_FAILED;
|
||||
print_testing_error("Third step failed");
|
||||
return;
|
||||
}
|
||||
|
||||
print_testing_success();
|
||||
|
||||
return TEST_SUCCESS;
|
||||
}
|
||||
|
||||
// ==================== FP64 ==================== //
|
||||
|
||||
int test_vector2_set_values_fp64()
|
||||
void test_vector2_set_values_fp64()
|
||||
{
|
||||
BgcVector2FP64 vector;
|
||||
|
||||
|
@ -50,38 +48,29 @@ int test_vector2_set_values_fp64()
|
|||
bgc_vector2_set_values_fp64(1.0, 2.0, &vector);
|
||||
|
||||
if (vector.x1 != 1.0 || vector.x2 != 2.0) {
|
||||
print_testing_failed();
|
||||
return TEST_FAILED;
|
||||
print_testing_error("First step failed");
|
||||
return;
|
||||
}
|
||||
|
||||
bgc_vector2_set_values_fp64(-3.0, -5.0, &vector);
|
||||
|
||||
if (vector.x1 != -3.0 || vector.x2 != -5.0) {
|
||||
print_testing_failed();
|
||||
return TEST_FAILED;
|
||||
print_testing_error("Second step failed");
|
||||
return;
|
||||
}
|
||||
|
||||
bgc_vector2_set_values_fp64(-2.0, 2.0, &vector);
|
||||
|
||||
if (vector.x1 != -2.0 || vector.x2 != 2.0) {
|
||||
print_testing_failed();
|
||||
return TEST_FAILED;
|
||||
print_testing_error("Third step failed");
|
||||
return;
|
||||
}
|
||||
|
||||
print_testing_success();
|
||||
|
||||
return TEST_SUCCESS;
|
||||
}
|
||||
|
||||
int test_vector2_set_values()
|
||||
void test_vector2_set_values()
|
||||
{
|
||||
if (test_vector2_set_values_fp32() != TEST_SUCCESS) {
|
||||
return TEST_FAILED;
|
||||
}
|
||||
|
||||
if (test_vector2_set_values_fp64() != TEST_SUCCESS) {
|
||||
return TEST_FAILED;
|
||||
}
|
||||
|
||||
return TEST_SUCCESS;
|
||||
test_vector2_set_values_fp32();
|
||||
test_vector2_set_values_fp64();
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#ifndef _TEST_VECTOR2_SET_VALUES_H_
|
||||
#define _TEST_VECTOR2_SET_VALUES_H_
|
||||
|
||||
int test_vector2_set_values_fp32();
|
||||
void test_vector2_set_values_fp32();
|
||||
|
||||
int test_vector2_set_values_fp64();
|
||||
void test_vector2_set_values_fp64();
|
||||
|
||||
int test_vector2_set_values();
|
||||
void test_vector2_set_values();
|
||||
|
||||
#endif
|
||||
|
|
|
@ -22,7 +22,7 @@ static const BgcVector2FP32 _TEST_FP32_VECTOR2_LIST2[] = {
|
|||
{ 1000.0f, -0.00025f }
|
||||
};
|
||||
|
||||
int test_vector2_swap_fp32()
|
||||
void test_vector2_swap_fp32()
|
||||
{
|
||||
BgcVector2FP32 vector1, vector2;
|
||||
|
||||
|
@ -39,13 +39,11 @@ int test_vector2_swap_fp32()
|
|||
vector2.x1 != _TEST_FP32_VECTOR2_LIST1[i].x1 ||
|
||||
vector2.x2 != _TEST_FP32_VECTOR2_LIST1[i].x2) {
|
||||
print_testing_failed();
|
||||
return TEST_FAILED;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
print_testing_success();
|
||||
|
||||
return TEST_SUCCESS;
|
||||
}
|
||||
|
||||
// ==================== FP64 ==================== //
|
||||
|
@ -66,7 +64,7 @@ static const BgcVector2FP64 _TEST_FP64_VECTOR2_LIST2[] = {
|
|||
{ 1000.0, -0.00025 }
|
||||
};
|
||||
|
||||
int test_vector2_swap_fp64()
|
||||
void test_vector2_swap_fp64()
|
||||
{
|
||||
BgcVector2FP64 vector1, vector2;
|
||||
|
||||
|
@ -83,24 +81,15 @@ int test_vector2_swap_fp64()
|
|||
vector2.x1 != _TEST_FP64_VECTOR2_LIST1[i].x1 ||
|
||||
vector2.x2 != _TEST_FP64_VECTOR2_LIST1[i].x2) {
|
||||
print_testing_failed();
|
||||
return TEST_FAILED;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
print_testing_success();
|
||||
|
||||
return TEST_SUCCESS;
|
||||
}
|
||||
|
||||
int test_vector2_swap()
|
||||
void test_vector2_swap()
|
||||
{
|
||||
if (test_vector2_swap_fp32() != TEST_SUCCESS) {
|
||||
return TEST_FAILED;
|
||||
}
|
||||
|
||||
if (test_vector2_swap_fp64() != TEST_SUCCESS) {
|
||||
return TEST_FAILED;
|
||||
}
|
||||
|
||||
return TEST_SUCCESS;
|
||||
test_vector2_swap_fp32();
|
||||
test_vector2_swap_fp64();
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#ifndef _TEST_VECTOR2_SWAP_H_
|
||||
#define _TEST_VECTOR2_SWAP_H_
|
||||
|
||||
int test_vector2_swap_fp32();
|
||||
void test_vector2_swap_fp32();
|
||||
|
||||
int test_vector2_swap_fp64();
|
||||
void test_vector2_swap_fp64();
|
||||
|
||||
int test_vector2_swap();
|
||||
void test_vector2_swap();
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue