diff --git a/Test/MiscTests.cpp b/Test/MiscTests.cpp new file mode 100644 index 00000000..ea004cc8 --- /dev/null +++ b/Test/MiscTests.cpp @@ -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); + } + +} diff --git a/Test/Test.xcodeproj/project.pbxproj b/Test/Test.xcodeproj/project.pbxproj new file mode 100644 index 00000000..0731e547 --- /dev/null +++ b/Test/Test.xcodeproj/project.pbxproj @@ -0,0 +1,293 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 45; + objects = { + +/* 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 */; }; + 4AFC3B0B12894114003A0C29 /* ClassTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4AFC3B0A12894114003A0C29 /* ClassTests.cpp */; }; + 4AFC3B671289C7E3003A0C29 /* TrickyTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4AFC3B661289C7E3003A0C29 /* TrickyTests.cpp */; }; + 8DD76F6A0486A84900D96B5E /* Test.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = C6859E8B029090EE04C91782 /* Test.1 */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 8DD76F690486A84900D96B5E /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 8; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + 8DD76F6A0486A84900D96B5E /* Test.1 in CopyFiles */, + ); + runOnlyForDeploymentPostprocessing = 1; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 4A3BFFB8128DCF06005609E3 /* TestMain.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TestMain.cpp; sourceTree = ""; }; + 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 = ""; }; + 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; }; + 4AFC341812809A36003A0C29 /* catch_reporter_registry.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = catch_reporter_registry.hpp; path = ../internal/catch_reporter_registry.hpp; sourceTree = SOURCE_ROOT; }; + 4AFC341912809A36003A0C29 /* catch_resultinfo.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = catch_resultinfo.hpp; path = ../internal/catch_resultinfo.hpp; sourceTree = SOURCE_ROOT; }; + 4AFC341A12809A36003A0C29 /* catch_runner_impl.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = catch_runner_impl.hpp; path = ../internal/catch_runner_impl.hpp; sourceTree = SOURCE_ROOT; }; + 4AFC341B12809A36003A0C29 /* catch_testcaseinfo.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = catch_testcaseinfo.hpp; path = ../internal/catch_testcaseinfo.hpp; sourceTree = SOURCE_ROOT; }; + 4AFC341C12809A45003A0C29 /* catch_default_main.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = catch_default_main.hpp; path = ../catch_default_main.hpp; sourceTree = SOURCE_ROOT; }; + 4AFC341D12809A45003A0C29 /* catch_reporter_basic.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = catch_reporter_basic.hpp; path = ../catch_reporter_basic.hpp; sourceTree = SOURCE_ROOT; }; + 4AFC341E12809A45003A0C29 /* catch_reporter_xml.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = catch_reporter_xml.hpp; path = ../catch_reporter_xml.hpp; sourceTree = SOURCE_ROOT; }; + 4AFC341F12809A45003A0C29 /* catch_list.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = catch_list.hpp; path = ../internal/catch_list.hpp; sourceTree = SOURCE_ROOT; }; + 4AFC342012809A45003A0C29 /* catch.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = catch.hpp; path = ../catch.hpp; sourceTree = SOURCE_ROOT; }; + 4AFC346412809D41003A0C29 /* catch_commandline.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = catch_commandline.hpp; path = ../internal/catch_commandline.hpp; sourceTree = SOURCE_ROOT; }; + 4AFC359B1281F00B003A0C29 /* catch_section.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = catch_section.hpp; path = ../internal/catch_section.hpp; sourceTree = SOURCE_ROOT; }; + 4AFC38161284B387003A0C29 /* catch_runner.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = catch_runner.hpp; path = ../catch_runner.hpp; sourceTree = SOURCE_ROOT; }; + 4AFC38CC12887D80003A0C29 /* ConditionTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ConditionTests.cpp; sourceTree = ""; }; + 4AFC3A9812893C56003A0C29 /* ExceptionTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ExceptionTests.cpp; sourceTree = ""; }; + 4AFC3AA812893E54003A0C29 /* MessageTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MessageTests.cpp; sourceTree = ""; }; + 4AFC3B0A12894114003A0C29 /* ClassTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ClassTests.cpp; sourceTree = ""; }; + 4AFC3B661289C7E3003A0C29 /* TrickyTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TrickyTests.cpp; sourceTree = ""; }; + 8DD76F6C0486A84900D96B5E /* Test */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = Test; sourceTree = BUILT_PRODUCTS_DIR; }; + C6859E8B029090EE04C91782 /* Test.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = Test.1; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 8DD76F660486A84900D96B5E /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 08FB7794FE84155DC02AAC07 /* Test */ = { + isa = PBXGroup; + children = ( + 08FB7795FE84155DC02AAC07 /* Source */, + C6859E8C029090F304C91782 /* Documentation */, + 1AB674ADFE9D54B511CA2CBB /* Products */, + ); + name = Test; + sourceTree = ""; + }; + 08FB7795FE84155DC02AAC07 /* Source */ = { + isa = PBXGroup; + children = ( + 4AA7E96C129FA2A0005A0B97 /* Tests */, + 4A3BFFB8128DCF06005609E3 /* TestMain.cpp */, + 4AFC341312809A12003A0C29 /* Catch */, + ); + name = Source; + sourceTree = ""; + }; + 1AB674ADFE9D54B511CA2CBB /* Products */ = { + isa = PBXGroup; + children = ( + 8DD76F6C0486A84900D96B5E /* Test */, + ); + name = Products; + sourceTree = ""; + }; + 4AA7E96B129FA282005A0B97 /* Reporters */ = { + isa = PBXGroup; + children = ( + 4AFC341D12809A45003A0C29 /* catch_reporter_basic.hpp */, + 4AFC341E12809A45003A0C29 /* catch_reporter_xml.hpp */, + 4AA7E968129FA1DF005A0B97 /* catch_reporter_junit.hpp */, + ); + name = Reporters; + sourceTree = ""; + }; + 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 = ""; + }; + 4AFC341312809A12003A0C29 /* Catch */ = { + isa = PBXGroup; + children = ( + 4AFC342012809A45003A0C29 /* catch.hpp */, + 4AFC341C12809A45003A0C29 /* catch_default_main.hpp */, + 4AFC38161284B387003A0C29 /* catch_runner.hpp */, + 4AA7E96B129FA282005A0B97 /* Reporters */, + 4AFC341412809A1B003A0C29 /* Internal */, + ); + name = Catch; + sourceTree = ""; + }; + 4AFC341412809A1B003A0C29 /* Internal */ = { + isa = PBXGroup; + children = ( + 4A3BFFF0128DD23C005609E3 /* catch_runnerconfig.hpp */, + 4AFC341F12809A45003A0C29 /* catch_list.hpp */, + 4AFC359B1281F00B003A0C29 /* catch_section.hpp */, + 4AFC346412809D41003A0C29 /* catch_commandline.hpp */, + 4AFC341512809A36003A0C29 /* catch_capture.hpp */, + 4AFC341612809A36003A0C29 /* catch_common.h */, + 4AFC341712809A36003A0C29 /* catch_registry.hpp */, + 4AFC341812809A36003A0C29 /* catch_reporter_registry.hpp */, + 4AFC341912809A36003A0C29 /* catch_resultinfo.hpp */, + 4AFC341A12809A36003A0C29 /* catch_runner_impl.hpp */, + 4AFC341B12809A36003A0C29 /* catch_testcaseinfo.hpp */, + ); + name = Internal; + sourceTree = ""; + }; + C6859E8C029090F304C91782 /* Documentation */ = { + isa = PBXGroup; + children = ( + C6859E8B029090EE04C91782 /* Test.1 */, + ); + name = Documentation; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 8DD76F620486A84900D96B5E /* Test */ = { + isa = PBXNativeTarget; + buildConfigurationList = 1DEB923108733DC60010E9CD /* Build configuration list for PBXNativeTarget "Test" */; + buildPhases = ( + 8DD76F640486A84900D96B5E /* Sources */, + 8DD76F660486A84900D96B5E /* Frameworks */, + 8DD76F690486A84900D96B5E /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Test; + productInstallPath = "$(HOME)/bin"; + productName = Test; + productReference = 8DD76F6C0486A84900D96B5E /* Test */; + productType = "com.apple.product-type.tool"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 08FB7793FE84155DC02AAC07 /* Project object */ = { + isa = PBXProject; + buildConfigurationList = 1DEB923508733DC60010E9CD /* Build configuration list for PBXProject "Test" */; + compatibilityVersion = "Xcode 3.1"; + hasScannedForEncodings = 1; + mainGroup = 08FB7794FE84155DC02AAC07 /* Test */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 8DD76F620486A84900D96B5E /* Test */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + 8DD76F640486A84900D96B5E /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 4AFC38CD12887D80003A0C29 /* ConditionTests.cpp in Sources */, + 4AFC3A9912893C56003A0C29 /* ExceptionTests.cpp in Sources */, + 4AFC3AA912893E54003A0C29 /* MessageTests.cpp in Sources */, + 4AFC3B0B12894114003A0C29 /* ClassTests.cpp in Sources */, + 4AFC3B671289C7E3003A0C29 /* TrickyTests.cpp in Sources */, + 4A3BFFB9128DCF06005609E3 /* TestMain.cpp in Sources */, + 4AA7EA9212A438C7005A0B97 /* MiscTests.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 1DEB923208733DC60010E9CD /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + COPY_PHASE_STRIP = NO; + GCC_DYNAMIC_NO_PIC = NO; + GCC_ENABLE_FIX_AND_CONTINUE = YES; + GCC_MODEL_TUNING = G5; + GCC_OPTIMIZATION_LEVEL = 0; + INSTALL_PATH = /usr/local/bin; + PRODUCT_NAME = Test; + }; + name = Debug; + }; + 1DEB923308733DC60010E9CD /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + GCC_MODEL_TUNING = G5; + INSTALL_PATH = /usr/local/bin; + PRODUCT_NAME = Test; + }; + name = Release; + }; + 1DEB923608733DC60010E9CD /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + ONLY_ACTIVE_ARCH = YES; + PREBINDING = NO; + SDKROOT = macosx10.6; + }; + name = Debug; + }; + 1DEB923708733DC60010E9CD /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + PREBINDING = NO; + SDKROOT = macosx10.6; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 1DEB923108733DC60010E9CD /* Build configuration list for PBXNativeTarget "Test" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1DEB923208733DC60010E9CD /* Debug */, + 1DEB923308733DC60010E9CD /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 1DEB923508733DC60010E9CD /* Build configuration list for PBXProject "Test" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1DEB923608733DC60010E9CD /* Debug */, + 1DEB923708733DC60010E9CD /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 08FB7793FE84155DC02AAC07 /* Project object */; +} diff --git a/Test/TestMain.cpp b/Test/TestMain.cpp index 1492fb7d..b2bf7f84 100644 --- a/Test/TestMain.cpp +++ b/Test/TestMain.cpp @@ -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,7 +58,7 @@ int main (int argc, char * const argv[]) { std::cout << failingResults << "\n\n"; } - + if( result == 0 ) { const size_t expectedTestCaseCount = 99; // !TBD factor this out @@ -73,3 +75,5 @@ int main (int argc, char * const argv[]) } return result; } +*/ +#include "catch_default_main.hpp" \ No newline at end of file diff --git a/Test/TrickyTests.cpp b/Test/TrickyTests.cpp index 120ca783..e12aa9af 100644 --- a/Test/TrickyTests.cpp +++ b/Test/TrickyTests.cpp @@ -60,4 +60,4 @@ TEST_CASE( "failing/Tricky/non streamable type", "A failing expression with a no CHECK( &o1 == &o2 ); CHECK( o1 == o2 ); -} \ No newline at end of file +} diff --git a/Test/Xcode/Test.xcodeproj/project.pbxproj b/Test/Xcode/Test.xcodeproj/project.pbxproj index 1002a432..e46c8035 100644 --- a/Test/Xcode/Test.xcodeproj/project.pbxproj +++ b/Test/Xcode/Test.xcodeproj/project.pbxproj @@ -7,12 +7,22 @@ objects = { /* Begin PBXBuildFile section */ +<<<<<<< HEAD:Test/Test.xcodeproj/project.pbxproj + 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 */; }; + 4AFC3B0B12894114003A0C29 /* ClassTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4AFC3B0A12894114003A0C29 /* ClassTests.cpp */; }; + 4AFC3B671289C7E3003A0C29 /* TrickyTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4AFC3B661289C7E3003A0C29 /* TrickyTests.cpp */; }; +======= 4A595364128E920B009DC1B9 /* ClassTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A59535F128E920B009DC1B9 /* ClassTests.cpp */; }; 4A595365128E920B009DC1B9 /* ConditionTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A595360128E920B009DC1B9 /* ConditionTests.cpp */; }; 4A595366128E920B009DC1B9 /* ExceptionTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A595361128E920B009DC1B9 /* ExceptionTests.cpp */; }; 4A595367128E920B009DC1B9 /* MessageTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A595362128E920B009DC1B9 /* MessageTests.cpp */; }; 4A595368128E920B009DC1B9 /* TrickyTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A595363128E920B009DC1B9 /* TrickyTests.cpp */; }; 4A59537A128E9354009DC1B9 /* TestMain.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A595379128E9354009DC1B9 /* TestMain.cpp */; }; +>>>>>>> 5f43a43662c8b9feca25aeccc79d1c7db664c9a0:Test/Xcode/Test.xcodeproj/project.pbxproj 8DD76F6A0486A84900D96B5E /* Test.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = C6859E8B029090EE04C91782 /* Test.1 */; }; /* End PBXBuildFile section */ @@ -30,6 +40,32 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ +<<<<<<< HEAD:Test/Test.xcodeproj/project.pbxproj + 4A3BFFB8128DCF06005609E3 /* TestMain.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TestMain.cpp; sourceTree = ""; }; + 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 = ""; }; + 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; }; + 4AFC341812809A36003A0C29 /* catch_reporter_registry.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = catch_reporter_registry.hpp; path = ../internal/catch_reporter_registry.hpp; sourceTree = SOURCE_ROOT; }; + 4AFC341912809A36003A0C29 /* catch_resultinfo.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = catch_resultinfo.hpp; path = ../internal/catch_resultinfo.hpp; sourceTree = SOURCE_ROOT; }; + 4AFC341A12809A36003A0C29 /* catch_runner_impl.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = catch_runner_impl.hpp; path = ../internal/catch_runner_impl.hpp; sourceTree = SOURCE_ROOT; }; + 4AFC341B12809A36003A0C29 /* catch_testcaseinfo.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = catch_testcaseinfo.hpp; path = ../internal/catch_testcaseinfo.hpp; sourceTree = SOURCE_ROOT; }; + 4AFC341C12809A45003A0C29 /* catch_default_main.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = catch_default_main.hpp; path = ../catch_default_main.hpp; sourceTree = SOURCE_ROOT; }; + 4AFC341D12809A45003A0C29 /* catch_reporter_basic.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = catch_reporter_basic.hpp; path = ../catch_reporter_basic.hpp; sourceTree = SOURCE_ROOT; }; + 4AFC341E12809A45003A0C29 /* catch_reporter_xml.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = catch_reporter_xml.hpp; path = ../catch_reporter_xml.hpp; sourceTree = SOURCE_ROOT; }; + 4AFC341F12809A45003A0C29 /* catch_list.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = catch_list.hpp; path = ../internal/catch_list.hpp; sourceTree = SOURCE_ROOT; }; + 4AFC342012809A45003A0C29 /* catch.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = catch.hpp; path = ../catch.hpp; sourceTree = SOURCE_ROOT; }; + 4AFC346412809D41003A0C29 /* catch_commandline.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = catch_commandline.hpp; path = ../internal/catch_commandline.hpp; sourceTree = SOURCE_ROOT; }; + 4AFC359B1281F00B003A0C29 /* catch_section.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = catch_section.hpp; path = ../internal/catch_section.hpp; sourceTree = SOURCE_ROOT; }; + 4AFC38161284B387003A0C29 /* catch_runner.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = catch_runner.hpp; path = ../catch_runner.hpp; sourceTree = SOURCE_ROOT; }; + 4AFC38CC12887D80003A0C29 /* ConditionTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ConditionTests.cpp; sourceTree = ""; }; + 4AFC3A9812893C56003A0C29 /* ExceptionTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ExceptionTests.cpp; sourceTree = ""; }; + 4AFC3AA812893E54003A0C29 /* MessageTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MessageTests.cpp; sourceTree = ""; }; + 4AFC3B0A12894114003A0C29 /* ClassTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ClassTests.cpp; sourceTree = ""; }; + 4AFC3B661289C7E3003A0C29 /* TrickyTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TrickyTests.cpp; sourceTree = ""; }; +======= 4A59535F128E920B009DC1B9 /* ClassTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ClassTests.cpp; path = ../ClassTests.cpp; sourceTree = SOURCE_ROOT; }; 4A595360128E920B009DC1B9 /* ConditionTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ConditionTests.cpp; path = ../ConditionTests.cpp; sourceTree = SOURCE_ROOT; }; 4A595361128E920B009DC1B9 /* ExceptionTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ExceptionTests.cpp; path = ../ExceptionTests.cpp; sourceTree = SOURCE_ROOT; }; @@ -53,6 +89,7 @@ 4A59538D128E93E1009DC1B9 /* catch_section.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = catch_section.hpp; path = ../../internal/catch_section.hpp; sourceTree = SOURCE_ROOT; }; 4A59538E128E93E1009DC1B9 /* catch_testcaseinfo.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = catch_testcaseinfo.hpp; path = ../../internal/catch_testcaseinfo.hpp; sourceTree = SOURCE_ROOT; }; 4A5955C412909CCC009DC1B9 /* catch_objc.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = catch_objc.hpp; path = ../../catch_objc.hpp; sourceTree = SOURCE_ROOT; }; +>>>>>>> 5f43a43662c8b9feca25aeccc79d1c7db664c9a0:Test/Xcode/Test.xcodeproj/project.pbxproj 8DD76F6C0486A84900D96B5E /* Test */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = Test; sourceTree = BUILT_PRODUCTS_DIR; }; C6859E8B029090EE04C91782 /* Test.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = Test.1; sourceTree = ""; }; /* End PBXFileReference section */ @@ -81,8 +118,13 @@ 08FB7795FE84155DC02AAC07 /* Source */ = { isa = PBXGroup; children = ( +<<<<<<< HEAD:Test/Test.xcodeproj/project.pbxproj + 4AA7E96C129FA2A0005A0B97 /* Tests */, + 4A3BFFB8128DCF06005609E3 /* TestMain.cpp */, +======= 4A595379128E9354009DC1B9 /* TestMain.cpp */, 4A59535E128E91FA009DC1B9 /* Test Cases */, +>>>>>>> 5f43a43662c8b9feca25aeccc79d1c7db664c9a0:Test/Xcode/Test.xcodeproj/project.pbxproj 4AFC341312809A12003A0C29 /* Catch */, ); name = Source; @@ -96,6 +138,29 @@ name = Products; sourceTree = ""; }; +<<<<<<< HEAD:Test/Test.xcodeproj/project.pbxproj + 4AA7E96B129FA282005A0B97 /* Reporters */ = { + isa = PBXGroup; + children = ( + 4AFC341D12809A45003A0C29 /* catch_reporter_basic.hpp */, + 4AFC341E12809A45003A0C29 /* catch_reporter_xml.hpp */, + 4AA7E968129FA1DF005A0B97 /* catch_reporter_junit.hpp */, + ); + name = Reporters; + sourceTree = ""; + }; + 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; +======= 4A59535E128E91FA009DC1B9 /* Test Cases */ = { isa = PBXGroup; children = ( @@ -106,17 +171,25 @@ 4A595363128E920B009DC1B9 /* TrickyTests.cpp */, ); name = "Test Cases"; +>>>>>>> 5f43a43662c8b9feca25aeccc79d1c7db664c9a0:Test/Xcode/Test.xcodeproj/project.pbxproj sourceTree = ""; }; 4AFC341312809A12003A0C29 /* Catch */ = { isa = PBXGroup; children = ( +<<<<<<< HEAD:Test/Test.xcodeproj/project.pbxproj + 4AFC342012809A45003A0C29 /* catch.hpp */, + 4AFC341C12809A45003A0C29 /* catch_default_main.hpp */, + 4AFC38161284B387003A0C29 /* catch_runner.hpp */, + 4AA7E96B129FA282005A0B97 /* Reporters */, +======= 4A5955C412909CCC009DC1B9 /* catch_objc.hpp */, 4A59537F128E93CA009DC1B9 /* catch_default_main.hpp */, 4A595380128E93CA009DC1B9 /* catch_reporter_basic.hpp */, 4A595381128E93CA009DC1B9 /* catch_reporter_xml.hpp */, 4A595382128E93CA009DC1B9 /* catch_runner.hpp */, 4A595383128E93CA009DC1B9 /* catch.hpp */, +>>>>>>> 5f43a43662c8b9feca25aeccc79d1c7db664c9a0:Test/Xcode/Test.xcodeproj/project.pbxproj 4AFC341412809A1B003A0C29 /* Internal */, ); name = Catch; @@ -191,12 +264,22 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( +<<<<<<< HEAD:Test/Test.xcodeproj/project.pbxproj + 4AFC38CD12887D80003A0C29 /* ConditionTests.cpp in Sources */, + 4AFC3A9912893C56003A0C29 /* ExceptionTests.cpp in Sources */, + 4AFC3AA912893E54003A0C29 /* MessageTests.cpp in Sources */, + 4AFC3B0B12894114003A0C29 /* ClassTests.cpp in Sources */, + 4AFC3B671289C7E3003A0C29 /* TrickyTests.cpp in Sources */, + 4A3BFFB9128DCF06005609E3 /* TestMain.cpp in Sources */, + 4AA7EA9212A438C7005A0B97 /* MiscTests.cpp in Sources */, +======= 4A595364128E920B009DC1B9 /* ClassTests.cpp in Sources */, 4A595365128E920B009DC1B9 /* ConditionTests.cpp in Sources */, 4A595366128E920B009DC1B9 /* ExceptionTests.cpp in Sources */, 4A595367128E920B009DC1B9 /* MessageTests.cpp in Sources */, 4A595368128E920B009DC1B9 /* TrickyTests.cpp in Sources */, 4A59537A128E9354009DC1B9 /* TestMain.cpp in Sources */, +>>>>>>> 5f43a43662c8b9feca25aeccc79d1c7db664c9a0:Test/Xcode/Test.xcodeproj/project.pbxproj ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/catch_reporter_basic.hpp b/catch_reporter_basic.hpp index bdd52ade..3026f70a 100644 --- a/catch_reporter_basic.hpp +++ b/catch_reporter_basic.hpp @@ -32,12 +32,80 @@ namespace Catch return "Reports test results as lines of text"; } + private: + + /////////////////////////////////////////////////////////////////////////// + void ReportCounts( std::size_t succeeded, std::size_t failed ) + { + if( failed + succeeded == 0 ) + m_config.stream() << "No tests ran"; + else if( failed == 0 ) + m_config.stream() << "All " << succeeded << " test(s) succeeded"; + else if( succeeded == 0 ) + m_config.stream() << "All " << failed << " test(s) failed"; + else + m_config.stream() << succeeded << " test(s) passed but " << failed << " test(s) failed"; + } + private: // ITestReporter + + /////////////////////////////////////////////////////////////////////////// + virtual void StartTesting() + { + m_config.stream() << "[Started testing]" << std::endl; + } + + /////////////////////////////////////////////////////////////////////////// + virtual void EndTesting( std::size_t succeeded, std::size_t failed ) + { + m_config.stream() << "[Testing completed. "; + ReportCounts( succeeded, failed ); + m_config.stream() << "]" << std::endl; + (succeeded, failed); + } + + /////////////////////////////////////////////////////////////////////////// + virtual void StartGroup( const std::string& groupName ) + { + if( !groupName.empty() ) + m_config.stream() << "[Started group: '" << groupName << "']" << std::endl; + } + + /////////////////////////////////////////////////////////////////////////// + virtual void EndGroup( const std::string& groupName, std::size_t succeeded, std::size_t failed ) + { + if( !groupName.empty() ) + { + m_config.stream() << "[End of group: '" << groupName << "'. "; + ReportCounts( succeeded, failed ); + m_config.stream() << "]\n" << std::endl; + } + } /////////////////////////////////////////////////////////////////////////// virtual void StartTestCase( const TestCaseInfo& testInfo ) { m_config.stream() << std::endl << "[Running: " << testInfo.getName() << "]" << std::endl; + m_firstSectionInTestCase = true; + } + + /////////////////////////////////////////////////////////////////////////// + virtual void StartSection( const std::string& sectionName, const std::string /*description*/ ) + { + if( m_firstSectionInTestCase ) + { + m_config.stream() << "\n"; + m_firstSectionInTestCase = false; + } + m_config.stream() << "[Started section: '" << sectionName << "']" << std::endl; + } + + /////////////////////////////////////////////////////////////////////////// + virtual void EndSection( const std::string& sectionName, std::size_t succeeded, std::size_t failed ) + { + m_config.stream() << "[End of section: '" << sectionName << "'. "; + ReportCounts( succeeded, failed ); + m_config.stream() << "]\n" << std::endl; } /////////////////////////////////////////////////////////////////////////// @@ -92,6 +160,7 @@ namespace Catch private: const ReporterConfig& m_config; + bool m_firstSectionInTestCase; }; } // end namespace Catch diff --git a/catch_reporter_xml.hpp b/catch_reporter_xml.hpp index ce6f76a0..c9953da2 100644 --- a/catch_reporter_xml.hpp +++ b/catch_reporter_xml.hpp @@ -35,6 +35,15 @@ namespace Catch private: // ITestReporter + virtual void StartTesting(){} + virtual void EndTesting( std::size_t succeeded, std::size_t failed ){(succeeded, failed);} + + virtual void StartGroup( const std::string& groupName ){(groupName);} + virtual void EndGroup( const std::string& groupName, std::size_t succeeded, std::size_t failed ){(groupName, succeeded, failed);} + + virtual void StartSection( const std::string& sectionName, const std::string description ){(sectionName,description);} + virtual void EndSection( const std::string& sectionName, std::size_t succeeded, std::size_t failed ){(sectionName, succeeded, failed);} + /////////////////////////////////////////////////////////////////////////// virtual void StartTestCase( const Catch::TestCaseInfo& testInfo ) { diff --git a/catch_runner.hpp b/catch_runner.hpp index 710e9832..4109f560 100644 --- a/catch_runner.hpp +++ b/catch_runner.hpp @@ -17,6 +17,7 @@ #include "internal/catch_list.hpp" #include "catch_reporter_basic.hpp" #include "catch_reporter_xml.hpp" +#include "catch_reporter_junit.hpp" namespace Catch { @@ -24,6 +25,7 @@ namespace Catch { ReporterRegistry::instance().registerReporter( "basic" ); ReporterRegistry::instance().registerReporter( "xml" ); + ReporterRegistry::instance().registerReporter( "junit" ); RunnerConfig config; ArgParser( argc, argv, config ); @@ -51,13 +53,14 @@ namespace Catch config.getReporterConfig().setStreamBuf( ofs.rdbuf() ); } - Runner runner; - runner.setReporter( config.getReporter() ); + Runner runner( config.getReporter() ); // Run test specs specified on the command line - or default to all if( config.m_testSpecs.size() == 0 ) { + config.getReporter()->StartGroup( "" ); runner.runAll(); + config.getReporter()->EndGroup( "", runner.getSuccessCount(), runner.getFailureCount() ); } else { @@ -67,11 +70,15 @@ namespace Catch std::vector::const_iterator itEnd = config.m_testSpecs.end(); for(; it != itEnd; ++it ) { + size_t prevSuccess = runner.getSuccessCount(); + size_t prevFail = runner.getFailureCount(); + config.getReporter()->StartGroup( *it ); if( runner.runMatching( *it ) == 0 ) { // Use reporter? std::cerr << "\n[Unable to match any test cases with: " << *it << "]" << std::endl; } + config.getReporter()->EndGroup( *it, runner.getSuccessCount()-prevSuccess, runner.getFailureCount()-prevFail ); } } return runner.getFailureCount(); diff --git a/internal/catch_capture.hpp b/internal/catch_capture.hpp index 1fea174e..ee8b00ce 100644 --- a/internal/catch_capture.hpp +++ b/internal/catch_capture.hpp @@ -195,6 +195,8 @@ struct IResultListener { virtual ~IResultListener(){} virtual void testEnded( const ResultInfo& result ) = 0; + virtual bool sectionStarted( const std::string& name, const std::string& description, std::size_t& successes, std::size_t& failures ) = 0; + virtual void sectionEnded( const std::string& name, std::size_t successes, std::size_t failures ) = 0; }; class ResultsCapture @@ -269,6 +271,16 @@ public: { } + static bool acceptSectionStart( const std::string& name, const std::string& description, std::size_t& successes, std::size_t& failures ) + { + return instance().m_listener->sectionStarted( name, description, successes, failures ); + } + + static void acceptSectionEnd( const std::string& name, std::size_t successes, std::size_t failures ) + { + instance().m_listener->sectionEnded( name, successes, failures ); + } + private: MutableResultInfo currentResult; IResultListener* m_listener; diff --git a/internal/catch_reporter_registry.hpp b/internal/catch_reporter_registry.hpp index b2ab3a69..bf89ff31 100644 --- a/internal/catch_reporter_registry.hpp +++ b/internal/catch_reporter_registry.hpp @@ -79,16 +79,19 @@ namespace Catch { virtual ~ITestReporter(){} - // !TBD - // StartTesting - // EndTesting - // StartGroup - // EndGroup - // StartSection - // EndSection + virtual void StartTesting() = 0; + virtual void EndTesting( std::size_t succeeded, std::size_t failed ) = 0; + + virtual void StartGroup( const std::string& groupName ) = 0; + virtual void EndGroup( const std::string& groupName, std::size_t succeeded, std::size_t failed ) = 0; + + virtual void StartSection( const std::string& sectionName, const std::string description ) = 0; + virtual void EndSection( const std::string& sectionName, std::size_t succeeded, std::size_t failed ) = 0; + virtual void StartTestCase( const TestCaseInfo& testInfo ) = 0; - virtual void Result( const ResultInfo& result ) = 0; virtual void EndTestCase( const TestCaseInfo& testInfo ) = 0; + + virtual void Result( const ResultInfo& result ) = 0; }; struct IReporterFactory diff --git a/internal/catch_resultinfo.hpp b/internal/catch_resultinfo.hpp index 01d5abd1..f7778cbf 100644 --- a/internal/catch_resultinfo.hpp +++ b/internal/catch_resultinfo.hpp @@ -20,13 +20,15 @@ namespace Catch { Unknown = -1, Ok = 0, - ExpressionFailed = 1, + Info = 1, + Warning = 2, + + FailureBit = 0x10, - Info = 2, - Warning = 3, - ExplicitFailure = 4, + ExpressionFailed = FailureBit | 1, + ExplicitFailure = FailureBit | 2, - Exception = 0x100, + Exception = 0x110, ThrewException = Exception | 1, DidntThrowException = Exception | 2 @@ -58,7 +60,7 @@ namespace Catch bool ok() const { - return m_result == ResultWas::Ok; + return ( m_result & ResultWas::FailureBit ) != ResultWas::FailureBit; } ResultWas::OfType getResultType() const diff --git a/internal/catch_runner_impl.hpp b/internal/catch_runner_impl.hpp index 535da6d6..9b5e7c67 100644 --- a/internal/catch_runner_impl.hpp +++ b/internal/catch_runner_impl.hpp @@ -48,16 +48,17 @@ namespace Catch class Runner : public IResultListener { public: - Runner() + explicit Runner( ITestReporter* reporter ) : m_successes( 0 ), m_failures( 0 ), - m_reporter( 0 ) + m_reporter( reporter ) { + m_reporter->StartTesting(); } - void setReporter( ITestReporter* reporter ) + ~Runner() { - m_reporter = reporter; + m_reporter->EndTesting( m_successes, m_failures ); } void runAll() @@ -134,6 +135,19 @@ namespace Catch m_reporter->Result( result ); } + + virtual bool sectionStarted( const std::string& name, const std::string& description, std::size_t& successes, std::size_t& failures ) + { + m_reporter->StartSection( name, description ); + successes = m_successes; + failures = m_failures; + return true; + } + + virtual void sectionEnded( const std::string& name, std::size_t prevSuccesses, std::size_t prevFailures ) + { + m_reporter->EndSection( name, m_successes - prevSuccesses, m_failures - prevFailures ); + } private: std::size_t m_successes; diff --git a/internal/catch_section.hpp b/internal/catch_section.hpp index a510ce87..d72bb546 100644 --- a/internal/catch_section.hpp +++ b/internal/catch_section.hpp @@ -13,6 +13,8 @@ #ifndef TWOBLUECUBES_CATCH_SECTION_HPP_INCLUDED #define TWOBLUECUBES_CATCH_SECTION_HPP_INCLUDED +#include "catch_capture.hpp" + #include namespace Catch @@ -21,25 +23,27 @@ namespace Catch { public: Section( const std::string& name, const std::string& description ) - : m_name( name ), m_description( description ) + : m_name( name ), + m_sectionIncluded( ResultsCapture::acceptSectionStart( name, description, m_successes, m_failures ) ) { - ResultsCapture::acceptSectionStart( name, description ); } ~Section() { - ResultsCapture::acceptSectionEnd( m_name ); + ResultsCapture::acceptSectionEnd( m_name, m_successes, m_failures ); } - // This returns whether the section should be included or not + // This indicates whether the section should be executed or not operator bool() { - // !TBD get this from runner - return true; + return m_sectionIncluded; } + private: std::string m_name; - std::string m_description; + std::size_t m_successes; + std::size_t m_failures; + bool m_sectionIncluded; }; } // end namespace Catch