#include "test.h"
#include "Utils/Common.h"
#include <assert.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
Go to the source code of this file.
|
test_t * | test_start (const char *name) |
|
void | test_end (test_t *t) |
|
void | test_assert (test_t *t, const char *pass_message, const char *fail_message, bool passes) |
|
void | test_assert_equal (test_t *t, const char *a_label, const char *b_label, float a, float b) |
|
void | test_assert_within_error (test_t *t, const char *actual_label, const char *expected_label, float actual, float expected) |
|
◆ test_assert()
void test_assert |
( |
test_t * |
t, |
|
|
const char * |
pass_message, |
|
|
const char * |
fail_message, |
|
|
bool |
passes |
|
) |
| |
Definition at line 33 of file test.c.
34 {
35 if (passes) {
37 } else {
39 }
40
42}
◆ test_assert_equal()
void test_assert_equal |
( |
test_t * |
t, |
|
|
const char * |
a_label, |
|
|
const char * |
b_label, |
|
|
float |
a, |
|
|
float |
b |
|
) |
| |
Definition at line 44 of file test.c.
45 {
47 if (passes) {
48 printf(
TEST_OK "%s %s = %s (%f = %f)\n", t->
name, a_label, b_label, a, b);
49 } else {
50 printf(
TEST_ERR "%s %s ≠ %s (%f ≠ %f)\n", t->
name, a_label, b_label, a, b);
51 }
52
54}
#define TEST_EQUAL_EPSILON
◆ test_assert_within_error()
void test_assert_within_error |
( |
test_t * |
t, |
|
|
const char * |
actual_label, |
|
|
const char * |
expected_label, |
|
|
float |
actual, |
|
|
float |
expected |
|
) |
| |
Definition at line 56 of file test.c.
58 {
59 float percent_error = (actual - expected) / expected * 100;
61 if (passes) {
62 printf(
TEST_OK "%s %s ≈ %s (%f ≈ %f)\n", t->
name, actual_label,
63 expected_label, actual, expected);
64 } else {
65 printf(
TEST_ERR "%s %s ≠ %s (%f ≠ %f)\n", t->
name, actual_label,
66 expected_label, actual, expected);
67 }
68
70}
#define TEST_ERROR_DELTA_PERCENT
◆ test_end()
Definition at line 22 of file test.c.
22 {
25 } else {
27 }
28
29
30 free(t);
31}
◆ test_start()
test_t * test_start |
( |
const char * |
name | ) |
|
Definition at line 9 of file test.c.
9 {
11 assert(t != NULL);
12
13
16
18
19 return t;
20}