Customer List
shortcut.h
1
/*----------------------------------------------------------
2
* HTBLA-Leonding
3
* ---------------------------------------------------------
4
* Title: shortcut
5
* Author: P. Bauer
6
* Date: November 03, 2010
7
* ----------------------------------------------------------
8
* Description:
9
* A simple unit testing frame work for C.
10
* ----------------------------------------------------------
11
*/
12
#ifndef ___SHORTCUT_H
13
#define ___SHORTCUT_H
14
15
#include <stdbool.h>
16
21
struct
TestCase
{
22
const
char
*name;
24
bool
success
;
25
27
void (*
test_function
)(
struct
TestCase
*tc);
28
};
29
33
const
char
* version();
34
38
char
* format_msg(
char
* format, ...);
39
49
void
assert_true(
bool
bool_expr,
struct
TestCase
*tc,
const
char
*msg,
50
const
char
* file,
int
line);
51
57
void
assert_false(
bool
bool_expr,
struct
TestCase
* tc,
const
char
* msg,
58
const
char
* file,
int
line);
59
72
void
assert_equals(
int
expected,
int
actual,
struct
TestCase
* tc,
73
const
char
* msg,
const
char
* file,
int
line);
74
void
assert_equals_str(
const
char
* expected,
char
* actual,
struct
TestCase
* tc,
75
const
char
* msg,
const
char
* file,
int
line);
76
void
assert_equals_f(
double
expected,
double
actual,
double
tolerance,
struct
TestCase
* tc,
77
const
char
* msg,
const
char
* file,
int
line);
78
81
int
get_test_count();
82
90
bool
add_test(
void
(*
test_function
)(
struct
TestCase
*tc),
const
char
*test_case_name);
91
92
void
run_tests();
93
94
#define TEST(testname) void testname(struct TestCase *tc)
95
96
#define MSG(format, ...) format_msg(format, ##__VA_ARGS__)
97
98
#define ASSERT_TRUE(condition, msg) assert_true(condition, tc, msg, __FILE__, __LINE__)
99
100
#define ASSERT_FALSE(condition, msg) assert_false(condition, tc, msg, __FILE__, __LINE__)
101
102
#define ASSERT_EQUALS(expected, actual) assert_equals(expected, actual, tc, "", __FILE__, __LINE__)
103
104
#define ASSERT_EQUALS_STR(expected, actual, msg) assert_equals_str(expected, actual, tc, msg, __FILE__, __LINE__)
105
106
#define ASSERT_EQUALS_TOLERANCE(expected, actual, tolerance) assert_equals_f(expected, actual, tolerance, tc, "", __FILE__, __LINE__)
107
108
#define ASSERT_EQUALS_TOLERANCE_STR(expected, actual, tolerance, msg) assert_equals_f(expected, actual, tolerance, tc, msg, __FILE__, __LINE__)
109
110
#define ADD_TEST(testfunction) add_test(testfunction, #testfunction)
111
112
#endif
TestCase
Definition:
shortcut.h:21
TestCase::test_function
void(* test_function)(struct TestCase *tc)
Definition:
shortcut.h:27
TestCase::success
bool success
Definition:
shortcut.h:24
Generated on Mon Dec 9 2024 23:15:48 for Customer List by
1.8.18