https://github.com/adwaith-rajesh/qd_tools
some Quick and Dirty tools for developing in C
https://github.com/adwaith-rajesh/qd_tools
Last synced: 9 months ago
JSON representation
some Quick and Dirty tools for developing in C
- Host: GitHub
- URL: https://github.com/adwaith-rajesh/qd_tools
- Owner: Adwaith-Rajesh
- License: mit
- Created: 2023-07-30T07:33:45.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-07-31T13:01:54.000Z (almost 3 years ago)
- Last Synced: 2025-08-17T18:30:25.259Z (10 months ago)
- Language: C
- Size: 10.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# QD Tools
## Quick and Dirty tools for developing in C
---
#### WARNING
THE TOOLS PROVIDED HAVE NO GUARANTEE OF WORKING AND ARE MEANT TO BE USED WITH CAUTION. THE TOOLS ITSELF MAY BREAK.
Eg. YOUR TEST MAY FAIL BECAUSE THE TESTING TOOL IS NOT WORKING PROPERLY.
USE IT WITH CAUTION
## test.h
A simple testing "framework" for C
- Without fail reason
```c
// main_test.c
#include "test.h"
int main(void) {
TEST("A simple test block", {
ASSERT(1 == 1);
});
TEST("A failing block", {
ASSERT(2 == 3);
});
return 0;
}
```
- Compile and run
```console
$ gcc main_test.c -o main_test && ./main_test
[ PASS ]: A simple test block
[FAILED]: main_test.c:8 A failing block
```
> It prints the filename and the line no. of the failed TEST.
- With fail reasons and test statistics
```c
// main_test.c
#define SHOW_FAIL_REASON
#define SHOW_TEST_STATISTICS
#include "test.h"
int main(void) {
TEST("A simple test block", {
ASSERT(1 == 1);
});
TEST("A failing block", {
ASSERT(2 == 3);
});
TEST("Explicit Fail", {
ASSERT_FAIL();
});
TEST("Explicit Fail with Reason", { // requires SHOW_FAIL_REASON
ASSERT_FAIL_W_REASON("Because it was wrong")
});
// test_end_call() requires SHOW_TEST_STATISTICS and
// sets the exit code to EXIT_FAILURE if failed test exists
return test_end_call();
}
```
- Compile and run
```console
$ gcc main_test.c -o main_test && ./main_test
[ PASS ]: A simple test block
[FAILED]: main_test.c:10 A failing block -- 2 == 3
[FAILED]: main_test.c:14 Explicit Fail --
[FAILED]: main_test.c:18 Explicit Fail with Reason -- Because it was wrong
Total: 4 -- Passed: 1 -- Failed: 3
$ echo $?
1
```
---
## debug.h
Docs on the way