Skip to content
Snippets Groups Projects
user avatar
Jake Drahos authored
This reverts commit bcd4f7e7.

Yes, this is a revert-revert. We should suspend Brendan's git license pending
completion of a remedial course and 20 hours community service.
bcf65b52
History

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 ints 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.