Skip to content

Instantly share code, notes, and snippets.

@martinmoene
Last active September 6, 2017 01:43
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martinmoene/c4240791bfd076c87e45 to your computer and use it in GitHub Desktop.
Save martinmoene/c4240791bfd076c87e45 to your computer and use it in GitHub Desktop.
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