Compare commits

..

2 Commits

Author SHA1 Message Date
0c6f39c956 Added a README 2025-09-28 17:51:10 +05:30
285c736b6c Added a simple example file 2025-09-28 13:18:10 +05:30
2 changed files with 108 additions and 0 deletions

76
README.md Normal file
View 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
View 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()