Show HN: Writing modern C unit tests with Criterion
github.com
github.com
I made this unit testing framework out of frustrations I had (and still have) with other C frameworks like CUnit or Check.
I wanted to make something much more simple, yet as powerful, and I think (and hope) I nailed it pretty much after a few months of work.
If you have any questions or suggestions, feel free to ask :)
It also uses some very platform specific stuff, so windows & os x are out, too.
Very well made nonetheless.
Good to see C test frameworks doing some innovative stuff!
(In case you mulled over using it.)
First, you'd have to wrap your header inclusions in `extern "C"` to disable mangling, then you would have to make sure you static_cast all your pointers where normally `void*` conversions would have done its job.
Furthermore, all interfaces relying on designated initializers and compound literals are broken unless you decide to compile in nonstandard GNU C++.
And there are more incompatibilities, such as using `static` or `const` in array parameter declarations or using VLA in macros which are not recognized by C++.
It's all about using the right tool for the right job, ultimately.
Otherwise, you can't (yet!) test if the code exits with a specific value nor simply redirect input/output, but I'll be sure to take these suggestions into account, thanks!
Both will be implemented quite soon.