Compare commits
2 Commits
1bd017adfc
...
v0.0.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
0c6f39c956
|
|||
|
285c736b6c
|
76
README.md
Normal file
76
README.md
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
# test.h
|
||||||
|
|
||||||
|
A simple header file to get test statistics.
|
||||||
|
|
||||||
|
|
||||||
|
> Currently under development things might change without notice
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
Here is a simple simple example for `test.h`
|
||||||
|
|
||||||
|
```c
|
||||||
|
// sample_test.c
|
||||||
|
|
||||||
|
#include "test.h"
|
||||||
|
|
||||||
|
TEST(sample1, {
|
||||||
|
ASSERT(1 == 1, "");
|
||||||
|
})
|
||||||
|
|
||||||
|
TEST_INIT({})
|
||||||
|
```
|
||||||
|
|
||||||
|
You can compile and rum this test file, and will get an output like this.
|
||||||
|
|
||||||
|
```console
|
||||||
|
=========================================================================
|
||||||
|
TEST doc.c
|
||||||
|
|
||||||
|
test_sample1
|
||||||
|
(1/1) passed (0) failed
|
||||||
|
|
||||||
|
PASSED - (1/1) passed (0) failed
|
||||||
|
=========================================================================
|
||||||
|
```
|
||||||
|
|
||||||
|
An example with two tests.
|
||||||
|
|
||||||
|
```c
|
||||||
|
#include "test.h"
|
||||||
|
|
||||||
|
TEST(sample1, {
|
||||||
|
ASSERT(1 == 1, "");
|
||||||
|
})
|
||||||
|
|
||||||
|
TEST(sample2, {
|
||||||
|
ASSERT(1 == 1, "");
|
||||||
|
ASSERT(1 == 0, "This assertion will fail");
|
||||||
|
})
|
||||||
|
|
||||||
|
TEST_INIT({})
|
||||||
|
```
|
||||||
|
|
||||||
|
```console
|
||||||
|
=========================================================================
|
||||||
|
TEST doc.c
|
||||||
|
|
||||||
|
test_sample1
|
||||||
|
(1/1) passed (0) failed
|
||||||
|
|
||||||
|
test_sample2
|
||||||
|
assertion failed (l.no - 9) [1 == 0] - This assertion will fail
|
||||||
|
(1/2) passed (1) failed
|
||||||
|
|
||||||
|
FAILED - (1/2) passed (1) failed
|
||||||
|
=========================================================================
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
To know about all the macros that you can use, check the [examples](./examples/) folder.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
If you have any issues or want to discuss, [Join my Discord](https://discord.gg/BxMbWzZe2Z)
|
||||||
|
|
||||||
|
## Bye....
|
||||||
32
examples/basic.c
Normal file
32
examples/basic.c
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
// #define MAX_TEST_FUNCS 0
|
||||||
|
#include "test.h"
|
||||||
|
|
||||||
|
BEFORE({
|
||||||
|
printf("run before each test.\n");
|
||||||
|
})
|
||||||
|
|
||||||
|
AFTER({
|
||||||
|
printf("runs after each test\n");
|
||||||
|
})
|
||||||
|
|
||||||
|
SETUP({
|
||||||
|
printf("runs once at the start\n");
|
||||||
|
})
|
||||||
|
|
||||||
|
TEARDOWN({
|
||||||
|
printf("runs once at the end\n");
|
||||||
|
})
|
||||||
|
|
||||||
|
TEST(simple_test, {
|
||||||
|
ASSERT(1 == 1, "");
|
||||||
|
// ASSERT(0 == 1, "This assertion will fail");
|
||||||
|
})
|
||||||
|
|
||||||
|
TEST(simple_test_2, {
|
||||||
|
ASSERT(1 == 1, "");
|
||||||
|
ASSERT(0 == 1, "This assertion will fail");
|
||||||
|
})
|
||||||
|
|
||||||
|
TEST_INIT()
|
||||||
Reference in New Issue
Block a user