Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yshui/test.h
Header only C unit testing framework
https://github.com/yshui/test.h
c header-only unit-test unit-testing unit-testing-framework
Last synced: 7 days ago
JSON representation
Header only C unit testing framework
- Host: GitHub
- URL: https://github.com/yshui/test.h
- Owner: yshui
- Created: 2019-03-12T22:04:24.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-02-14T22:43:39.000Z (9 months ago)
- Last Synced: 2024-02-15T17:41:27.897Z (9 months ago)
- Topics: c, header-only, unit-test, unit-testing, unit-testing-framework
- Language: C
- Homepage:
- Size: 21.5 KB
- Stars: 6
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
test.h
======A very simple, light weight, header only C unit test framework.
# Features
* Easy to use, no dependencies, no setup needed.
* Keep test cases close to the code they test.
* Automatic registration of the test cases.# Usage
## SetupJust include the header
```c
#include "test.h"
```## Defining test cases
```c
TEST_CASE(test_case_name) {
// Your code here
// ...
TEST_EQUAL(1, 0); // Fail
}
```## Run the test cases
Build your program with `-DUNIT_TEST`, then run your program with `./program --unittest`.
# Hooks
If you define a function `test_h_unittest_setup`, it will be called before any test cases are run.