catch3
Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.
Clonegit clone https://git.progmasoft.com/catch3
Added Visual Studio project and fixed up some warnings showing in VS
- Commit
d8aa843c7d5244b90761c52eb61dc3838df1b4f1- Author
- Phil Nash ·
- Parents
7e8cfa714f2f
Changes
.gitignore | 5 + Test/{main.cpp => TestMain.cpp} | 2 +- Test/VisualStudio/TestCatch/TestCatch.sln | 20 ++ Test/VisualStudio/TestCatch/TestCatch/ReadMe.txt | 33 +++ .../VisualStudio/TestCatch/TestCatch/TestCatch.cpp | 8 + .../TestCatch/TestCatch/TestCatch.vcproj | 221 +++++++++++++++++++++ catch_reporter_xml.hpp | 2 +- catch_runner.hpp | 2 +- internal/catch_capture.hpp | 2 +- internal/catch_commandline.hpp | 2 +- internal/catch_common.h | 11 + internal/catch_reporter_registry.hpp | 2 +- internal/catch_runner_impl.hpp | 4 +- internal/catch_section.hpp | 2 +- 14 files changed, 307 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index d3a1e133..35fc7a6e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,8 @@ Test/build *.pbxuser *.mode1v3 +*.ncb +*.suo +Debug +Release +*.user \ No newline at end of file diff --git a/Test/main.cpp b/Test/TestMain.cpp similarity index 93% rename from Test/main.cpp rename to Test/TestMain.cpp index 2a577905..98f85160 100644 --- a/Test/main.cpp +++ b/Test/TestMain.cpp @@ -59,7 +59,7 @@ int main (int argc, char * const argv[]) if( result == 0 ) { - std::cout << "All tests completed successfully" << std::endl; + std::cout << "All " << runner.getSuccessCount() + runner.getFailureCount() << " tests completed successfully" << std::endl; } return result; } diff --git a/Test/VisualStudio/TestCatch/TestCatch.sln b/Test/VisualStudio/TestCatch/TestCatch.sln new file mode 100644 index 00000000..d6120f4e --- /dev/null +++ b/Test/VisualStudio/TestCatch/TestCatch.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestCatch", "TestCatch\TestCatch.vcproj", "{A2F23B19-9CF7-4246-AE58-BC65E39C6F7E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A2F23B19-9CF7-4246-AE58-BC65E39C6F7E}.Debug|Win32.ActiveCfg = Debug|Win32 + {A2F23B19-9CF7-4246-AE58-BC65E39C6F7E}.Debug|Win32.Build.0 = Debug|Win32 + {A2F23B19-9CF7-4246-AE58-BC65E39C6F7E}.Release|Win32.ActiveCfg = Release|Win32 + {A2F23B19-9CF7-4246-AE58-BC65E39C6F7E}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Test/VisualStudio/TestCatch/TestCatch/ReadMe.txt b/Test/VisualStudio/TestCatch/TestCatch/ReadMe.txt new file mode 100644 index 00000000..597d267b --- /dev/null +++ b/Test/VisualStudio/TestCatch/TestCatch/ReadMe.txt @@ -0,0 +1,33 @@ +======================================================================== + CONSOLE APPLICATION : TestCatch Project Overview +======================================================================== + +AppWizard has created this TestCatch application for you. + +This file contains a summary of what you will find in each of the files that +make up your TestCatch application. + + +TestCatch.vcproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +TestCatch.cpp + This is the main application source file. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named TestCatch.pch and a precompiled types file named StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// +Other notes: + +AppWizard uses "TODO:" comments to indicate parts of the source code you +should add to or customize. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Test/VisualStudio/TestCatch/TestCatch/TestCatch.cpp b/Test/VisualStudio/TestCatch/TestCatch/TestCatch.cpp new file mode 100644 index 00000000..c2fa801e --- /dev/null +++ b/Test/VisualStudio/TestCatch/TestCatch/TestCatch.cpp @@ -0,0 +1,8 @@ +// TestCatch.cpp : Defines the entry point for the console application. +// + +int main(int argc, char* argv[]) +{ + return 0; +} + diff --git a/Test/VisualStudio/TestCatch/TestCatch/TestCatch.vcproj b/Test/VisualStudio/TestCatch/TestCatch/TestCatch.vcproj new file mode 100644 index 00000000..854685d7 --- /dev/null +++ b/Test/VisualStudio/TestCatch/TestCatch/TestCatch.vcproj @@ -0,0 +1,221 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9.00" + Name="TestCatch" + ProjectGUID="{A2F23B19-9CF7-4246-AE58-BC65E39C6F7E}" + RootNamespace="TestCatch" + Keyword="Win32Proj" + TargetFrameworkVersion="196613" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(SolutionDir)$(ConfigurationName)" + IntermediateDirectory="$(ConfigurationName)" + ConfigurationType="1" + CharacterSet="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + UsePrecompiledHeader="0" + WarningLevel="4" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + LinkIncremental="2" + GenerateDebugInformation="true" + SubSystem="1" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(SolutionDir)$(ConfigurationName)" + IntermediateDirectory="$(ConfigurationName)" + ConfigurationType="1" + CharacterSet="1" + WholeProgramOptimization="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="2" + EnableIntrinsicFunctions="true" + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" + RuntimeLibrary="2" + EnableFunctionLevelLinking="true" + UsePrecompiledHeader="0" + WarningLevel="3" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + LinkIncremental="1" + GenerateDebugInformation="true" + SubSystem="1" + OptimizeReferences="2" + EnableCOMDATFolding="2" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath="..\..\..\TestMain.cpp" + > + </File> + </Filter> + <Filter + Name="Header Files" + Filter="h;hpp;hxx;hm;inl;inc;xsd" + UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" + > + </Filter> + <Filter + Name="Resource Files" + Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav" + UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}" + > + </Filter> + <Filter + Name="TestCases" + > + <File + RelativePath="..\..\..\ClassTests.cpp" + > + </File> + <File + RelativePath="..\..\..\ConditionTests.cpp" + > + </File> + <File + RelativePath="..\..\..\ExceptionTests.cpp" + > + </File> + <File + RelativePath="..\..\..\MessageTests.cpp" + > + </File> + <File + RelativePath="..\..\..\TrickyTests.cpp" + > + </File> + </Filter> + <File + RelativePath=".\ReadMe.txt" + > + </File> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/catch_reporter_xml.hpp b/catch_reporter_xml.hpp index 34dd863f..ce6f76a0 100644 --- a/catch_reporter_xml.hpp +++ b/catch_reporter_xml.hpp @@ -82,7 +82,7 @@ namespace Catch } /////////////////////////////////////////////////////////////////////////// - virtual void EndTestCase( const Catch::TestCaseInfo& testInfo ) + virtual void EndTestCase( const Catch::TestCaseInfo& ) { m_config.stream() << "\t<OverallResult success='" << (m_currentTestSuccess ? "true" : "false" ) << "/>\n"; m_config.stream() << "</TestCase>" << std::endl; diff --git a/catch_runner.hpp b/catch_runner.hpp index cdf6653f..710e9832 100644 --- a/catch_runner.hpp +++ b/catch_runner.hpp @@ -74,7 +74,7 @@ namespace Catch } } } - return runner.getFailures(); + return runner.getFailureCount(); } } // end namespace Catch diff --git a/internal/catch_capture.hpp b/internal/catch_capture.hpp index dd923bf8..060c6cf1 100644 --- a/internal/catch_capture.hpp +++ b/internal/catch_capture.hpp @@ -61,7 +61,7 @@ public: } template<typename RhsT> - MutableResultInfo& operator ||( const RhsT& rhs ) + MutableResultInfo& operator ||( const RhsT& ) { m_expressionIncomplete = true; return *this; diff --git a/internal/catch_commandline.hpp b/internal/catch_commandline.hpp index b39046ad..0c10dead 100644 --- a/internal/catch_commandline.hpp +++ b/internal/catch_commandline.hpp @@ -25,7 +25,7 @@ namespace Catch // -r --report <type> // -o --output filename to write to // -s --success report successful cases too - class ArgParser + class ArgParser : NonCopyable { enum Mode { diff --git a/internal/catch_common.h b/internal/catch_common.h index 99a9da52..d94ca34c 100644 --- a/internal/catch_common.h +++ b/internal/catch_common.h @@ -17,4 +17,15 @@ #define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) #define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ ) +namespace Catch +{ + class NonCopyable + { + NonCopyable( const NonCopyable& ); + void operator = ( const NonCopyable& ); + protected: + NonCopyable(){} + }; +} + #endif // TWOBLUECUBES_CATCH_COMMON_H_INCLUDED \ No newline at end of file diff --git a/internal/catch_reporter_registry.hpp b/internal/catch_reporter_registry.hpp index 0837d14c..b2ab3a69 100644 --- a/internal/catch_reporter_registry.hpp +++ b/internal/catch_reporter_registry.hpp @@ -75,7 +75,7 @@ namespace Catch mutable std::ostream m_os; }; - struct ITestReporter + struct ITestReporter : NonCopyable { virtual ~ITestReporter(){} diff --git a/internal/catch_runner_impl.hpp b/internal/catch_runner_impl.hpp index 405dc355..535da6d6 100644 --- a/internal/catch_runner_impl.hpp +++ b/internal/catch_runner_impl.hpp @@ -95,7 +95,7 @@ namespace Catch { testInfo.invoke(); } - catch( TestFailureException& ex ) + catch( TestFailureException& ) { // This just means the test was aborted due to failure } @@ -118,7 +118,7 @@ namespace Catch { return m_successes; } - std:: size_t getFailures() const + std:: size_t getFailureCount() const { return m_failures; } diff --git a/internal/catch_section.hpp b/internal/catch_section.hpp index 0975695d..6eb802d6 100644 --- a/internal/catch_section.hpp +++ b/internal/catch_section.hpp @@ -22,7 +22,7 @@ namespace Catch public: Section( const std::string& name, const std::string& description ) { - // !TBD notify the runner + (name, description); // !TBD notify the runner } operator bool()