Basic Testing Suite in C
This test suite helps you run tests. It handles the result of every test whether it be a success, failure, or segfault, and keeps running until all tests have been executed. It then gives a summary of the test results.
To use, just write your tests using functions that return int
s to indicate
failure. 1 means failure. 0 means success.
Then in your main function for your tests, pass these functions to the test()
function along with a name you want included in the test report.
int main() {
test(test_func, "this test will pass!");
test(another_func, "this one might fail...");
...
Then at the end of your main function, call the test_summary()
function, and
return its return value from your main function.
int main() {
...
return test_summary();
}
An example.c
file is included for reference.