Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
CATCH - Small complete multi-file example.
// This tells Catch to provide a main() - only do this in one cpp file:
#define CATCH_CONFIG_MAIN
#include "catch.hpp"
#include "catch.hpp"
TEST_CASE( "Passing case", "[pass]" ) {
REQUIRE( 1 < 2 );
}
TEST_CASE( "Failing case", "[fail]" ) {
REQUIRE( 1 == 2 );
}
rem compile main once:
g++ -c main.cpp
rem subsequently use main's object file:
g++ -o test.exe main.o unit-1.cpp && test
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test is a Catch v1.1 b3 host application.
Run with -? for options
-------------------------------------------------------------------------------
Failing case
-------------------------------------------------------------------------------
unit-1.cpp:7
...............................................................................
unit-1.cpp:8: FAILED:
REQUIRE( 1 == 2 )
===============================================================================
test cases: 2 | 1 passed | 1 failed
assertions: 2 | 1 passed | 1 failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.