7a809d7 |
Jamozed |
2020-11-18 22:32:50 |
0
|
// unit.h |
7a809d7 |
Jamozed |
2020-11-18 22:32:50 |
1
|
// Unit testing library |
7a809d7 |
Jamozed |
2020-11-18 22:32:50 |
2
|
// Copyright (C) 2019, Jakob Wakeling |
7f427d9 |
Jamozed |
2022-03-06 12:55:13 |
3
|
// MIT Licence |
b9d4a23 |
Jamozed |
2021-01-26 13:11:04 |
4
|
|
7a809d7 |
Jamozed |
2020-11-18 22:32:50 |
5
|
#ifndef OMKOV_UNIT_H_YNUUN45Z |
7a809d7 |
Jamozed |
2020-11-18 22:32:50 |
6
|
#define OMKOV_UNIT_H_YNUUN45Z |
b9d4a23 |
Jamozed |
2021-01-26 13:11:04 |
7
|
|
b9d4a23 |
Jamozed |
2021-01-26 13:11:04 |
8
|
#include <stdio.h> |
7a809d7 |
Jamozed |
2020-11-18 22:32:50 |
9
|
|
7a809d7 |
Jamozed |
2020-11-18 22:32:50 |
10
|
#define PASS(message) printf("\033[1;32mPASS\033[0m %s\n", message) |
7a809d7 |
Jamozed |
2020-11-18 22:32:50 |
11
|
#define FAIL(message) printf("\033[1;31mFAIL\033[0m %s\n", message) |
7a809d7 |
Jamozed |
2020-11-18 22:32:50 |
12
|
|
7a809d7 |
Jamozed |
2020-11-18 22:32:50 |
13
|
#define ASSERT(message, condition) do { \ |
7a809d7 |
Jamozed |
2020-11-18 22:32:50 |
14
|
if(condition) { PASS(message); ++testspassed; } \ |
7a809d7 |
Jamozed |
2020-11-18 22:32:50 |
15
|
else { FAIL(message); ++testsfailed; } ++testsrun; \ |
7a809d7 |
Jamozed |
2020-11-18 22:32:50 |
16
|
} while (0) |
7a809d7 |
Jamozed |
2020-11-18 22:32:50 |
17
|
|
7a809d7 |
Jamozed |
2020-11-18 22:32:50 |
18
|
static int testsrun, testspassed, testsfailed; |
7a809d7 |
Jamozed |
2020-11-18 22:32:50 |
19
|
|
7a809d7 |
Jamozed |
2020-11-18 22:32:50 |
20
|
#endif // OMKOV_UNIT_H_YNUUN45Z |
|
|
|
21
|
|