I decided to try writing tests with Catch. I am using MinGW32 in Windows. I used the example file define here (which I reproduce below for convenience):
#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file
#include "catch.hpp"
unsigned int Factorial( unsigned int number ) {
return number <= 1 ? number : Factorial(number-1)*number;
}
TEST_CASE( "Factorials are computed", "[factorial]" ) {
REQUIRE( Factorial(1) == 1 );
REQUIRE( Factorial(2) == 2 );
REQUIRE( Factorial(3) == 6 );
REQUIRE( Factorial(10) == 3628800 );
}
I am running the following line to compile the program:
g++ -I./Catch/include/ -W -Wall -o run_tests main.cpp
I get absolutely no error, but when I run it I get a Segmentation Fault.
Following this, I tried supplying my own main()
function. Now the code looks like this:
#define CATCH_CONFIG_RUNNER
#include "catch.hpp"
int main()
{
return 0; // Yes, I'm not even using Catch and it still crashes
}
and I still get a Segmentation Fault.
Is this some incompatibility with MinGW? Has anyone also run into this issue?