Упрощение тестов
This commit is contained in:
parent
fcf793c758
commit
7f242c4b63
71 changed files with 518 additions and 943 deletions
|
|
@ -1,4 +1,5 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "helpers.h"
|
||||
|
||||
|
|
@ -15,11 +16,17 @@ void print_testing_name(const char * name)
|
|||
|
||||
void print_testing_success()
|
||||
{
|
||||
puts("[ Success ]\n");
|
||||
puts("[ \x1b[32mSuccess\x1b[0m ]");
|
||||
}
|
||||
|
||||
void print_testing_failed(const char* message)
|
||||
void print_testing_error(const char * message)
|
||||
{
|
||||
printf("[ Failed: %s ]\n", message);
|
||||
printf("[ \x1b[31mFailed\x1b[0m: %s ]\n", message);
|
||||
exit(TEST_FAILED);
|
||||
}
|
||||
|
||||
void print_testing_failed()
|
||||
{
|
||||
puts("[ \x1b[31mFailed\x1b[0m ]");
|
||||
exit(TEST_FAILED);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,15 +3,53 @@
|
|||
|
||||
#include <basic-geometry.h>
|
||||
|
||||
#define TEST_SUCCESS 0
|
||||
#define TEST_SUCCES 0
|
||||
#define TEST_FAILED 1
|
||||
|
||||
// =================== Number =================== //
|
||||
|
||||
typedef struct {
|
||||
float number1, number2;
|
||||
} TestNumberPairFP32;
|
||||
|
||||
typedef struct {
|
||||
double number1, number2;
|
||||
} TestNumberPairFP64;
|
||||
|
||||
// ================== Vector2 =================== //
|
||||
|
||||
// ================== Vector3 =================== //
|
||||
|
||||
// ================= Quaternion ================= //
|
||||
|
||||
// =================== Versor =================== //
|
||||
|
||||
typedef struct {
|
||||
BgcVersorFP32 first, second;
|
||||
} TestVersorPairFP32;
|
||||
|
||||
typedef struct {
|
||||
BgcVersorFP64 first, second;
|
||||
} TestVersorPairFP64;
|
||||
|
||||
typedef struct {
|
||||
BgcVersorFP32 first, second, result;
|
||||
} TestVersorTripletFP32;
|
||||
|
||||
typedef struct {
|
||||
BgcVersorFP64 first, second, result;
|
||||
} TestVersorTripletFP64;
|
||||
|
||||
// ================= Functions ================== //
|
||||
|
||||
void print_testing_section(const char * name);
|
||||
|
||||
void print_testing_name(const char * name);
|
||||
|
||||
void print_testing_success();
|
||||
|
||||
void print_testing_failed(const char* message);
|
||||
void print_testing_error(const char * message);
|
||||
|
||||
void print_testing_failed();
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -12,10 +12,14 @@
|
|||
int main()
|
||||
{
|
||||
test_utilities();
|
||||
|
||||
test_vector2();
|
||||
|
||||
test_vector3();
|
||||
|
||||
test_quaternion();
|
||||
|
||||
test_versor();
|
||||
|
||||
return TEST_SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,36 +1,14 @@
|
|||
#include "quaternion.h"
|
||||
|
||||
int test_quaternion()
|
||||
void test_quaternion()
|
||||
{
|
||||
print_testing_section("BGC Quaternion");
|
||||
|
||||
if (test_quaternion_reset() != TEST_SUCCESS) {
|
||||
return TEST_FAILED;
|
||||
}
|
||||
|
||||
if (test_quaternion_set_to_identity() != TEST_SUCCESS) {
|
||||
return TEST_FAILED;
|
||||
}
|
||||
|
||||
if (test_quaternion_set_values() != TEST_SUCCESS) {
|
||||
return TEST_FAILED;
|
||||
}
|
||||
|
||||
if (test_quaternion_copy() != TEST_SUCCESS) {
|
||||
return TEST_FAILED;
|
||||
}
|
||||
|
||||
if (test_quaternion_swap() != TEST_SUCCESS) {
|
||||
return TEST_FAILED;
|
||||
}
|
||||
|
||||
if (test_quaternion_is_zero() != TEST_SUCCESS) {
|
||||
return TEST_FAILED;
|
||||
}
|
||||
|
||||
if (test_quaternion_is_unit() != TEST_SUCCESS) {
|
||||
return TEST_FAILED;
|
||||
}
|
||||
|
||||
return TEST_SUCCESS;
|
||||
test_quaternion_reset();
|
||||
test_quaternion_set_to_identity();
|
||||
test_quaternion_set_values();
|
||||
test_quaternion_copy();
|
||||
test_quaternion_swap();
|
||||
test_quaternion_is_zero();
|
||||
test_quaternion_is_unit();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,6 @@
|
|||
#include "./quaternion/quaternion_is_zero.h"
|
||||
#include "./quaternion/quaternion_is_unit.h"
|
||||
|
||||
int test_quaternion();
|
||||
void test_quaternion();
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ static const BgcQuaternionFP32 _TEST_FP32_QUATERNION_LIST[] = {
|
|||
{ 0.001f, -100.0f, 100.0f, -0.001f }
|
||||
};
|
||||
|
||||
int test_quaternion_copy_fp32()
|
||||
void test_quaternion_copy_fp32()
|
||||
{
|
||||
BgcQuaternionFP32 vector;
|
||||
|
||||
|
|
@ -29,13 +29,11 @@ int test_quaternion_copy_fp32()
|
|||
vector.x2 != _TEST_FP32_QUATERNION_LIST[i].x2 ||
|
||||
vector.x3 != _TEST_FP32_QUATERNION_LIST[i].x3) {
|
||||
print_testing_failed();
|
||||
return TEST_FAILED;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
print_testing_success();
|
||||
|
||||