I'm trying to create a unit test file with Catch but following the instructions on the website doesn't seem to work. If I add only the implicit main clang is not able to build the test complaining a main function is missing:
#define CATCH_CONFIG_RUNNER
#include "../lib/catch.hpp"
TEST_CASE("Test Something", "[Test it]") {
REQUIRE(true);
REQUIRE(false);
}
[...]
Undefined symbols for architecture x86_64:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [tests/unit/tests] Error 1
make[1]: *** [tests/unit/CMakeFiles/tests.dir/all] Error 2
make: *** [all] Error 2
If I add an explicit main as defined in the Catch website clang has no problems building the binary:
#define CATCH_CONFIG_RUNNER
#include "../lib/catch.hpp"
TEST_CASE("Test Something", "[Test it]") {
REQUIRE(true);
REQUIRE(false);
}
int main( int argc, char* const argv[] )
{
// global setup...
int result = Catch::Session().run( argc, argv );
// global clean-up...
return result;
}
Aucun commentaire:
Enregistrer un commentaire