- No setup - just #include
- Easy to use syntax
- Beautiful colored output that just works
- Easily expand for custom types
int factorial(n)
{
return n <= 1 ? 1 : factorial(n - 1) * n;
}
TEST("factorial")
{
EXPECT_INT(factorial(1), ==, 1);
EXPECT_INT(factorial(2), ==, 2);
EXPECT_INT(factorial(3), ==, 6);
EXPECT_INT(factorial(4), ==, 24);
EXPECT_INT(factorial(5), ==, 120);
}
- Download the
caught.h
andcaught.c
files from the latest release - In your test files, simply
#include "caught.h"
- Modify your compiler to compile your tests &
caught.c
- See Usage for how to begin!
Note: your code cannot include a
main
function as Caught needs to define it.
One file solution
If you only want to have one test file, you can put the contents of `caught.c` at the end of `caught.h` and just include that instead, without modifying your compiler to compile `caught.c`.This works because there cannot be duplicate definitions of main
.
From source
If you want, you can always download the full source and use that directly.However, you will need to make sure you include the actual path to caught.h
(#include "path/to/caught.h"
) and
update your compiler to compile all of Caught's files.
Please see the following docs: