Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stavshamir/test_utils
A simple unit testing framework for C99
https://github.com/stavshamir/test_utils
c c99 unit-test unit-testing unit-testing-framework unittest unittesting unittests
Last synced: 3 days ago
JSON representation
A simple unit testing framework for C99
- Host: GitHub
- URL: https://github.com/stavshamir/test_utils
- Owner: stavshamir
- License: mit
- Created: 2018-09-26T08:03:19.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2018-09-26T08:21:03.000Z (about 6 years ago)
- Last Synced: 2024-10-10T05:38:05.866Z (27 days ago)
- Topics: c, c99, unit-test, unit-testing, unit-testing-framework, unittest, unittesting, unittests
- Language: C
- Homepage:
- Size: 3.91 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# test_utils
A simple unit testing framework for C99.## Usage
Clone and run the following command:```bash
$ source test_utils.sh
```
This will create a skeleton for your unit test file with the name test_filename.c:```C
#include#include "test_filename.h"
void test_foo();
/**********************************************************************************************************************/
int main() {
test_fn_t tests[] = {
test_foo
};RUN_TESTS(tests);
return 0;
}/**********************************************************************************************************************/
void test_foo() {
PRINT_TEST_HEADER;FAIL_TEST();
}
```In order to add a test function, do the following:
1. Declare it above the main function
2. Add the unit test function name to the tests array in the main function
3. Implement the function, and optionally (but recommended) add the PRINT_TEST_HEADER macro as the first statment**All unit test functions must be void and receive no parameters.**
Look at test_utils.h to see the available assertions (feel free to open an issue to add more assertions), and look at the test_example.c file for some more examples.