mirror of
				https://github.com/catchorg/Catch2.git
				synced 2025-10-31 20:27:11 +01:00 
			
		
		
		
	Implemented more reporter methods and started to fill out Section impl
This commit is contained in:
		
							
								
								
									
										31
									
								
								Test/MiscTests.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								Test/MiscTests.cpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,31 @@ | ||||
| /* | ||||
|  *  MiscTests.cpp | ||||
|  *  Catch - Test | ||||
|  * | ||||
|  *  Created by Phil on 29/11/2010. | ||||
|  *  Copyright 2010 Two Blue Cubes Ltd. All rights reserved. | ||||
|  * | ||||
|  *  Distributed under the Boost Software License, Version 1.0. (See accompanying | ||||
|  *  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | ||||
|  * | ||||
|  */ | ||||
|  | ||||
| #include "../catch.hpp" | ||||
|  | ||||
| TEST_CASE( "succeeding/Misc/Sections", "random SECTION tests" ) | ||||
| { | ||||
|     int a = 1; | ||||
|     int b = 2; | ||||
|      | ||||
|     SECTION( "s1", "doesn't equal" ) | ||||
|     { | ||||
|         EXPECT( a != b ); | ||||
|         EXPECT( b != a ); | ||||
|     } | ||||
|      | ||||
|     SECTION( "s2", "not equal" ) | ||||
|     { | ||||
|         EXPECT_NOT( a == b); | ||||
|     } | ||||
|      | ||||
| } | ||||
| @@ -8,6 +8,7 @@ | ||||
|  | ||||
| /* Begin PBXBuildFile section */ | ||||
| 		4A3BFFB9128DCF06005609E3 /* TestMain.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A3BFFB8128DCF06005609E3 /* TestMain.cpp */; }; | ||||
| 		4AA7EA9212A438C7005A0B97 /* MiscTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4AA7EA9112A438C7005A0B97 /* MiscTests.cpp */; }; | ||||
| 		4AFC38CD12887D80003A0C29 /* ConditionTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4AFC38CC12887D80003A0C29 /* ConditionTests.cpp */; }; | ||||
| 		4AFC3A9912893C56003A0C29 /* ExceptionTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4AFC3A9812893C56003A0C29 /* ExceptionTests.cpp */; }; | ||||
| 		4AFC3AA912893E54003A0C29 /* MessageTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4AFC3AA812893E54003A0C29 /* MessageTests.cpp */; }; | ||||
| @@ -32,6 +33,8 @@ | ||||
| /* Begin PBXFileReference section */ | ||||
| 		4A3BFFB8128DCF06005609E3 /* TestMain.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TestMain.cpp; sourceTree = "<group>"; }; | ||||
| 		4A3BFFF0128DD23C005609E3 /* catch_runnerconfig.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = catch_runnerconfig.hpp; path = ../internal/catch_runnerconfig.hpp; sourceTree = SOURCE_ROOT; }; | ||||
| 		4AA7E968129FA1DF005A0B97 /* catch_reporter_junit.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = catch_reporter_junit.hpp; path = ../../../Lib/Catch/catch_reporter_junit.hpp; sourceTree = SOURCE_ROOT; }; | ||||
| 		4AA7EA9112A438C7005A0B97 /* MiscTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MiscTests.cpp; sourceTree = "<group>"; }; | ||||
| 		4AFC341512809A36003A0C29 /* catch_capture.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = catch_capture.hpp; path = ../internal/catch_capture.hpp; sourceTree = SOURCE_ROOT; }; | ||||
| 		4AFC341612809A36003A0C29 /* catch_common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = catch_common.h; path = ../internal/catch_common.h; sourceTree = SOURCE_ROOT; }; | ||||
| 		4AFC341712809A36003A0C29 /* catch_registry.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = catch_registry.hpp; path = ../internal/catch_registry.hpp; sourceTree = SOURCE_ROOT; }; | ||||
| @@ -80,13 +83,9 @@ | ||||
| 		08FB7795FE84155DC02AAC07 /* Source */ = { | ||||
| 			isa = PBXGroup; | ||||
| 			children = ( | ||||
| 				4AA7E96C129FA2A0005A0B97 /* Tests */, | ||||
| 				4A3BFFB8128DCF06005609E3 /* TestMain.cpp */, | ||||
| 				4AFC341312809A12003A0C29 /* Catch */, | ||||
| 				4AFC38CC12887D80003A0C29 /* ConditionTests.cpp */, | ||||
| 				4AFC3A9812893C56003A0C29 /* ExceptionTests.cpp */, | ||||
| 				4AFC3AA812893E54003A0C29 /* MessageTests.cpp */, | ||||
| 				4AFC3B0A12894114003A0C29 /* ClassTests.cpp */, | ||||
| 				4AFC3B661289C7E3003A0C29 /* TrickyTests.cpp */, | ||||
| 			); | ||||
| 			name = Source; | ||||
| 			sourceTree = "<group>"; | ||||
| @@ -99,14 +98,36 @@ | ||||
| 			name = Products; | ||||
| 			sourceTree = "<group>"; | ||||
| 		}; | ||||
| 		4AA7E96B129FA282005A0B97 /* Reporters */ = { | ||||
| 			isa = PBXGroup; | ||||
| 			children = ( | ||||
| 				4AFC341D12809A45003A0C29 /* catch_reporter_basic.hpp */, | ||||
| 				4AFC341E12809A45003A0C29 /* catch_reporter_xml.hpp */, | ||||
| 				4AA7E968129FA1DF005A0B97 /* catch_reporter_junit.hpp */, | ||||
| 			); | ||||
| 			name = Reporters; | ||||
| 			sourceTree = "<group>"; | ||||
| 		}; | ||||
| 		4AA7E96C129FA2A0005A0B97 /* Tests */ = { | ||||
| 			isa = PBXGroup; | ||||
| 			children = ( | ||||
| 				4AA7EA9112A438C7005A0B97 /* MiscTests.cpp */, | ||||
| 				4AFC38CC12887D80003A0C29 /* ConditionTests.cpp */, | ||||
| 				4AFC3A9812893C56003A0C29 /* ExceptionTests.cpp */, | ||||
| 				4AFC3AA812893E54003A0C29 /* MessageTests.cpp */, | ||||
| 				4AFC3B0A12894114003A0C29 /* ClassTests.cpp */, | ||||
| 				4AFC3B661289C7E3003A0C29 /* TrickyTests.cpp */, | ||||
| 			); | ||||
| 			name = Tests; | ||||
| 			sourceTree = "<group>"; | ||||
| 		}; | ||||
| 		4AFC341312809A12003A0C29 /* Catch */ = { | ||||
| 			isa = PBXGroup; | ||||
| 			children = ( | ||||
| 				4AFC342012809A45003A0C29 /* catch.hpp */, | ||||
| 				4AFC341C12809A45003A0C29 /* catch_default_main.hpp */, | ||||
| 				4AFC341D12809A45003A0C29 /* catch_reporter_basic.hpp */, | ||||
| 				4AFC341E12809A45003A0C29 /* catch_reporter_xml.hpp */, | ||||
| 				4AFC38161284B387003A0C29 /* catch_runner.hpp */, | ||||
| 				4AA7E96B129FA282005A0B97 /* Reporters */, | ||||
| 				4AFC341412809A1B003A0C29 /* Internal */, | ||||
| 			); | ||||
| 			name = Catch; | ||||
| @@ -187,6 +208,7 @@ | ||||
| 				4AFC3B0B12894114003A0C29 /* ClassTests.cpp in Sources */, | ||||
| 				4AFC3B671289C7E3003A0C29 /* TrickyTests.cpp in Sources */, | ||||
| 				4A3BFFB9128DCF06005609E3 /* TestMain.cpp in Sources */, | ||||
| 				4AA7EA9212A438C7005A0B97 /* MiscTests.cpp in Sources */, | ||||
| 			); | ||||
| 			runOnlyForDeploymentPostprocessing = 0; | ||||
| 		}; | ||||
|   | ||||
| @@ -14,6 +14,7 @@ | ||||
| #include "../catch_runner.hpp" | ||||
|  | ||||
| // This code runs the meta tests and verifies that the failing ones failed and the successful ones succeeded | ||||
| /* | ||||
| int main (int argc, char * const argv[]) | ||||
| { | ||||
|     using namespace Catch; | ||||
| @@ -22,17 +23,18 @@ int main (int argc, char * const argv[]) | ||||
|     if( argc > 1 && ( std::string( argv[1] ) == "-s" || std::string( argv[1] ) == "--success" ) ) | ||||
|         showAllResults = true; | ||||
|          | ||||
|     std::ostringstream ossSucceeding; | ||||
|     std::ostringstream ossFailing; | ||||
|  | ||||
|     ReporterConfig reporterConfig( ReporterConfig::Include::SuccessfulResults ); | ||||
|     BasicReporter reporter (reporterConfig ); | ||||
|     Runner runner; | ||||
|     runner.setReporter( &reporter ); | ||||
|  | ||||
|     std::ostringstream ossSucceeding; | ||||
|     Runner runner( &reporter ); | ||||
|  | ||||
|     reporterConfig.setStreamBuf( ossSucceeding.rdbuf() ); | ||||
|     runner.runMatching( "succeeding/*" ); | ||||
|     std::string succeedingResults = ossSucceeding.str(); | ||||
|      | ||||
|     std::ostringstream ossFailing; | ||||
|     reporterConfig.setStreamBuf( ossFailing.rdbuf() ); | ||||
|     runner.runMatching( "failing/*" ); | ||||
|     std::string failingResults = ossFailing.str(); | ||||
| @@ -56,10 +58,12 @@ int main (int argc, char * const argv[]) | ||||
|     { | ||||
|         std::cout << failingResults << "\n\n"; | ||||
|     } | ||||
|      | ||||
|  | ||||
|     if( result == 0 ) | ||||
|     { | ||||
|         std::cout << "All " << runner.getSuccessCount() + runner.getFailureCount() << " tests completed successfully" << std::endl; | ||||
|     } | ||||
|     return result; | ||||
| } | ||||
| */ | ||||
| #include "catch_default_main.hpp" | ||||
| @@ -41,3 +41,4 @@ TEST_CASE( "succeeding/Tricky/complex lhs", "Where the LHS is not a simple value | ||||
|     // This only captures part of the expression, but issues a warning about the rest | ||||
|     EXPECT( a == 2 || b == 2 ); | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Phil Nash
					Phil Nash