https://github.com/rubenvannieuwpoort/c_unit_tests
Feels a bit more in line with the spirit of C (small language, few dependencies).
https://github.com/rubenvannieuwpoort/c_unit_tests
Feels a bit more in line with the spirit of C (small language, few dependencies).
This implementation only works with gcc though probably (it uses the automatic __start_SECTION and __stop_SECTION that gcc generates but clang doesn't seem to... there are likely hacks to make this work anyway though).
In principle, this approach allows interspersing your tests throughout a shared library instead of all in one file (though in that case you wouldn't want the testing function to be called main and you would need a separate driver program for test).
You don't need malloc if using local variables either, which is helpful when your target doesn't have malloc or when debugging memory problems on targets that do. It's nice to know the test framework cannot be leaking or use-after-free anything.