Last active
September 6, 2017 01:43
-
-
Save martinmoene/c4240791bfd076c87e45 to your computer and use it in GitHub Desktop.
CATCH - Small complete multi-file example.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This tells Catch to provide a main() - only do this in one cpp file: | |
#define CATCH_CONFIG_MAIN | |
#include "catch.hpp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "catch.hpp" | |
TEST_CASE( "Passing case", "[pass]" ) { | |
REQUIRE( 1 < 2 ); | |
} | |
TEST_CASE( "Failing case", "[fail]" ) { | |
REQUIRE( 1 == 2 ); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
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