diff options
| author | Phil Nash | 2015-03-27 17:54:45 +0000 |
|---|---|---|
| committer | Phil Nash | 2015-03-27 17:54:45 +0000 |
| commit | d9fbc620930136ef9250269d73aa1d1a5f76da31 (patch) | |
| tree | 891b77187e1168778f11c7a4b7b1d64de548e714 /projects/SelfTest/TestMain.cpp | |
| parent | b9ec8a10edd66009c2e79af9a7f789b6547180bc (diff) | |
| parent | 0ae7578028fe30135015ace15a97009a547f2d46 (diff) | |
| download | catch3-d9fbc620930136ef9250269d73aa1d1a5f76da31.tar.gz | |
Merged from develop
Diffstat (limited to 'projects/SelfTest/TestMain.cpp')
| -rw-r--r-- | projects/SelfTest/TestMain.cpp | 58 |
1 files changed, 54 insertions, 4 deletions
diff --git a/projects/SelfTest/TestMain.cpp b/projects/SelfTest/TestMain.cpp index edc8aa1f..7cb7ca42 100644 --- a/projects/SelfTest/TestMain.cpp +++ b/projects/SelfTest/TestMain.cpp @@ -8,6 +8,7 @@ #define CATCH_CONFIG_MAIN #include "catch.hpp" +#include "reporters/catch_reporter_teamcity.hpp" // Some example tag aliases CATCH_REGISTER_TAG_ALIAS( "[@nhf]", "[failing]~[.]" ) @@ -181,7 +182,23 @@ TEST_CASE( "Process can be configured on command line", "[config][command-line]" CHECK( config.shouldDebugBreak ); CHECK( config.noThrow == true ); } - } + } + + SECTION( "force-colour", "") { + SECTION( "--force-colour", "" ) { + const char* argv[] = { "test", "--force-colour" }; + CHECK_NOTHROW( parseIntoConfig( argv, config ) ); + + REQUIRE( config.forceColour ); + } + + SECTION( "without --force-colour", "" ) { + const char* argv[] = { "test" }; + CHECK_NOTHROW( parseIntoConfig( argv, config ) ); + + REQUIRE( !config.forceColour ); + } + } } @@ -347,22 +364,55 @@ private: std::vector<ColourIndex> colours; }; +TEST_CASE( "replaceInPlace", "" ) { + std::string letters = "abcdefcg"; + SECTION( "replace single char" ) { + CHECK( replaceInPlace( letters, "b", "z" ) ); + CHECK( letters == "azcdefcg" ); + } + SECTION( "replace two chars" ) { + CHECK( replaceInPlace( letters, "c", "z" ) ); + CHECK( letters == "abzdefzg" ); + } + SECTION( "replace first char" ) { + CHECK( replaceInPlace( letters, "a", "z" ) ); + CHECK( letters == "zbcdefcg" ); + } + SECTION( "replace last char" ) { + CHECK( replaceInPlace( letters, "g", "z" ) ); + CHECK( letters == "abcdefcz" ); + } + SECTION( "replace all chars" ) { + CHECK( replaceInPlace( letters, letters, "replaced" ) ); + CHECK( letters == "replaced" ); + } + SECTION( "replace no chars" ) { + CHECK_FALSE( replaceInPlace( letters, "x", "z" ) ); + CHECK( letters == letters ); + } + SECTION( "escape '" ) { + std::string s = "didn't"; + CHECK( replaceInPlace( s, "'", "|'" ) ); + CHECK( s == "didn|'t" ); + } +} + // !TBD: This will be folded into Text class -TEST_CASE( "Strings can be rendered with colour", "[colour][.]" ) { +TEST_CASE( "Strings can be rendered with colour", "[.colour]" ) { { ColourString cs( "hello" ); cs .addColour( Colour::Red, 0 ) .addColour( Colour::Green, -1 ); - std::cout << cs << std::endl; + Catch::cout() << cs << std::endl; } { ColourString cs( "hello" ); cs .addColour( Colour::Blue, 1, -2 ); - std::cout << cs << std::endl; + Catch::cout() << cs << std::endl; } } |