A enough simple and cross-platform unit test framework for C++, CuteX for short. It is just a very small header file that uses the C/C++ peculiar features (template specialization, recursive and variadic, ...) to simplify testing work.
Only one assertion template, zero learning time.
You just write a test unit, no matter where, and the compiler does the rest for you.
It is designed to let users focus on writing test scenarios. Each test unit is a native struct or class, so there are no "weird" test fixtures. The only assertion tool is normal method, so avoids using macros in a unit test.
- Only a header file, only use C++ compiler.
- Any member method or function can be tested.
- No concept to learn, no heavy documentation, just one assertion tool.
- No config, no test macro, no graphic interface, no extrernal library.
- Can run a test unit or group by wildcard name.
- Extended easily and integrated easily into an application.
template <class A>
static void _assert(const A& expression, const char* shouldbe=0, ...);
The below code snippet demonstrates the least amount of code required to write an executable test:
/* Add this header file into your project */
#include "CppUnitTestExpress.h"
/* Write a test unit given a name. */
class TestMinimal : public Unit<TestMinimal>
{
void Test()
{
_assert(true,"Should be true.");
}
};
/* Run the unit test. */
int main(int argc, char* argv[])
{
return 0;
}
/* Display the result of test . */
SUCCESS : TestMinimal - 0s
----------------------------------------
Executed: 1 unit, 0s at 2025-01-12 20:30:47
Resulted: SUCCESS