Repository navigation
Expand file tree
/
Copy pathjtn002.h
More file actions
46 lines (39 loc) · 1.58 KB
/
Copy pathjtn002.h
File metadata and controls
46 lines (39 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/* This is the original code written by John Brewer when he described
his idea for a mininal C unit test framework that uses no memory
allocation and should "work fine under almost any circumstance" and
which could be used to do unit testing in a constrained environment such as
an embedded system written in C such as a BIOS, EEPROM, etc.
Link: https://jera.com/techinfo/jtns/jtn002
You may use the code in his tech note for any purpose, with the understanding
that it comes with NO WARRANTY.
*/
#ifndef JTN002_H
#define JTN002_H
/**
* Macro to silence unused parameter warnings.
*
* This macro is used to explicitly mark parameters as intentionally unused.
* It works by casting the parameter to void, which is a no-op but tells the
* compiler we're aware the parameter is unused.
*
* Usage:
* void function(int used, int unused) {
* UNUSED(unused); // Silence warning about unused parameter
* printf("%d\n", used);
* }
*
* Benefits:
* - Works with any C compiler
* - Can be used with function pointers
* - Can be used anywhere in the function body
* - Makes intent clear to other developers
* - Can be used for unused variables too
*/
#define UNUSED(x) ((void)(x))
#define mu_assert(message, test) do { if (!(test)) return message; } while (0)
#define mu_run_test(test) do { char *message = test(); tests_run++; \
if (message) return message; } while (0)
#define mu_run_suite(suite) do { char *message = suite(); tests_run++; \
if (message) return message; } while (0)
extern int tests_run;
#endif