As a new year starts I generally have some long awaited cleanup to do on my C/C++ single header libraries. Maybe I need to update the CI scripts because they are out of date, maybe I have some features I want to add, or maybe I want to test more things.
For those that do not know I have six main libraries that I maintain that are single header and work across C/C++:
- 🧪 utest.h - a single header unit testing framework that supports C and C++.
- ⏱️ ubench.h - a single header unit benchmarking framework that supports C and C++.
- 📚 utf8.h - a single header UTF-8 string implementation supporting header for C and C++.
- 🗄️ json.h - a single header JSON parsing and writing header that supports JSON5 and simplified-JSON, and works with C and C++.
- 🐜 subprocess.h - a single header process spawning, joining, and interacting with library for C and C++.
- #️⃣ hashmap.h - a single header hashmap implementation for C and C++.
So what have I done in this new year cleanup?
In my unit testing framework utest.h I’ve:
- Added support for building with MinGW. A user of my other library subprocess.h submitted a PR that adds MinGW support, and in that PR they had modified utest.h to also support MinGW. But with that code not merged into the main utest.h repository, any updates to the library would override the changes. So I added testing and support for MinGW in utest.h.
- Added Clang sanitizer support for utest.h to ensure I’m being as safe as I can be.
- A user had previously added support for exception handling in tests and I suddenly realised that this support assumed all users would be compiling with exceptions enabled in their code. So I made sure my library would work if the user had disabled exceptions explicitly.
- I also added support for comparing enum classes for C++11 and onwards. I used this as an opportunity to add explicit testing for C++14 and C++17 too.
In my benchmarking framework ubench.h I’ve added sanitizers. No bugs in the code were found, but its nice to have extra checks for future changes.
In my UTF-8 string header utf8.h I’ve added sanitizers.
I found one wee bug in my unit tests where a
constexpr test was going out of
In my single header hashmap library hashmap.h I’ve also added sanitizers. No bugs in the code were found.