From a9fd5b3f14f927f94e7ce84b0f9b5e31b2f44d09 Mon Sep 17 00:00:00 2001 From: Phil Nash Date: Thu, 14 Nov 2013 23:35:56 +0000 Subject: [PATCH 01/15] Removed cruft from VS projects --- projects/VS2008/TestCatch/UpgradeLog.XML | 12 - .../_UpgradeReport_Files/UpgradeReport.css | 207 ---------------- .../_UpgradeReport_Files/UpgradeReport.xslt | 232 ------------------ .../UpgradeReport_Minus.gif | Bin 69 -> 0 bytes .../UpgradeReport_Plus.gif | Bin 71 -> 0 bytes .../VS2010/TestCatch/TestCatch/ReadMe.txt | 33 --- 6 files changed, 484 deletions(-) delete mode 100644 projects/VS2008/TestCatch/UpgradeLog.XML delete mode 100644 projects/VS2008/TestCatch/_UpgradeReport_Files/UpgradeReport.css delete mode 100644 projects/VS2008/TestCatch/_UpgradeReport_Files/UpgradeReport.xslt delete mode 100644 projects/VS2008/TestCatch/_UpgradeReport_Files/UpgradeReport_Minus.gif delete mode 100644 projects/VS2008/TestCatch/_UpgradeReport_Files/UpgradeReport_Plus.gif delete mode 100644 projects/VS2010/TestCatch/TestCatch/ReadMe.txt diff --git a/projects/VS2008/TestCatch/UpgradeLog.XML b/projects/VS2008/TestCatch/UpgradeLog.XML deleted file mode 100644 index 991a3e5b..00000000 --- a/projects/VS2008/TestCatch/UpgradeLog.XML +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/projects/VS2008/TestCatch/_UpgradeReport_Files/UpgradeReport.css b/projects/VS2008/TestCatch/_UpgradeReport_Files/UpgradeReport.css deleted file mode 100644 index fae98af0..00000000 --- a/projects/VS2008/TestCatch/_UpgradeReport_Files/UpgradeReport.css +++ /dev/null @@ -1,207 +0,0 @@ -BODY -{ - BACKGROUND-COLOR: white; - FONT-FAMILY: "Verdana", sans-serif; - FONT-SIZE: 100%; - MARGIN-LEFT: 0px; - MARGIN-TOP: 0px -} -P -{ - FONT-FAMILY: "Verdana", sans-serif; - FONT-SIZE: 70%; - LINE-HEIGHT: 12pt; - MARGIN-BOTTOM: 0px; - MARGIN-LEFT: 10px; - MARGIN-TOP: 10px -} -.note -{ - BACKGROUND-COLOR: #ffffff; - COLOR: #336699; - FONT-FAMILY: "Verdana", sans-serif; - FONT-SIZE: 100%; - MARGIN-BOTTOM: 0px; - MARGIN-LEFT: 0px; - MARGIN-TOP: 0px; - PADDING-RIGHT: 10px -} -.infotable -{ - BACKGROUND-COLOR: #f0f0e0; - BORDER-BOTTOM: #ffffff 0px solid; - BORDER-COLLAPSE: collapse; - BORDER-LEFT: #ffffff 0px solid; - BORDER-RIGHT: #ffffff 0px solid; - BORDER-TOP: #ffffff 0px solid; - FONT-SIZE: 70%; - MARGIN-LEFT: 10px -} -.issuetable -{ - BACKGROUND-COLOR: #ffffe8; - BORDER-COLLAPSE: collapse; - COLOR: #000000; - FONT-SIZE: 100%; - MARGIN-BOTTOM: 10px; - MARGIN-LEFT: 13px; - MARGIN-TOP: 0px -} -.issuetitle -{ - BACKGROUND-COLOR: #ffffff; - BORDER-BOTTOM: #dcdcdc 1px solid; - BORDER-TOP: #dcdcdc 1px; - COLOR: #003366; - FONT-WEIGHT: normal -} -.header -{ - BACKGROUND-COLOR: #cecf9c; - BORDER-BOTTOM: #ffffff 1px solid; - BORDER-LEFT: #ffffff 1px solid; - BORDER-RIGHT: #ffffff 1px solid; - BORDER-TOP: #ffffff 1px solid; - COLOR: #000000; - FONT-WEIGHT: bold -} -.issuehdr -{ - BACKGROUND-COLOR: #E0EBF5; - BORDER-BOTTOM: #dcdcdc 1px solid; - BORDER-TOP: #dcdcdc 1px solid; - COLOR: #000000; - FONT-WEIGHT: normal -} -.issuenone -{ - BACKGROUND-COLOR: #ffffff; - BORDER-BOTTOM: 0px; - BORDER-LEFT: 0px; - BORDER-RIGHT: 0px; - BORDER-TOP: 0px; - COLOR: #000000; - FONT-WEIGHT: normal -} -.content -{ - BACKGROUND-COLOR: #e7e7ce; - BORDER-BOTTOM: #ffffff 1px solid; - BORDER-LEFT: #ffffff 1px solid; - BORDER-RIGHT: #ffffff 1px solid; - BORDER-TOP: #ffffff 1px solid; - PADDING-LEFT: 3px -} -.issuecontent -{ - BACKGROUND-COLOR: #ffffff; - BORDER-BOTTOM: #dcdcdc 1px solid; - BORDER-TOP: #dcdcdc 1px solid; - PADDING-LEFT: 3px -} -A:link -{ - COLOR: #cc6633; - TEXT-DECORATION: underline -} -A:visited -{ - COLOR: #cc6633; -} -A:active -{ - COLOR: #cc6633; -} -A:hover -{ - COLOR: #cc3300; - TEXT-DECORATION: underline -} -H1 -{ - BACKGROUND-COLOR: #003366; - BORDER-BOTTOM: #336699 6px solid; - COLOR: #ffffff; - FONT-SIZE: 130%; - FONT-WEIGHT: normal; - MARGIN: 0em 0em 0em -20px; - PADDING-BOTTOM: 8px; - PADDING-LEFT: 30px; - PADDING-TOP: 16px -} -H2 -{ - COLOR: #000000; - FONT-SIZE: 80%; - FONT-WEIGHT: bold; - MARGIN-BOTTOM: 3px; - MARGIN-LEFT: 10px; - MARGIN-TOP: 20px; - PADDING-LEFT: 0px -} -H3 -{ - COLOR: #000000; - FONT-SIZE: 80%; - FONT-WEIGHT: bold; - MARGIN-BOTTOM: -5px; - MARGIN-LEFT: 10px; - MARGIN-TOP: 20px -} -H4 -{ - COLOR: #000000; - FONT-SIZE: 70%; - FONT-WEIGHT: bold; - MARGIN-BOTTOM: 0px; - MARGIN-TOP: 15px; - PADDING-BOTTOM: 0px -} -UL -{ - COLOR: #000000; - FONT-SIZE: 70%; - LIST-STYLE: square; - MARGIN-BOTTOM: 0pt; - MARGIN-TOP: 0pt -} -OL -{ - COLOR: #000000; - FONT-SIZE: 70%; - LIST-STYLE: square; - MARGIN-BOTTOM: 0pt; - MARGIN-TOP: 0pt -} -LI -{ - LIST-STYLE: square; - MARGIN-LEFT: 0px -} -.expandable -{ - CURSOR: hand -} -.expanded -{ - color: black -} -.collapsed -{ - DISPLAY: none -} -.foot -{ -BACKGROUND-COLOR: #ffffff; -BORDER-BOTTOM: #cecf9c 1px solid; -BORDER-TOP: #cecf9c 2px solid -} -.settings -{ -MARGIN-LEFT: 25PX; -} -.help -{ -TEXT-ALIGN: right; -margin-right: 10px; -} diff --git a/projects/VS2008/TestCatch/_UpgradeReport_Files/UpgradeReport.xslt b/projects/VS2008/TestCatch/_UpgradeReport_Files/UpgradeReport.xslt deleted file mode 100644 index 73c4e7af..00000000 --- a/projects/VS2008/TestCatch/_UpgradeReport_Files/UpgradeReport.xslt +++ /dev/null @@ -1,232 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- Solution: - Project: - - - - - - - -

- - - - - - - - - - - - - - - - - - - - - - - - src - - - - - - - - - - - - -
FilenameStatusErrorsWarnings
- javascript:document.images[''].click()src - - - - Converted - - - - Converted - -
- - files - - - 1 file - - - Converted:
- Not converted: -
-
-
- - - - : - - - - - - - - - Conversion Report - <xsl:if test="Properties/Property[@Name='LogNumber']"> - <xsl:value-of select="Properties/Property[@Name='LogNumber']/@Value"/> - </xsl:if> - - - - -

Conversion Report -

- -

- Time of Conversion:
-

- - - - - - - - - - - - - - - - - - - - - - - - -

- - - - - -
- Conversion Settings -

- - -
-
diff --git a/projects/VS2008/TestCatch/_UpgradeReport_Files/UpgradeReport_Minus.gif b/projects/VS2008/TestCatch/_UpgradeReport_Files/UpgradeReport_Minus.gif deleted file mode 100644 index 17751cb2fd5c284dfe984adc4c769982f73a0a66..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 69 zcmZ?wbhEHb23ky~TYXIqG7FYlP diff --git a/projects/VS2010/TestCatch/TestCatch/ReadMe.txt b/projects/VS2010/TestCatch/TestCatch/ReadMe.txt deleted file mode 100644 index 139e3319..00000000 --- a/projects/VS2010/TestCatch/TestCatch/ReadMe.txt +++ /dev/null @@ -1,33 +0,0 @@ -======================================================================== - 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. - -///////////////////////////////////////////////////////////////////////////// From 337dc25ed78a98f3876b30bd8542735f536473c8 Mon Sep 17 00:00:00 2001 From: Phil Nash Date: Tue, 19 Nov 2013 07:21:03 +0000 Subject: [PATCH 02/15] Converted all test case names to "modern" style (freeform text + tags) --- include/internal/catch_test_case_info.hpp | 2 +- .../catch_test_case_registry_impl.hpp | 4 +- projects/SelfTest/ApproxTests.cpp | 24 +- .../Baselines/console.std.approved.txt | 112 ++- .../Baselines/console.sw.approved.txt | 841 ++++-------------- .../Baselines/console.swa4.approved.txt | 24 +- .../SelfTest/Baselines/junit.sw.approved.txt | 224 +++-- .../SelfTest/Baselines/xml.sw.approved.txt | 292 +++--- projects/SelfTest/ClassTests.cpp | 8 +- projects/SelfTest/ConditionTests.cpp | 42 +- projects/SelfTest/ExceptionTests.cpp | 24 +- projects/SelfTest/GeneratorTests.cpp | 4 +- projects/SelfTest/MessageTests.cpp | 31 +- projects/SelfTest/MiscTests.cpp | 59 +- projects/SelfTest/TestMain.cpp | 46 - projects/SelfTest/TrickyTests.cpp | 64 +- .../TestCatch/TestCatch/TestCatch.vcxproj | 3 - 17 files changed, 587 insertions(+), 1217 deletions(-) diff --git a/include/internal/catch_test_case_info.hpp b/include/internal/catch_test_case_info.hpp index 3a279602..59fc39f4 100644 --- a/include/internal/catch_test_case_info.hpp +++ b/include/internal/catch_test_case_info.hpp @@ -22,7 +22,7 @@ namespace Catch { SourceLineInfo const& _lineInfo ) { std::string desc = _descOrTags; - bool isHidden( startsWith( _name, "./" ) ); + bool isHidden( startsWith( _name, "./" ) ); // Legacy support std::set tags; TagExtracter( tags ).parse( desc ); if( tags.find( "hide" ) != tags.end() || tags.find( "." ) != tags.end() ) diff --git a/include/internal/catch_test_case_registry_impl.hpp b/include/internal/catch_test_case_registry_impl.hpp index 41714bc8..af1ee29f 100644 --- a/include/internal/catch_test_case_registry_impl.hpp +++ b/include/internal/catch_test_case_registry_impl.hpp @@ -42,8 +42,8 @@ namespace Catch { else { TestCase const& prev = *m_functions.find( testCase ); std::cerr << "error: TEST_CASE( \"" << name << "\" ) already defined.\n" - << "\tFirst seen at " << SourceLineInfo( prev.getTestCaseInfo().lineInfo ) << "\n" - << "\tRedefined at " << SourceLineInfo( testCase.getTestCaseInfo().lineInfo ) << std::endl; + << "\tFirst seen at " << prev.getTestCaseInfo().lineInfo << "\n" + << "\tRedefined at " << testCase.getTestCaseInfo().lineInfo << std::endl; exit(1); } } diff --git a/projects/SelfTest/ApproxTests.cpp b/projects/SelfTest/ApproxTests.cpp index acf96c99..1df76155 100644 --- a/projects/SelfTest/ApproxTests.cpp +++ b/projects/SelfTest/ApproxTests.cpp @@ -11,8 +11,8 @@ /////////////////////////////////////////////////////////////////////////////// TEST_CASE ( - "./succeeding/Approx/simple", - "Some simple comparisons between doubles" + "Some simple comparisons between doubles", + "[Approx]" ) { double d = 1.23; @@ -29,8 +29,8 @@ TEST_CASE /////////////////////////////////////////////////////////////////////////////// TEST_CASE ( - "./succeeding/Approx/epsilon", - "Approximate comparisons with different epsilons" + "Approximate comparisons with different epsilons", + "[Approx]" ) { double d = 1.23; @@ -42,8 +42,8 @@ TEST_CASE /////////////////////////////////////////////////////////////////////////////// TEST_CASE ( - "./succeeding/Approx/float", - "Approximate comparisons with floats" + "Approximate comparisons with floats", + "[Approx]" ) { REQUIRE( 1.23f == Approx( 1.23f ) ); @@ -53,8 +53,8 @@ TEST_CASE /////////////////////////////////////////////////////////////////////////////// TEST_CASE ( - "./succeeding/Approx/int", - "Approximate comparisons with ints" + "Approximate comparisons with ints", + "[Approx]" ) { REQUIRE( 1 == Approx( 1 ) ); @@ -64,8 +64,8 @@ TEST_CASE /////////////////////////////////////////////////////////////////////////////// TEST_CASE ( - "./succeeding/Approx/mixed", - "Approximate comparisons with mixed numeric types" + "Approximate comparisons with mixed numeric types", + "[Approx]" ) { const double dZero = 0; @@ -82,8 +82,8 @@ TEST_CASE /////////////////////////////////////////////////////////////////////////////// TEST_CASE ( - "./succeeding/Approx/custom", - "Use a custom approx" + "Use a custom approx", + "[Approx][custom]" ) { double d = 1.23; diff --git a/projects/SelfTest/Baselines/console.std.approved.txt b/projects/SelfTest/Baselines/console.std.approved.txt index aaafd844..54bee3e5 100644 --- a/projects/SelfTest/Baselines/console.std.approved.txt +++ b/projects/SelfTest/Baselines/console.std.approved.txt @@ -4,7 +4,7 @@ CatchSelfTest is a host application. Run with -? for options ------------------------------------------------------------------------------- -./failing/TestClass/failingCase +A METHOD_AS_TEST_CASE based test run that fails ------------------------------------------------------------------------------- ClassTests.cpp: ............................................................................... @@ -15,7 +15,7 @@ with expansion: "hello" == "world" ------------------------------------------------------------------------------- -./failing/Fixture/failingCase +A TEST_CASE_METHOD based test run that fails ------------------------------------------------------------------------------- ClassTests.cpp: ............................................................................... @@ -26,7 +26,7 @@ with expansion: 1 == 2 ------------------------------------------------------------------------------- -./failing/conditions/equality +Equality checks that should fail] ------------------------------------------------------------------------------- ConditionTests.cpp: ............................................................................... @@ -97,7 +97,7 @@ with expansion: 1.3 == Approx( 1.301 ) ------------------------------------------------------------------------------- -./failing/conditions/inequality +Inequality checks that should fails ------------------------------------------------------------------------------- ConditionTests.cpp: ............................................................................... @@ -128,7 +128,7 @@ with expansion: 5 != 5 ------------------------------------------------------------------------------- -./failing/conditions/ordered +Ordering comparison checks that should fail ------------------------------------------------------------------------------- ConditionTests.cpp: ............................................................................... @@ -229,7 +229,7 @@ with expansion: "hello" <= "a" ------------------------------------------------------------------------------- -./failing/conditions/not +'Not' checks that should fail ------------------------------------------------------------------------------- ConditionTests.cpp: ............................................................................... @@ -269,7 +269,7 @@ with expansion: !(1 == 1) ------------------------------------------------------------------------------- -./failing/exceptions/explicit +Expected exceptions that don't throw or unexpected exceptions fail the test ------------------------------------------------------------------------------- ExceptionTests.cpp: ............................................................................... @@ -289,7 +289,7 @@ due to unexpected exception with message: expected exception ------------------------------------------------------------------------------- -./failing/exceptions/implicit +When unchecked exceptions are thrown directly they are always failures ------------------------------------------------------------------------------- ExceptionTests.cpp: ............................................................................... @@ -299,7 +299,7 @@ due to unexpected exception with message: unexpected exception ------------------------------------------------------------------------------- -./failing/exceptions/implicit/2 +An unchecked exception reports the line of the last assertion ------------------------------------------------------------------------------- ExceptionTests.cpp: ............................................................................... @@ -310,7 +310,7 @@ due to unexpected exception with message: unexpected exception ------------------------------------------------------------------------------- -./failing/exceptions/implicit/3 +When unchecked exceptions are thrown from sections they are always failures section name ------------------------------------------------------------------------------- ExceptionTests.cpp: @@ -321,7 +321,7 @@ due to unexpected exception with message: unexpected exception ------------------------------------------------------------------------------- -./failing/exceptions/implicit/4 +When unchecked exceptions are thrown from functions they are always failures ------------------------------------------------------------------------------- ExceptionTests.cpp: ............................................................................... @@ -332,7 +332,7 @@ due to unexpected exception with message: expected exception ------------------------------------------------------------------------------- -./failing/exceptions/custom +Unexpected custom exceptions can be translated ------------------------------------------------------------------------------- ExceptionTests.cpp: ............................................................................... @@ -342,7 +342,7 @@ due to unexpected exception with message: custom exception ------------------------------------------------------------------------------- -./failing/exceptions/custom/nothrow +Custom exceptions can be translated when testing for nothrow ------------------------------------------------------------------------------- ExceptionTests.cpp: ............................................................................... @@ -353,7 +353,7 @@ due to unexpected exception with message: custom exception - not std ------------------------------------------------------------------------------- -./failing/exceptions/custom/throw +Custom exceptions can be translated when testing for throwing as something else ------------------------------------------------------------------------------- ExceptionTests.cpp: ............................................................................... @@ -364,7 +364,7 @@ due to unexpected exception with message: custom exception - not std ------------------------------------------------------------------------------- -./failing/exceptions/custom/double +Unexpected exceptions can be translated ------------------------------------------------------------------------------- ExceptionTests.cpp: ............................................................................... @@ -374,7 +374,7 @@ due to unexpected exception with message: 3.14 ------------------------------------------------------------------------------- -./succeeding/message +INFO and WARN do not abort tests ------------------------------------------------------------------------------- MessageTests.cpp: ............................................................................... @@ -384,7 +384,7 @@ warning: this is a warning ------------------------------------------------------------------------------- -./failing/message/info/1 +INFO gets logged on failure ------------------------------------------------------------------------------- MessageTests.cpp: ............................................................................... @@ -398,7 +398,7 @@ with messages: so should this ------------------------------------------------------------------------------- -./mixed/message/info/2 +INFO gets logged on failure, even if captured before successful assertions ------------------------------------------------------------------------------- MessageTests.cpp: ............................................................................... @@ -419,7 +419,7 @@ with message: and this, but later ------------------------------------------------------------------------------- -./failing/message/fail +FAIL aborts the test ------------------------------------------------------------------------------- MessageTests.cpp: ............................................................................... @@ -429,7 +429,7 @@ explicitly with message: This is a failure ------------------------------------------------------------------------------- -./failing/message/sections +Output from all sections is reported one ------------------------------------------------------------------------------- MessageTests.cpp: @@ -440,7 +440,7 @@ explicitly with message: Message from section one ------------------------------------------------------------------------------- -./failing/message/sections +Output from all sections is reported two ------------------------------------------------------------------------------- MessageTests.cpp: @@ -453,7 +453,7 @@ explicitly with message: Message from section one Message from section two ------------------------------------------------------------------------------- -./mixed/message/scoped +SCOPED_INFO is reset for each loop ------------------------------------------------------------------------------- MessageTests.cpp: ............................................................................... @@ -477,7 +477,19 @@ explicitly with message: Previous info should not be seen ------------------------------------------------------------------------------- -./mixed/Misc/Sections/nested2 +sends information to INFO +------------------------------------------------------------------------------- +MessageTests.cpp: +............................................................................... + +MessageTests.cpp:: FAILED: + REQUIRE( false ) +with messages: + hi + i := 7 + +------------------------------------------------------------------------------- +more nested SECTION tests s1 s2 ------------------------------------------------------------------------------- @@ -490,7 +502,7 @@ with expansion: 1 == 2 ------------------------------------------------------------------------------- -./mixed/Misc/Sections/loops +looped SECTION tests s1 ------------------------------------------------------------------------------- MiscTests.cpp: @@ -502,7 +514,7 @@ with expansion: 0 > 1 ------------------------------------------------------------------------------- -./mixed/Misc/loops +looped tests ------------------------------------------------------------------------------- MiscTests.cpp: ............................................................................... @@ -552,19 +564,7 @@ with message: Some information An error ------------------------------------------------------------------------------- -./failing/info -------------------------------------------------------------------------------- -MiscTests.cpp: -............................................................................... - -MiscTests.cpp:: FAILED: - REQUIRE( false ) -with messages: - hi - i := 7 - -------------------------------------------------------------------------------- -./failing/checkedif +checkedIf, failing ------------------------------------------------------------------------------- MiscTests.cpp: ............................................................................... @@ -580,7 +580,7 @@ with expansion: false ------------------------------------------------------------------------------- -./failing/checkedelse +checkedElse, failing ------------------------------------------------------------------------------- MiscTests.cpp: ............................................................................... @@ -596,7 +596,7 @@ with expansion: false ------------------------------------------------------------------------------- -./manual/onechar +send a single char to INFO ------------------------------------------------------------------------------- MiscTests.cpp: ............................................................................... @@ -607,7 +607,7 @@ with message: 3 ------------------------------------------------------------------------------- -./failing/matchers/Contains +Contains string matcher ------------------------------------------------------------------------------- MiscTests.cpp: ............................................................................... @@ -618,7 +618,7 @@ with expansion: "this string contains 'abc' as a substring" contains: "not there" ------------------------------------------------------------------------------- -./failing/matchers/StartsWith +StartsWith string matcher ------------------------------------------------------------------------------- MiscTests.cpp: ............................................................................... @@ -629,7 +629,7 @@ with expansion: "this string contains 'abc' as a substring" starts with: "string" ------------------------------------------------------------------------------- -./failing/matchers/EndsWith +EndsWith string matcher ------------------------------------------------------------------------------- MiscTests.cpp: ............................................................................... @@ -640,7 +640,7 @@ with expansion: "this string contains 'abc' as a substring" ends with: "this" ------------------------------------------------------------------------------- -./failing/matchers/Equals +Equals string matcher ------------------------------------------------------------------------------- MiscTests.cpp: ............................................................................... @@ -661,7 +661,7 @@ warning: This one ran ------------------------------------------------------------------------------- -./failing/CatchSectionInfiniteLoop +A couple of nested sections followed by a failure ------------------------------------------------------------------------------- MiscTests.cpp: ............................................................................... @@ -671,7 +671,7 @@ explicitly with message: to infinity and beyond ------------------------------------------------------------------------------- -./failing/CatchSectionInfiniteLoop +A couple of nested sections followed by a failure ------------------------------------------------------------------------------- MiscTests.cpp: ............................................................................... @@ -681,7 +681,7 @@ explicitly with message: to infinity and beyond ------------------------------------------------------------------------------- -./failing/CatchSectionInfiniteLoop +A couple of nested sections followed by a failure ------------------------------------------------------------------------------- MiscTests.cpp: ............................................................................... @@ -690,18 +690,10 @@ MiscTests.cpp:: FAILED: explicitly with message: to infinity and beyond -Message from section one -Message from section two -Some information -An error -Message from section one -Message from section two -Some information -An error hello hello ------------------------------------------------------------------------------- -./inprogress/failing/Tricky/trailing expression +Where the is more to the expression after the RHS[failing] ------------------------------------------------------------------------------- TrickyTests.cpp: ............................................................................... @@ -712,7 +704,7 @@ warning: error ------------------------------------------------------------------------------- -./inprogress/failing/Tricky/compound lhs +Where the LHS is not a simple value[failing] ------------------------------------------------------------------------------- TrickyTests.cpp: ............................................................................... @@ -723,7 +715,7 @@ warning: error ------------------------------------------------------------------------------- -./failing/Tricky/non streamable type +A failing expression with a non streamable type is still captured[failing] ------------------------------------------------------------------------------- TrickyTests.cpp: ............................................................................... @@ -739,7 +731,7 @@ with expansion: {?} == {?} ------------------------------------------------------------------------------- -./failing/string literals +string literals of different sizes can be compared[failing] ------------------------------------------------------------------------------- TrickyTests.cpp: ............................................................................... @@ -750,5 +742,5 @@ with expansion: "first" == "second" =============================================================================== -122 test cases - 35 failed (753 assertions - 90 failed) +120 test cases - 35 failed (673 assertions - 90 failed) diff --git a/projects/SelfTest/Baselines/console.sw.approved.txt b/projects/SelfTest/Baselines/console.sw.approved.txt index c85230c3..7c39bd07 100644 --- a/projects/SelfTest/Baselines/console.sw.approved.txt +++ b/projects/SelfTest/Baselines/console.sw.approved.txt @@ -4,7 +4,7 @@ CatchSelfTest is a host application. Run with -? for options ------------------------------------------------------------------------------- -./succeeding/Approx/simple +Some simple comparisons between doubles ------------------------------------------------------------------------------- ApproxTests.cpp: ............................................................................... @@ -46,7 +46,7 @@ with expansion: Approx( 1.23 ) != 1.24 ------------------------------------------------------------------------------- -./succeeding/Approx/epsilon +Approximate comparisons with different epsilons ------------------------------------------------------------------------------- ApproxTests.cpp: ............................................................................... @@ -64,7 +64,7 @@ with expansion: 1.23 == Approx( 1.231 ) ------------------------------------------------------------------------------- -./succeeding/Approx/float +Approximate comparisons with floats ------------------------------------------------------------------------------- ApproxTests.cpp: ............................................................................... @@ -82,7 +82,7 @@ with expansion: 0 == Approx( 0 ) ------------------------------------------------------------------------------- -./succeeding/Approx/int +Approximate comparisons with ints ------------------------------------------------------------------------------- ApproxTests.cpp: ............................................................................... @@ -96,7 +96,7 @@ PASSED: REQUIRE( 0 == Approx( 0 ) ) ------------------------------------------------------------------------------- -./succeeding/Approx/mixed +Approximate comparisons with mixed numeric types ------------------------------------------------------------------------------- ApproxTests.cpp: ............................................................................... @@ -132,7 +132,7 @@ with expansion: 1.234 == Approx( 1.234 ) ------------------------------------------------------------------------------- -./succeeding/Approx/custom +Use a custom approx ------------------------------------------------------------------------------- ApproxTests.cpp: ............................................................................... @@ -204,7 +204,7 @@ with expansion: 3.1428571429 != Approx( 3.141 ) ------------------------------------------------------------------------------- -./succeeding/TestClass/succeedingCase +A METHOD_AS_TEST_CASE based test run that succeeds ------------------------------------------------------------------------------- ClassTests.cpp: ............................................................................... @@ -216,7 +216,7 @@ with expansion: "hello" == "hello" ------------------------------------------------------------------------------- -./failing/TestClass/failingCase +A METHOD_AS_TEST_CASE based test run that fails ------------------------------------------------------------------------------- ClassTests.cpp: ............................................................................... @@ -227,7 +227,7 @@ with expansion: "hello" == "world" ------------------------------------------------------------------------------- -./succeeding/Fixture/succeedingCase +A TEST_CASE_METHOD based test run that succeeds ------------------------------------------------------------------------------- ClassTests.cpp: ............................................................................... @@ -239,7 +239,7 @@ with expansion: 1 == 1 ------------------------------------------------------------------------------- -./failing/Fixture/failingCase +A TEST_CASE_METHOD based test run that fails ------------------------------------------------------------------------------- ClassTests.cpp: ............................................................................... @@ -250,7 +250,7 @@ with expansion: 1 == 2 ------------------------------------------------------------------------------- -./succeeding/conditions/equality +Equality checks that should succeed ------------------------------------------------------------------------------- ConditionTests.cpp: ............................................................................... @@ -298,7 +298,7 @@ with expansion: 1.3 == Approx( 1.3 ) ------------------------------------------------------------------------------- -./failing/conditions/equality +Equality checks that should fail] ------------------------------------------------------------------------------- ConditionTests.cpp: ............................................................................... @@ -369,7 +369,7 @@ with expansion: 1.3 == Approx( 1.301 ) ------------------------------------------------------------------------------- -./succeeding/conditions/inequality +Inequality checks that should succeed ------------------------------------------------------------------------------- ConditionTests.cpp: ............................................................................... @@ -441,7 +441,7 @@ with expansion: 5 != 6 ------------------------------------------------------------------------------- -./failing/conditions/inequality +Inequality checks that should fails ------------------------------------------------------------------------------- ConditionTests.cpp: ............................................................................... @@ -472,7 +472,7 @@ with expansion: 5 != 5 ------------------------------------------------------------------------------- -./succeeding/conditions/ordered +Ordering comparison checks that should succeed ------------------------------------------------------------------------------- ConditionTests.cpp: ............................................................................... @@ -580,7 +580,7 @@ with expansion: "hello" > "a" ------------------------------------------------------------------------------- -./failing/conditions/ordered +Ordering comparison checks that should fail ------------------------------------------------------------------------------- ConditionTests.cpp: ............................................................................... @@ -681,7 +681,7 @@ with expansion: "hello" <= "a" ------------------------------------------------------------------------------- -./succeeding/conditions/int literals +Comparisons with int literals don't warn when mixing signed/ unsigned ------------------------------------------------------------------------------- ConditionTests.cpp: ............................................................................... @@ -765,7 +765,7 @@ with expansion: 0x > 4 ------------------------------------------------------------------------------- -./succeeding/conditions//long_to_unsigned_x +comparisons between int variables ------------------------------------------------------------------------------- ConditionTests.cpp: ............................................................................... @@ -795,7 +795,7 @@ with expansion: 1 == 1 ------------------------------------------------------------------------------- -./succeeding/conditions/const ints to int literal +comparisons between const int variables ------------------------------------------------------------------------------- ConditionTests.cpp: ............................................................................... @@ -825,7 +825,8 @@ with expansion: 1 == 1 ------------------------------------------------------------------------------- -./succeeding/conditions/negative ints +Comparisons between unsigned ints and negative signed ints match c++ standard +behaviour ------------------------------------------------------------------------------- ConditionTests.cpp: ............................................................................... @@ -867,7 +868,7 @@ with expansion: -2147483648 > 2 ------------------------------------------------------------------------------- -./succeeding/conditions/computed ints +Comparisons between ints where one side is computed ------------------------------------------------------------------------------- ConditionTests.cpp: ............................................................................... @@ -879,7 +880,7 @@ with expansion: 54 == 54 ------------------------------------------------------------------------------- -./succeeding/conditions/ptr +Pointers can be compared to null ------------------------------------------------------------------------------- ConditionTests.cpp: ............................................................................... @@ -933,7 +934,7 @@ with expansion: 0 != 0x ------------------------------------------------------------------------------- -./succeeding/conditions/not +'Not' checks that should succeed ------------------------------------------------------------------------------- ConditionTests.cpp: ............................................................................... @@ -981,7 +982,7 @@ with expansion: !(1 == 2) ------------------------------------------------------------------------------- -./failing/conditions/not +'Not' checks that should fail ------------------------------------------------------------------------------- ConditionTests.cpp: ............................................................................... @@ -1021,7 +1022,7 @@ with expansion: !(1 == 1) ------------------------------------------------------------------------------- -./succeeding/exceptions/explicit +When checked exceptions are thrown they can be expected or unexpected ------------------------------------------------------------------------------- ExceptionTests.cpp: ............................................................................... @@ -1039,7 +1040,7 @@ PASSED: REQUIRE_THROWS( thisThrows() ) ------------------------------------------------------------------------------- -./failing/exceptions/explicit +Expected exceptions that don't throw or unexpected exceptions fail the test ------------------------------------------------------------------------------- ExceptionTests.cpp: ............................................................................... @@ -1059,7 +1060,7 @@ due to unexpected exception with message: expected exception ------------------------------------------------------------------------------- -./failing/exceptions/implicit +When unchecked exceptions are thrown directly they are always failures ------------------------------------------------------------------------------- ExceptionTests.cpp: ............................................................................... @@ -1069,7 +1070,7 @@ due to unexpected exception with message: unexpected exception ------------------------------------------------------------------------------- -./failing/exceptions/implicit/2 +An unchecked exception reports the line of the last assertion ------------------------------------------------------------------------------- ExceptionTests.cpp: ............................................................................... @@ -1084,7 +1085,7 @@ due to unexpected exception with message: unexpected exception ------------------------------------------------------------------------------- -./failing/exceptions/implicit/3 +When unchecked exceptions are thrown from sections they are always failures section name ------------------------------------------------------------------------------- ExceptionTests.cpp: @@ -1095,7 +1096,7 @@ due to unexpected exception with message: unexpected exception ------------------------------------------------------------------------------- -./failing/exceptions/implicit/4 +When unchecked exceptions are thrown from functions they are always failures ------------------------------------------------------------------------------- ExceptionTests.cpp: ............................................................................... @@ -1106,16 +1107,16 @@ due to unexpected exception with message: expected exception ------------------------------------------------------------------------------- -./succeeding/exceptions/implicit +When unchecked exceptions are thrown, but caught, they do not affect the test ------------------------------------------------------------------------------- ExceptionTests.cpp: ............................................................................... -No assertions in test case './succeeding/exceptions/implicit' +No assertions in test case 'When unchecked exceptions are thrown, but caught, they do not affect the test' ------------------------------------------------------------------------------- -./failing/exceptions/custom +Unexpected custom exceptions can be translated ------------------------------------------------------------------------------- ExceptionTests.cpp: ............................................................................... @@ -1125,7 +1126,7 @@ due to unexpected exception with message: custom exception ------------------------------------------------------------------------------- -./failing/exceptions/custom/nothrow +Custom exceptions can be translated when testing for nothrow ------------------------------------------------------------------------------- ExceptionTests.cpp: ............................................................................... @@ -1136,7 +1137,7 @@ due to unexpected exception with message: custom exception - not std ------------------------------------------------------------------------------- -./failing/exceptions/custom/throw +Custom exceptions can be translated when testing for throwing as something else ------------------------------------------------------------------------------- ExceptionTests.cpp: ............................................................................... @@ -1147,7 +1148,7 @@ due to unexpected exception with message: custom exception - not std ------------------------------------------------------------------------------- -./failing/exceptions/custom/double +Unexpected exceptions can be translated ------------------------------------------------------------------------------- ExceptionTests.cpp: ............................................................................... @@ -1157,7 +1158,7 @@ due to unexpected exception with message: 3.14 ------------------------------------------------------------------------------- -./succeeding/exceptions/notimplemented +NotImplemented exception ------------------------------------------------------------------------------- ExceptionTests.cpp: ............................................................................... @@ -1167,7 +1168,7 @@ PASSED: REQUIRE_THROWS( thisFunctionNotImplemented( 7 ) ) ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -1185,7 +1186,7 @@ with expansion: 200 == 200 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -1203,7 +1204,7 @@ with expansion: 200 == 200 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -1221,7 +1222,7 @@ with expansion: 200 == 200 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -1239,7 +1240,7 @@ with expansion: 200 == 200 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -1257,7 +1258,7 @@ with expansion: 200 == 200 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -1275,7 +1276,7 @@ with expansion: 200 == 200 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -1293,7 +1294,7 @@ with expansion: 200 == 200 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -1311,7 +1312,7 @@ with expansion: 200 == 200 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -1329,7 +1330,7 @@ with expansion: 200 == 200 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -1347,7 +1348,7 @@ with expansion: 202 == 202 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -1365,7 +1366,7 @@ with expansion: 202 == 202 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -1383,7 +1384,7 @@ with expansion: 202 == 202 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -1401,7 +1402,7 @@ with expansion: 202 == 202 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -1419,7 +1420,7 @@ with expansion: 202 == 202 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -1437,7 +1438,7 @@ with expansion: 202 == 202 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -1455,7 +1456,7 @@ with expansion: 202 == 202 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -1473,7 +1474,7 @@ with expansion: 202 == 202 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -1491,7 +1492,7 @@ with expansion: 202 == 202 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -1509,7 +1510,7 @@ with expansion: 204 == 204 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -1527,7 +1528,7 @@ with expansion: 204 == 204 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -1545,7 +1546,7 @@ with expansion: 204 == 204 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -1563,7 +1564,7 @@ with expansion: 204 == 204 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -1581,7 +1582,7 @@ with expansion: 204 == 204 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -1599,7 +1600,7 @@ with expansion: 204 == 204 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -1617,7 +1618,7 @@ with expansion: 204 == 204 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -1635,7 +1636,7 @@ with expansion: 204 == 204 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -1653,7 +1654,7 @@ with expansion: 204 == 204 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -1671,7 +1672,7 @@ with expansion: 206 == 206 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -1689,7 +1690,7 @@ with expansion: 206 == 206 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -1707,7 +1708,7 @@ with expansion: 206 == 206 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -1725,7 +1726,7 @@ with expansion: 206 == 206 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -1743,7 +1744,7 @@ with expansion: 206 == 206 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -1761,7 +1762,7 @@ with expansion: 206 == 206 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -1779,7 +1780,7 @@ with expansion: 206 == 206 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -1797,7 +1798,7 @@ with expansion: 206 == 206 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -1815,7 +1816,7 @@ with expansion: 206 == 206 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -1833,7 +1834,7 @@ with expansion: 208 == 208 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -1851,7 +1852,7 @@ with expansion: 208 == 208 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -1869,7 +1870,7 @@ with expansion: 208 == 208 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -1887,7 +1888,7 @@ with expansion: 208 == 208 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -1905,7 +1906,7 @@ with expansion: 208 == 208 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -1923,7 +1924,7 @@ with expansion: 208 == 208 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -1941,7 +1942,7 @@ with expansion: 208 == 208 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -1959,7 +1960,7 @@ with expansion: 208 == 208 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -1977,7 +1978,7 @@ with expansion: 208 == 208 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -1995,7 +1996,7 @@ with expansion: 210 == 210 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -2013,7 +2014,7 @@ with expansion: 210 == 210 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -2031,7 +2032,7 @@ with expansion: 210 == 210 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -2049,7 +2050,7 @@ with expansion: 210 == 210 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -2067,7 +2068,7 @@ with expansion: 210 == 210 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -2085,7 +2086,7 @@ with expansion: 210 == 210 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -2103,7 +2104,7 @@ with expansion: 210 == 210 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -2121,7 +2122,7 @@ with expansion: 210 == 210 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -2139,7 +2140,7 @@ with expansion: 210 == 210 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -2157,7 +2158,7 @@ with expansion: 212 == 212 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -2175,7 +2176,7 @@ with expansion: 212 == 212 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -2193,7 +2194,7 @@ with expansion: 212 == 212 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -2211,7 +2212,7 @@ with expansion: 212 == 212 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -2229,7 +2230,7 @@ with expansion: 212 == 212 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -2247,7 +2248,7 @@ with expansion: 212 == 212 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -2265,7 +2266,7 @@ with expansion: 212 == 212 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -2283,7 +2284,7 @@ with expansion: 212 == 212 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -2301,7 +2302,7 @@ with expansion: 212 == 212 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -2319,7 +2320,7 @@ with expansion: 214 == 214 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -2337,7 +2338,7 @@ with expansion: 214 == 214 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -2355,7 +2356,7 @@ with expansion: 214 == 214 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -2373,7 +2374,7 @@ with expansion: 214 == 214 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -2391,7 +2392,7 @@ with expansion: 214 == 214 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -2409,7 +2410,7 @@ with expansion: 214 == 214 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -2427,7 +2428,7 @@ with expansion: 214 == 214 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -2445,7 +2446,7 @@ with expansion: 214 == 214 ------------------------------------------------------------------------------- -./succeeding/generators/1 +Generators over two ranges ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -2463,7 +2464,7 @@ with expansion: 214 == 214 ------------------------------------------------------------------------------- -./succeeding/generators/2 +Generator over a range of pairs ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -2475,7 +2476,7 @@ with expansion: 0 == 0 ------------------------------------------------------------------------------- -./succeeding/generators/2 +Generator over a range of pairs ------------------------------------------------------------------------------- GeneratorTests.cpp: ............................................................................... @@ -2487,7 +2488,7 @@ with expansion: 2 == 2 ------------------------------------------------------------------------------- -./succeeding/message +INFO and WARN do not abort tests ------------------------------------------------------------------------------- MessageTests.cpp: ............................................................................... @@ -2498,10 +2499,10 @@ warning: this is a warning -No assertions in test case './succeeding/message' +No assertions in test case 'INFO and WARN do not abort tests' ------------------------------------------------------------------------------- -./succeeding/succeed +SUCCEED counts as a test pass ------------------------------------------------------------------------------- MessageTests.cpp: ............................................................................... @@ -2512,7 +2513,7 @@ with message: this is a success ------------------------------------------------------------------------------- -./failing/message/info/1 +INFO gets logged on failure ------------------------------------------------------------------------------- MessageTests.cpp: ............................................................................... @@ -2526,7 +2527,7 @@ with messages: so should this ------------------------------------------------------------------------------- -./mixed/message/info/2 +INFO gets logged on failure, even if captured before successful assertions ------------------------------------------------------------------------------- MessageTests.cpp: ............................................................................... @@ -2562,7 +2563,7 @@ with message: but not this ------------------------------------------------------------------------------- -./failing/message/fail +FAIL aborts the test ------------------------------------------------------------------------------- MessageTests.cpp: ............................................................................... @@ -2572,7 +2573,7 @@ explicitly with message: This is a failure ------------------------------------------------------------------------------- -./failing/message/sections +Output from all sections is reported one ------------------------------------------------------------------------------- MessageTests.cpp: @@ -2583,7 +2584,7 @@ explicitly with message: Message from section one ------------------------------------------------------------------------------- -./failing/message/sections +Output from all sections is reported two ------------------------------------------------------------------------------- MessageTests.cpp: @@ -2595,7 +2596,7 @@ explicitly with message: Message from section one ------------------------------------------------------------------------------- -./succeeding/message/sections/stdout +Standard output from all sections is reported one ------------------------------------------------------------------------------- MessageTests.cpp: @@ -2606,7 +2607,7 @@ No assertions in section 'one' Message from section two ------------------------------------------------------------------------------- -./succeeding/message/sections/stdout +Standard output from all sections is reported two ------------------------------------------------------------------------------- MessageTests.cpp: @@ -2616,7 +2617,7 @@ MessageTests.cpp: No assertions in section 'two' ------------------------------------------------------------------------------- -./mixed/message/scoped +SCOPED_INFO is reset for each loop ------------------------------------------------------------------------------- MessageTests.cpp: ............................................................................... @@ -2720,7 +2721,7 @@ with messages: i := 10 ------------------------------------------------------------------------------- -./succeeding/nofail +The NO_FAIL macro reports a failure but does not fail the test ------------------------------------------------------------------------------- MessageTests.cpp: ............................................................................... @@ -2730,7 +2731,7 @@ FAILED - but was ok: CHECK_NOFAIL( 1 == 2 ) -No assertions in test case './succeeding/nofail' +No assertions in test case 'The NO_FAIL macro reports a failure but does not fail the test' ------------------------------------------------------------------------------- just info @@ -2752,7 +2753,19 @@ explicitly with message: Previous info should not be seen ------------------------------------------------------------------------------- -./succeeding/Misc/Sections +sends information to INFO +------------------------------------------------------------------------------- +MessageTests.cpp: +............................................................................... + +MessageTests.cpp:: FAILED: + REQUIRE( false ) +with messages: + hi + i := 7 + +------------------------------------------------------------------------------- +random SECTION tests s1 ------------------------------------------------------------------------------- MiscTests.cpp: @@ -2771,7 +2784,7 @@ with expansion: 2 != 1 ------------------------------------------------------------------------------- -./succeeding/Misc/Sections +random SECTION tests s2 ------------------------------------------------------------------------------- MiscTests.cpp: @@ -2784,7 +2797,7 @@ with expansion: 1 != 2 ------------------------------------------------------------------------------- -./succeeding/Misc/Sections/nested +nested SECTION tests s1 ------------------------------------------------------------------------------- MiscTests.cpp: @@ -2803,7 +2816,7 @@ with expansion: 2 != 1 ------------------------------------------------------------------------------- -./succeeding/Misc/Sections/nested +nested SECTION tests s1 ------------------------------------------------------------------------------- MiscTests.cpp: @@ -2822,7 +2835,7 @@ with expansion: 2 != 1 ------------------------------------------------------------------------------- -./succeeding/Misc/Sections/nested +nested SECTION tests s1 s2 ------------------------------------------------------------------------------- @@ -2836,7 +2849,7 @@ with expansion: 1 != 2 ------------------------------------------------------------------------------- -./mixed/Misc/Sections/nested2 +more nested SECTION tests s1 s2 ------------------------------------------------------------------------------- @@ -2849,7 +2862,7 @@ with expansion: 1 == 2 ------------------------------------------------------------------------------- -./mixed/Misc/Sections/nested2 +more nested SECTION tests s1 s3 ------------------------------------------------------------------------------- @@ -2863,7 +2876,7 @@ with expansion: 1 != 2 ------------------------------------------------------------------------------- -./mixed/Misc/Sections/nested2 +more nested SECTION tests s1 s4 ------------------------------------------------------------------------------- @@ -2877,7 +2890,7 @@ with expansion: 1 < 2 ------------------------------------------------------------------------------- -./Sections/nested/a/b +even more nested SECTION tests c d (leaf) ------------------------------------------------------------------------------- @@ -2888,7 +2901,7 @@ MiscTests.cpp: No assertions in section 'd (leaf)' ------------------------------------------------------------------------------- -./Sections/nested/a/b +even more nested SECTION tests c e (leaf) ------------------------------------------------------------------------------- @@ -2899,7 +2912,7 @@ MiscTests.cpp: No assertions in section 'e (leaf)' ------------------------------------------------------------------------------- -./Sections/nested/a/b +even more nested SECTION tests f (leaf) ------------------------------------------------------------------------------- MiscTests.cpp: @@ -2909,7 +2922,7 @@ MiscTests.cpp: No assertions in section 'f (leaf)' ------------------------------------------------------------------------------- -./mixed/Misc/Sections/loops +looped SECTION tests s1 ------------------------------------------------------------------------------- MiscTests.cpp: @@ -2921,7 +2934,7 @@ with expansion: 0 > 1 ------------------------------------------------------------------------------- -./mixed/Misc/loops +looped tests ------------------------------------------------------------------------------- MiscTests.cpp: ............................................................................... @@ -2987,16 +3000,16 @@ with message: Some information An error ------------------------------------------------------------------------------- -./succeeding/Misc/stdout,stderr +Sends stuff to stdout and stderr ------------------------------------------------------------------------------- MiscTests.cpp: ............................................................................... -No assertions in test case './succeeding/Misc/stdout,stderr' +No assertions in test case 'Sends stuff to stdout and stderr' ------------------------------------------------------------------------------- -./succeeding/Misc/null strings +null strings ------------------------------------------------------------------------------- MiscTests.cpp: ............................................................................... @@ -3014,19 +3027,7 @@ with expansion: {null string} == {null string} ------------------------------------------------------------------------------- -./failing/info -------------------------------------------------------------------------------- -MiscTests.cpp: -............................................................................... - -MiscTests.cpp:: FAILED: - REQUIRE( false ) -with messages: - hi - i := 7 - -------------------------------------------------------------------------------- -./succeeding/checkedif +checkedIf ------------------------------------------------------------------------------- MiscTests.cpp: ............................................................................... @@ -3044,7 +3045,7 @@ with expansion: true ------------------------------------------------------------------------------- -./failing/checkedif +checkedIf, failing ------------------------------------------------------------------------------- MiscTests.cpp: ............................................................................... @@ -3060,7 +3061,7 @@ with expansion: false ------------------------------------------------------------------------------- -./succeeding/checkedelse +checkedElse ------------------------------------------------------------------------------- MiscTests.cpp: ............................................................................... @@ -3078,7 +3079,7 @@ with expansion: true ------------------------------------------------------------------------------- -./failing/checkedelse +checkedElse, failing ------------------------------------------------------------------------------- MiscTests.cpp: ............................................................................... @@ -3094,7 +3095,7 @@ with expansion: false ------------------------------------------------------------------------------- -./misc/xmlentitycheck +xmlentitycheck embedded xml ------------------------------------------------------------------------------- MiscTests.cpp: @@ -3104,7 +3105,7 @@ MiscTests.cpp: No assertions in section 'embedded xml' ------------------------------------------------------------------------------- -./misc/xmlentitycheck +xmlentitycheck encoded chars ------------------------------------------------------------------------------- MiscTests.cpp: @@ -3114,7 +3115,7 @@ MiscTests.cpp: No assertions in section 'encoded chars' ------------------------------------------------------------------------------- -./manual/onechar +send a single char to INFO ------------------------------------------------------------------------------- MiscTests.cpp: ............................................................................... @@ -3125,7 +3126,7 @@ with message: 3 ------------------------------------------------------------------------------- -./succeeding/atomic if +atomic if ------------------------------------------------------------------------------- MiscTests.cpp: ............................................................................... @@ -3137,7 +3138,7 @@ with expansion: 0 == 0 ------------------------------------------------------------------------------- -./succeeding/matchers +String matchers ------------------------------------------------------------------------------- MiscTests.cpp: ............................................................................... @@ -3167,7 +3168,7 @@ with expansion: "this string contains 'abc' as a substring" ends with: "substring" ------------------------------------------------------------------------------- -./failing/matchers/Contains +Contains string matcher ------------------------------------------------------------------------------- MiscTests.cpp: ............................................................................... @@ -3178,7 +3179,7 @@ with expansion: "this string contains 'abc' as a substring" contains: "not there" ------------------------------------------------------------------------------- -./failing/matchers/StartsWith +StartsWith string matcher ------------------------------------------------------------------------------- MiscTests.cpp: ............................................................................... @@ -3189,7 +3190,7 @@ with expansion: "this string contains 'abc' as a substring" starts with: "string" ------------------------------------------------------------------------------- -./failing/matchers/EndsWith +EndsWith string matcher ------------------------------------------------------------------------------- MiscTests.cpp: ............................................................................... @@ -3200,7 +3201,7 @@ with expansion: "this string contains 'abc' as a substring" ends with: "this" ------------------------------------------------------------------------------- -./failing/matchers/Equals +Equals string matcher ------------------------------------------------------------------------------- MiscTests.cpp: ............................................................................... @@ -3211,7 +3212,7 @@ with expansion: "this string contains 'abc' as a substring" equals: "something else" ------------------------------------------------------------------------------- -string +Equals string matcher, with NULL ------------------------------------------------------------------------------- MiscTests.cpp: ............................................................................... @@ -3223,7 +3224,7 @@ with expansion: "" equals: "" ------------------------------------------------------------------------------- -./succeeding/matchers/AllOf +AllOf matcher ------------------------------------------------------------------------------- MiscTests.cpp: ............................................................................... @@ -3236,7 +3237,7 @@ with expansion: contains: "abc" ) ------------------------------------------------------------------------------- -./succeeding/matchers/AnyOf +AnyOf matcher ------------------------------------------------------------------------------- MiscTests.cpp: ............................................................................... @@ -3256,7 +3257,7 @@ with expansion: contains: "string" ) ------------------------------------------------------------------------------- -./succeeding/matchers/Equals +Equals ------------------------------------------------------------------------------- MiscTests.cpp: ............................................................................... @@ -3305,13 +3306,13 @@ with expansion: 0x == 3628800 ------------------------------------------------------------------------------- -empty +An empty test with no assertions ------------------------------------------------------------------------------- MiscTests.cpp: ............................................................................... -No assertions in test case 'empty' +No assertions in test case 'An empty test with no assertions' ------------------------------------------------------------------------------- Nice descriptive name @@ -3562,7 +3563,7 @@ with expansion: 5 >= 5 ------------------------------------------------------------------------------- -./failing/CatchSectionInfiniteLoop +A couple of nested sections followed by a failure ------------------------------------------------------------------------------- MiscTests.cpp: ............................................................................... @@ -3572,7 +3573,7 @@ explicitly with message: to infinity and beyond ------------------------------------------------------------------------------- -./failing/CatchSectionInfiniteLoop +A couple of nested sections followed by a failure ------------------------------------------------------------------------------- MiscTests.cpp: ............................................................................... @@ -3582,7 +3583,7 @@ explicitly with message: to infinity and beyond ------------------------------------------------------------------------------- -./failing/CatchSectionInfiniteLoop +A couple of nested sections followed by a failure Outer Inner ------------------------------------------------------------------------------- @@ -3595,7 +3596,7 @@ with message: that's not flying - that's failing in style ------------------------------------------------------------------------------- -./failing/CatchSectionInfiniteLoop +A couple of nested sections followed by a failure ------------------------------------------------------------------------------- MiscTests.cpp: ............................................................................... @@ -3604,458 +3605,6 @@ MiscTests.cpp:: FAILED: explicitly with message: to infinity and beyond -------------------------------------------------------------------------------- -selftest/main - selftest/expected result - selftest/expected result/failing tests -------------------------------------------------------------------------------- -TestMain.cpp: -............................................................................... - -catch_self_test.hpp:: -PASSED: -with message: - Tests failed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests failed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests failed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests failed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests failed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests failed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests failed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests failed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests failed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests failed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests failed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests failed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests failed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests failed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests failed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests failed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests failed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests failed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests failed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests failed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests failed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests failed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests failed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests failed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests failed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests failed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests failed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests failed, as expected - -------------------------------------------------------------------------------- -selftest/main - selftest/expected result - selftest/expected result/succeeding tests -------------------------------------------------------------------------------- -TestMain.cpp: -............................................................................... - -catch_self_test.hpp:: -PASSED: -with message: - Tests passed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests passed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests passed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests passed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests passed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests passed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests passed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests passed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests passed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests passed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests passed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests passed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests passed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests passed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests passed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests passed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests passed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests passed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests passed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests passed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests passed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests passed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests passed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests passed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests passed, as expected - -Message from section one -Message from section two -catch_self_test.hpp:: -PASSED: -with message: - Tests passed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests passed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests passed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests passed, as expected - -Some information -An error -catch_self_test.hpp:: -PASSED: -with message: - Tests passed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests passed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests passed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests passed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests passed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests passed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests passed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests passed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests passed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests passed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests passed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests passed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests passed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests passed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests passed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests passed, as expected - -catch_self_test.hpp:: -PASSED: -with message: - Tests passed, as expected - -Message from section one -Message from section two -Some information -An error -------------------------------------------------------------------------------- -selftest/main - selftest/test counts - selftest/test counts/succeeding tests -------------------------------------------------------------------------------- -TestMain.cpp: -............................................................................... - -TestMain.cpp:: -PASSED: - CHECK( totals.assertions.passed == 298 ) -with expansion: - 298 == 298 - -TestMain.cpp:: -PASSED: - CHECK( totals.assertions.failed == 0 ) -with expansion: - 0 == 0 - -------------------------------------------------------------------------------- -selftest/main - selftest/test counts - selftest/test counts/failing tests -------------------------------------------------------------------------------- -TestMain.cpp: -............................................................................... - -TestMain.cpp:: -PASSED: - CHECK( totals.assertions.passed == 2 ) -with expansion: - 2 == 2 - -TestMain.cpp:: -PASSED: - CHECK( totals.assertions.failed == 77 ) -with expansion: - 77 == 77 - -------------------------------------------------------------------------------- -meta/Misc/Sections -------------------------------------------------------------------------------- -TestMain.cpp: -............................................................................... - -TestMain.cpp:: -PASSED: - CHECK( totals.assertions.passed == 2 ) -with expansion: - 2 == 2 - -TestMain.cpp:: -PASSED: - CHECK( totals.assertions.failed == 1 ) -with expansion: - 1 == 1 - ------------------------------------------------------------------------------- Process can be configured on command line default - no arguments @@ -6414,7 +5963,7 @@ with expansion: ... message truncated due to excessive size ------------------------------------------------------------------------------- -./succeeding/Tricky/std::pair +Parsing a std::pair ------------------------------------------------------------------------------- TrickyTests.cpp: ............................................................................... @@ -6426,7 +5975,7 @@ with expansion: std::pair( 1, 2 ) == std::pair( 1, 2 ) ------------------------------------------------------------------------------- -./inprogress/failing/Tricky/trailing expression +Where the is more to the expression after the RHS[failing] ------------------------------------------------------------------------------- TrickyTests.cpp: ............................................................................... @@ -6437,10 +5986,10 @@ warning: error -No assertions in test case './inprogress/failing/Tricky/trailing expression' +No assertions in test case 'Where the is more to the expression after the RHS[failing]' ------------------------------------------------------------------------------- -./inprogress/failing/Tricky/compound lhs +Where the LHS is not a simple value[failing] ------------------------------------------------------------------------------- TrickyTests.cpp: ............................................................................... @@ -6451,10 +6000,10 @@ warning: error -No assertions in test case './inprogress/failing/Tricky/compound lhs' +No assertions in test case 'Where the LHS is not a simple value[failing]' ------------------------------------------------------------------------------- -./failing/Tricky/non streamable type +A failing expression with a non streamable type is still captured[failing] ------------------------------------------------------------------------------- TrickyTests.cpp: ............................................................................... @@ -6470,7 +6019,7 @@ with expansion: {?} == {?} ------------------------------------------------------------------------------- -./failing/string literals +string literals of different sizes can be compared[failing] ------------------------------------------------------------------------------- TrickyTests.cpp: ............................................................................... @@ -6481,7 +6030,7 @@ with expansion: "first" == "second" ------------------------------------------------------------------------------- -./succeeding/side-effects +An expression with side-effects should only be evaluated once ------------------------------------------------------------------------------- TrickyTests.cpp: ............................................................................... @@ -6499,7 +6048,7 @@ with expansion: 8 == 8 ------------------------------------------------------------------------------- -./succeeding/koenig +Operators at different namespace levels not hijacked by Koenig lookup ------------------------------------------------------------------------------- TrickyTests.cpp: ............................................................................... @@ -6511,7 +6060,7 @@ with expansion: 0x == {?} ------------------------------------------------------------------------------- -./succeeding/non-const== +Demonstrate that a non-const == is not used ------------------------------------------------------------------------------- TrickyTests.cpp: ............................................................................... @@ -6523,7 +6072,7 @@ with expansion: {?} == 1 ------------------------------------------------------------------------------- -./succeeding/enum/bits +Test enum bit values ------------------------------------------------------------------------------- TrickyTests.cpp: ............................................................................... @@ -6535,7 +6084,7 @@ with expansion: 0x == 3221225472 ------------------------------------------------------------------------------- -./succeeding/boolean member +boolean member ------------------------------------------------------------------------------- TrickyTests.cpp: ............................................................................... @@ -6547,7 +6096,7 @@ with expansion: 0x != 0 ------------------------------------------------------------------------------- -./succeeding/unimplemented static bool +(unimplemented) static bools can be evaluated compare to true ------------------------------------------------------------------------------- TrickyTests.cpp: @@ -6566,7 +6115,7 @@ with expansion: true == true ------------------------------------------------------------------------------- -./succeeding/unimplemented static bool +(unimplemented) static bools can be evaluated compare to false ------------------------------------------------------------------------------- TrickyTests.cpp: @@ -6585,7 +6134,7 @@ with expansion: false == false ------------------------------------------------------------------------------- -./succeeding/unimplemented static bool +(unimplemented) static bools can be evaluated negation ------------------------------------------------------------------------------- TrickyTests.cpp: @@ -6598,7 +6147,7 @@ with expansion: true ------------------------------------------------------------------------------- -./succeeding/unimplemented static bool +(unimplemented) static bools can be evaluated double negation ------------------------------------------------------------------------------- TrickyTests.cpp: @@ -6611,7 +6160,7 @@ with expansion: true ------------------------------------------------------------------------------- -./succeeding/unimplemented static bool +(unimplemented) static bools can be evaluated direct ------------------------------------------------------------------------------- TrickyTests.cpp: @@ -6630,7 +6179,7 @@ with expansion: !false ------------------------------------------------------------------------------- -./succeeding/SafeBool +Objects that evaluated in boolean contexts can be checked ------------------------------------------------------------------------------- TrickyTests.cpp: ............................................................................... @@ -7574,5 +7123,5 @@ with expansion: true =============================================================================== -122 test cases - 50 failed (772 assertions - 109 failed) +120 test cases - 50 failed (692 assertions - 109 failed) diff --git a/projects/SelfTest/Baselines/console.swa4.approved.txt b/projects/SelfTest/Baselines/console.swa4.approved.txt index aa5e2493..65a96d7d 100644 --- a/projects/SelfTest/Baselines/console.swa4.approved.txt +++ b/projects/SelfTest/Baselines/console.swa4.approved.txt @@ -4,7 +4,7 @@ CatchSelfTest is a host application. Run with -? for options ------------------------------------------------------------------------------- -./succeeding/Approx/simple +Some simple comparisons between doubles ------------------------------------------------------------------------------- ApproxTests.cpp: ............................................................................... @@ -46,7 +46,7 @@ with expansion: Approx( 1.23 ) != 1.24 ------------------------------------------------------------------------------- -./succeeding/Approx/epsilon +Approximate comparisons with different epsilons ------------------------------------------------------------------------------- ApproxTests.cpp: ............................................................................... @@ -64,7 +64,7 @@ with expansion: 1.23 == Approx( 1.231 ) ------------------------------------------------------------------------------- -./succeeding/Approx/float +Approximate comparisons with floats ------------------------------------------------------------------------------- ApproxTests.cpp: ............................................................................... @@ -82,7 +82,7 @@ with expansion: 0 == Approx( 0 ) ------------------------------------------------------------------------------- -./succeeding/Approx/int +Approximate comparisons with ints ------------------------------------------------------------------------------- ApproxTests.cpp: ............................................................................... @@ -96,7 +96,7 @@ PASSED: REQUIRE( 0 == Approx( 0 ) ) ------------------------------------------------------------------------------- -./succeeding/Approx/mixed +Approximate comparisons with mixed numeric types ------------------------------------------------------------------------------- ApproxTests.cpp: ............................................................................... @@ -132,7 +132,7 @@ with expansion: 1.234 == Approx( 1.234 ) ------------------------------------------------------------------------------- -./succeeding/Approx/custom +Use a custom approx ------------------------------------------------------------------------------- ApproxTests.cpp: ............................................................................... @@ -204,7 +204,7 @@ with expansion: 3.1428571429 != Approx( 3.141 ) ------------------------------------------------------------------------------- -./succeeding/TestClass/succeedingCase +A METHOD_AS_TEST_CASE based test run that succeeds ------------------------------------------------------------------------------- ClassTests.cpp: ............................................................................... @@ -216,7 +216,7 @@ with expansion: "hello" == "hello" ------------------------------------------------------------------------------- -./failing/TestClass/failingCase +A METHOD_AS_TEST_CASE based test run that fails ------------------------------------------------------------------------------- ClassTests.cpp: ............................................................................... @@ -227,7 +227,7 @@ with expansion: "hello" == "world" ------------------------------------------------------------------------------- -./succeeding/Fixture/succeedingCase +A TEST_CASE_METHOD based test run that succeeds ------------------------------------------------------------------------------- ClassTests.cpp: ............................................................................... @@ -239,7 +239,7 @@ with expansion: 1 == 1 ------------------------------------------------------------------------------- -./failing/Fixture/failingCase +A TEST_CASE_METHOD based test run that fails ------------------------------------------------------------------------------- ClassTests.cpp: ............................................................................... @@ -250,7 +250,7 @@ with expansion: 1 == 2 ------------------------------------------------------------------------------- -./succeeding/conditions/equality +Equality checks that should succeed ------------------------------------------------------------------------------- ConditionTests.cpp: ............................................................................... @@ -298,7 +298,7 @@ with expansion: 1.3 == Approx( 1.3 ) ------------------------------------------------------------------------------- -./failing/conditions/equality +Equality checks that should fail] ------------------------------------------------------------------------------- ConditionTests.cpp: ............................................................................... diff --git a/projects/SelfTest/Baselines/junit.sw.approved.txt b/projects/SelfTest/Baselines/junit.sw.approved.txt index b292d258..0bb7c778 100644 --- a/projects/SelfTest/Baselines/junit.sw.approved.txt +++ b/projects/SelfTest/Baselines/junit.sw.approved.txt @@ -1,26 +1,26 @@ - - - - - - - + + + + + + + - - + + ClassTests.cpp: - - + + ClassTests.cpp: - - + + ConditionTests.cpp: @@ -61,8 +61,8 @@ ConditionTests.cpp: ConditionTests.cpp: - - + + ConditionTests.cpp: @@ -79,8 +79,8 @@ ConditionTests.cpp: ConditionTests.cpp: - - + + ConditionTests.cpp: @@ -139,14 +139,14 @@ ConditionTests.cpp: ConditionTests.cpp: - - - - - - - - + + + + + + + + ConditionTests.cpp: @@ -172,8 +172,8 @@ ConditionTests.cpp: ConditionTests.cpp: - - + + expected exception ExceptionTests.cpp: @@ -186,67 +186,67 @@ expected exception ExceptionTests.cpp: - + unexpected exception ExceptionTests.cpp: - + unexpected exception ExceptionTests.cpp: - + unexpected exception ExceptionTests.cpp: - + expected exception ExceptionTests.cpp: - + custom exception ExceptionTests.cpp: - + custom exception - not std ExceptionTests.cpp: - + custom exception - not std ExceptionTests.cpp: - + 3.14 ExceptionTests.cpp: - - - - - - + + + + + + this message should be logged so should this MessageTests.cpp: - + this message should be logged MessageTests.cpp: @@ -256,61 +256,68 @@ and this, but later MessageTests.cpp: - + This is a failure MessageTests.cpp: - + Message from section one MessageTests.cpp: - + Message from section two MessageTests.cpp: - + Message from section one Message from section two - + current counter 10 i := 10 MessageTests.cpp: - + Previous info should not be seen MessageTests.cpp: - - - - - + + +hi +i := 7 +MessageTests.cpp: + + + + + + + MiscTests.cpp: - - - + + + MiscTests.cpp: - + Testing if fib[0] (1) is even MiscTests.cpp: @@ -336,7 +343,7 @@ Testing if fib[7] (21) is even MiscTests.cpp: - + Some information @@ -344,16 +351,9 @@ Some information An error - - - -hi -i := 7 -MiscTests.cpp: - - - - + + + MiscTests.cpp: @@ -361,8 +361,8 @@ MiscTests.cpp: MiscTests.cpp: - - + + MiscTests.cpp: @@ -370,38 +370,38 @@ MiscTests.cpp: MiscTests.cpp: - + 3 MiscTests.cpp: - - - + + + MiscTests.cpp: - + MiscTests.cpp: - + MiscTests.cpp: - + MiscTests.cpp: - - - - + + + + @@ -410,7 +410,7 @@ MiscTests.cpp: - + to infinity and beyond MiscTests.cpp: @@ -424,25 +424,7 @@ to infinity and beyond MiscTests.cpp: - - - - - - -Message from section one -Message from section two -Some information -Message from section one -Message from section two -Some information - - -An error -An error - - - + @@ -493,10 +475,10 @@ hello - - - - + + + + TrickyTests.cpp: @@ -504,22 +486,22 @@ TrickyTests.cpp: TrickyTests.cpp: - + TrickyTests.cpp: - - - - - - - - - - - + + + + + + + + + + + @@ -563,18 +545,10 @@ TrickyTests.cpp: Message from section one Message from section two Some information -Message from section one -Message from section two -Some information -Message from section one -Message from section two -Some information hello hello -An error -An error An error diff --git a/projects/SelfTest/Baselines/xml.sw.approved.txt b/projects/SelfTest/Baselines/xml.sw.approved.txt index 2a2c41de..ded8c1f2 100644 --- a/projects/SelfTest/Baselines/xml.sw.approved.txt +++ b/projects/SelfTest/Baselines/xml.sw.approved.txt @@ -1,6 +1,6 @@ - + d == Approx( 1.23 ) @@ -51,7 +51,7 @@ - + d != Approx( 1.231 ) @@ -70,7 +70,7 @@ - + 1.23f == Approx( 1.23f ) @@ -89,7 +89,7 @@ - + 1 == Approx( 1 ) @@ -108,7 +108,7 @@ - + 1.0f == Approx( 1 ) @@ -151,7 +151,7 @@ - + d == approx( 1.23 ) @@ -237,7 +237,7 @@ - + s == "hello" @@ -248,7 +248,7 @@ - + s == "world" @@ -259,7 +259,7 @@ - + m_a == 1 @@ -270,7 +270,7 @@ - + m_a == 2 @@ -281,7 +281,7 @@ - + data.int_seven == 7 @@ -340,7 +340,7 @@ - + data.int_seven == 6 @@ -447,7 +447,7 @@ - + data.int_seven != 6 @@ -538,7 +538,7 @@ - + data.int_seven != 7 @@ -581,7 +581,7 @@ - + data.int_seven < 8 @@ -720,7 +720,7 @@ - + data.int_seven > 7 @@ -875,7 +875,7 @@ - + i == 1 @@ -982,7 +982,7 @@ - + long_var == unsigned_char_var @@ -1017,7 +1017,7 @@ - + unsigned_char_var == 1 @@ -1052,7 +1052,7 @@ - + ( -1 > 2u ) @@ -1103,7 +1103,7 @@ - + 54 == 6*9 @@ -1114,7 +1114,7 @@ - + p == __null @@ -1181,7 +1181,7 @@ - + false == false @@ -1248,7 +1248,7 @@ - + false != false @@ -1315,7 +1315,7 @@ - + thisThrows() @@ -1342,7 +1342,7 @@ - + thisThrows() @@ -1375,13 +1375,13 @@ - + unexpected exception - + 1 == 1 @@ -1403,7 +1403,7 @@ - +
unexpected exception @@ -1412,7 +1412,7 @@
- + thisThrows() == 0 @@ -1426,16 +1426,16 @@ - + - + custom exception - + throwCustom() @@ -1449,7 +1449,7 @@ - + throwCustom() @@ -1463,13 +1463,13 @@ - + 3.14 - + thisFunctionNotImplemented( 7 ) @@ -1480,7 +1480,7 @@ - + multiply( i, 2 ) == i*2 @@ -2635,7 +2635,7 @@ - + i->first == i->second-1 @@ -2654,7 +2654,7 @@ - + this is a message @@ -2663,10 +2663,10 @@ - + - + this message should be logged @@ -2683,7 +2683,7 @@ - + a == 2 @@ -2724,13 +2724,13 @@ - + This is a failure - +
Message from section one @@ -2745,7 +2745,7 @@
- +
@@ -2754,7 +2754,7 @@
- + i < 10 @@ -2851,7 +2851,7 @@ - + 1 == 2 @@ -2871,7 +2871,24 @@ - + + + hi + + + i := 7 + + + + false + + + false + + + + +
@@ -2904,7 +2921,7 @@
- +
@@ -2956,7 +2973,7 @@
- +
@@ -3004,7 +3021,7 @@
- +
@@ -3025,7 +3042,7 @@
- +
@@ -3039,7 +3056,7 @@
- + Testing if fib[0] (1) is even @@ -3124,10 +3141,10 @@ - + - + makeString( false ) != static_cast<char*>(__null) @@ -3146,24 +3163,7 @@ - - - hi - - - i := 7 - - - - false - - - false - - - - - + flag @@ -3182,7 +3182,7 @@ - + flag @@ -3201,7 +3201,7 @@ - + flag @@ -3220,7 +3220,7 @@ - + flag @@ -3239,7 +3239,7 @@ - +
@@ -3248,7 +3248,7 @@
- + 3 @@ -3262,7 +3262,7 @@ - + x == 0 @@ -3273,7 +3273,7 @@ - + testStringForMatching() Contains( "string" ) @@ -3308,7 +3308,7 @@ - + testStringForMatching() Contains( "not there" ) @@ -3319,7 +3319,7 @@ - + testStringForMatching() StartsWith( "string" ) @@ -3330,7 +3330,7 @@ - + testStringForMatching() EndsWith( "this" ) @@ -3341,7 +3341,7 @@ - + testStringForMatching() Equals( "something else" ) @@ -3352,7 +3352,7 @@ - + "" Equals(__null) @@ -3363,7 +3363,7 @@ - + testStringForMatching() AllOf( Catch::Contains( "string" ), Catch::Contains( "abc" ) ) @@ -3374,7 +3374,7 @@ - + testStringForMatching() AnyOf( Catch::Contains( "string" ), Catch::Contains( "not there" ) ) @@ -3393,7 +3393,7 @@ - + testStringForMatching() Equals( "this string contains 'abc' as a substring" ) @@ -3447,7 +3447,7 @@ - + @@ -3667,7 +3667,7 @@ - + to infinity and beyond @@ -3688,90 +3688,6 @@ - -
- -
-
-
- -
- -
-
-
- -
- -
-
- -
-
-
- - - totals.assertions.passed == 298 - - - 298 == 298 - - - - - totals.assertions.failed == 0 - - - 0 == 0 - - - -
- -
-
-
- - - totals.assertions.passed == 2 - - - 2 == 2 - - - - - totals.assertions.failed == 77 - - - 77 == 77 - - - -
- -
- -
- - - - totals.assertions.passed == 2 - - - 2 == 2 - - - - - totals.assertions.failed == 1 - - - 1 == 1 - - - -
@@ -6374,7 +6290,7 @@ there" - + (std::pair<int, int>( 1, 2 )) == aNicePair @@ -6385,19 +6301,19 @@ there" - + Uncomment the code in this test to check that it gives a sensible compiler error - + Uncomment the code in this test to check that it gives a sensible compiler error - + &o1 == &o2 @@ -6416,7 +6332,7 @@ there" - + std::string( "first" ) == "second" @@ -6427,7 +6343,7 @@ there" - + i++ == 7 @@ -6446,7 +6362,7 @@ there" - + 0x == o @@ -6457,7 +6373,7 @@ there" - + t == 1u @@ -6468,7 +6384,7 @@ there" - + 0x == bit30and31 @@ -6479,7 +6395,7 @@ there" - + obj.prop != __null @@ -6490,7 +6406,7 @@ there" - +
@@ -6572,7 +6488,7 @@ there"
- + True @@ -7482,7 +7398,7 @@ there"
- +
- +
diff --git a/projects/SelfTest/ClassTests.cpp b/projects/SelfTest/ClassTests.cpp index 573f5aaa..e22f3d24 100644 --- a/projects/SelfTest/ClassTests.cpp +++ b/projects/SelfTest/ClassTests.cpp @@ -31,8 +31,8 @@ namespace } -METHOD_AS_TEST_CASE( TestClass::succeedingCase, "./succeeding/TestClass/succeedingCase", "A method based test run that succeeds [class]" ) -METHOD_AS_TEST_CASE( TestClass::failingCase, "./failing/TestClass/failingCase", "A method based test run that fails [class]" ) +METHOD_AS_TEST_CASE( TestClass::succeedingCase, "A METHOD_AS_TEST_CASE based test run that succeeds", "[class]" ) +METHOD_AS_TEST_CASE( TestClass::failingCase, "A METHOD_AS_TEST_CASE based test run that fails", "[.][class][failing]" ) struct Fixture @@ -42,7 +42,7 @@ struct Fixture int m_a; }; -TEST_CASE_METHOD( Fixture, "./succeeding/Fixture/succeedingCase", "A method based test run that succeeds [class]" ) +TEST_CASE_METHOD( Fixture, "A TEST_CASE_METHOD based test run that succeeds", "[class]" ) { REQUIRE( m_a == 1 ); } @@ -50,7 +50,7 @@ TEST_CASE_METHOD( Fixture, "./succeeding/Fixture/succeedingCase", "A method base // We should be able to write our tests within a different namespace namespace Inner { - TEST_CASE_METHOD( Fixture, "./failing/Fixture/failingCase", "A method based test run that fails [class]" ) + TEST_CASE_METHOD( Fixture, "A TEST_CASE_METHOD based test run that fails", "[.][class][failing]" ) { REQUIRE( m_a == 2 ); } diff --git a/projects/SelfTest/ConditionTests.cpp b/projects/SelfTest/ConditionTests.cpp index b298de1d..a2dabfa1 100644 --- a/projects/SelfTest/ConditionTests.cpp +++ b/projects/SelfTest/ConditionTests.cpp @@ -43,8 +43,7 @@ struct TestDef { // This allows us to see all results, even if an earlier check fails // Equality tests -TEST_CASE( "./succeeding/conditions/equality", - "Equality checks that should succeed" ) +TEST_CASE( "Equality checks that should succeed", "" ) { TestDef td; @@ -63,8 +62,7 @@ TEST_CASE( "./succeeding/conditions/equality", REQUIRE( x == Approx( 1.3 ) ); } -TEST_CASE( "./failing/conditions/equality", - "Equality checks that should fail" ) +TEST_CASE( "Equality checks that should fail]", "[.][failing]" ) { TestData data; @@ -85,8 +83,7 @@ TEST_CASE( "./failing/conditions/equality", CHECK( x == Approx( 1.301 ) ); } -TEST_CASE( "./succeeding/conditions/inequality", - "Inequality checks that should succeed" ) +TEST_CASE( "Inequality checks that should succeed", "" ) { TestData data; @@ -103,8 +100,7 @@ TEST_CASE( "./succeeding/conditions/inequality", REQUIRE( data.str_hello.size() != 6 ); } -TEST_CASE( "./failing/conditions/inequality", - "Inequality checks that should fails" ) +TEST_CASE( "Inequality checks that should fails", "[.][failing]" ) { TestData data; @@ -116,8 +112,7 @@ TEST_CASE( "./failing/conditions/inequality", } // Ordering comparison tests -TEST_CASE( "./succeeding/conditions/ordered", - "Ordering comparison checks that should succeed" ) +TEST_CASE( "Ordering comparison checks that should succeed", "" ) { TestData data; @@ -144,8 +139,7 @@ TEST_CASE( "./succeeding/conditions/ordered", REQUIRE( data.str_hello > "a" ); } -TEST_CASE( "./failing/conditions/ordered", - "Ordering comparison checks that should fail" ) +TEST_CASE( "Ordering comparison checks that should fail", "[.][failing]" ) { TestData data; @@ -175,8 +169,7 @@ TEST_CASE( "./failing/conditions/ordered", } // Comparisons with int literals -TEST_CASE( "./succeeding/conditions/int literals", - "Comparisons with int literals don't warn when mixing signed/ unsigned" ) +TEST_CASE( "Comparisons with int literals don't warn when mixing signed/ unsigned", "" ) { int i = 1; unsigned int ui = 2; @@ -214,8 +207,7 @@ TEST_CASE( "./succeeding/conditions/int literals", #pragma warning(disable:4389) // '==' : signed/unsigned mismatch #endif -TEST_CASE( "./succeeding/conditions//long_to_unsigned_x", - "comparisons between int variables" ) +TEST_CASE( "comparisons between int variables", "" ) { long long_var = 1L; unsigned char unsigned_char_var = 1; @@ -229,8 +221,7 @@ TEST_CASE( "./succeeding/conditions//long_to_unsigned_x", REQUIRE( long_var == unsigned_long_var ); } -TEST_CASE( "./succeeding/conditions/const ints to int literal", - "comparisons between const int variables" ) +TEST_CASE( "comparisons between const int variables", "" ) { const unsigned char unsigned_char_var = 1; const unsigned short unsigned_short_var = 1; @@ -243,8 +234,7 @@ TEST_CASE( "./succeeding/conditions/const ints to int literal", REQUIRE( unsigned_long_var == 1 ); } -TEST_CASE( "./succeeding/conditions/negative ints", - "Comparisons between unsigned ints and negative signed ints match c++ standard behaviour" ) +TEST_CASE( "Comparisons between unsigned ints and negative signed ints match c++ standard behaviour", "" ) { CHECK( ( -1 > 2u ) ); CHECK( -1 > 2u ); @@ -266,8 +256,7 @@ struct Ex T operator * ( const T& ) const { return T(); } }; -TEST_CASE( "./succeeding/conditions/computed ints", - "Comparisons between ints where one side is computed" ) +TEST_CASE( "Comparisons between ints where one side is computed", "" ) { CHECK( 54 == 6*9 ); } @@ -279,8 +268,7 @@ TEST_CASE( "./succeeding/conditions/computed ints", inline const char* returnsConstNull(){ return NULL; } inline char* returnsNull(){ return NULL; } -TEST_CASE( "./succeeding/conditions/ptr", - "Pointers can be compared to null" ) +TEST_CASE( "Pointers can be compared to null", "" ) { TestData* p = NULL; TestData* pNULL = NULL; @@ -312,8 +300,7 @@ TEST_CASE( "./succeeding/conditions/ptr", // is detected and a warning issued. // An alternative form of the macros (CHECK_FALSE and REQUIRE_FALSE) can be used instead to capture // the operand value. -TEST_CASE( "./succeeding/conditions/not", - "'Not' checks that should succeed" ) +TEST_CASE( "'Not' checks that should succeed", "" ) { bool falseValue = false; @@ -329,8 +316,7 @@ TEST_CASE( "./succeeding/conditions/not", REQUIRE_FALSE( 1 == 2 ); } -TEST_CASE( "./failing/conditions/not", - "'Not' checks that should fail" ) +TEST_CASE( "'Not' checks that should fail", "[.][failing]" ) { bool trueValue = true; diff --git a/projects/SelfTest/ExceptionTests.cpp b/projects/SelfTest/ExceptionTests.cpp index 123e8cef..d15c3f67 100644 --- a/projects/SelfTest/ExceptionTests.cpp +++ b/projects/SelfTest/ExceptionTests.cpp @@ -28,33 +28,33 @@ namespace } } -TEST_CASE( "./succeeding/exceptions/explicit", "When checked exceptions are thrown they can be expected or unexpected" ) +TEST_CASE( "When checked exceptions are thrown they can be expected or unexpected", "" ) { REQUIRE_THROWS_AS( thisThrows(), std::domain_error ); REQUIRE_NOTHROW( thisDoesntThrow() ); REQUIRE_THROWS( thisThrows() ); } -TEST_CASE( "./failing/exceptions/explicit", "When checked exceptions are thrown they can be expected or unexpected" ) +TEST_CASE( "Expected exceptions that don't throw or unexpected exceptions fail the test", "[.][failing]" ) { CHECK_THROWS_AS( thisThrows(), std::string ); CHECK_THROWS_AS( thisDoesntThrow(), std::domain_error ); CHECK_NOTHROW( thisThrows() ); } -TEST_CASE( "./failing/exceptions/implicit", "When unchecked exceptions are thrown they are always failures" ) +TEST_CASE( "When unchecked exceptions are thrown directly they are always failures", "[.][failing]" ) { if( Catch::isTrue( true ) ) throw std::domain_error( "unexpected exception" ); } -TEST_CASE( "./failing/exceptions/implicit/2", "An unchecked exception reports the line of the last assertion" ) +TEST_CASE( "An unchecked exception reports the line of the last assertion", "[.][failing]" ) { CHECK( 1 == 1 ); if( Catch::isTrue( true ) ) throw std::domain_error( "unexpected exception" ); } -TEST_CASE( "./failing/exceptions/implicit/3", "When unchecked exceptions are thrown they are always failures" ) +TEST_CASE( "When unchecked exceptions are thrown from sections they are always failures", "[.][failing]" ) { SECTION( "section name", "" ) { @@ -63,12 +63,12 @@ TEST_CASE( "./failing/exceptions/implicit/3", "When unchecked exceptions are thr } } -TEST_CASE( "./failing/exceptions/implicit/4", "When unchecked exceptions are thrown they are always failures" ) +TEST_CASE( "When unchecked exceptions are thrown from functions they are always failures", "[.][failing]" ) { CHECK( thisThrows() == 0 ); } -TEST_CASE( "./succeeding/exceptions/implicit", "When unchecked exceptions are thrown, but caught, they do not affect the test" ) +TEST_CASE( "When unchecked exceptions are thrown, but caught, they do not affect the test", "" ) { try { @@ -105,7 +105,7 @@ CATCH_TRANSLATE_EXCEPTION( double& ex ) return Catch::toString( ex ); } -TEST_CASE( "./failing/exceptions/custom", "Unexpected custom exceptions can be translated" ) +TEST_CASE("Unexpected custom exceptions can be translated", "[.][failing]" ) { if( Catch::isTrue( true ) ) throw CustomException( "custom exception" ); @@ -116,18 +116,18 @@ inline void throwCustom() { throw CustomException( "custom exception - not std" ); } -TEST_CASE( "./failing/exceptions/custom/nothrow", "Custom exceptions can be translated when testing for nothrow" ) +TEST_CASE( "Custom exceptions can be translated when testing for nothrow", "[.][failing]" ) { REQUIRE_NOTHROW( throwCustom() ); } -TEST_CASE( "./failing/exceptions/custom/throw", "Custom exceptions can be translated when testing for throwing as something else" ) +TEST_CASE( "Custom exceptions can be translated when testing for throwing as something else", "[.][failing]" ) { REQUIRE_THROWS_AS( throwCustom(), std::exception ); } -TEST_CASE( "./failing/exceptions/custom/double", "Unexpected custom exceptions can be translated" ) +TEST_CASE( "Unexpected exceptions can be translated", "[.][failing]" ) { if( Catch::isTrue( true ) ) throw double( 3.14 ); @@ -137,7 +137,7 @@ inline int thisFunctionNotImplemented( int ) { CATCH_NOT_IMPLEMENTED; } -TEST_CASE( "./succeeding/exceptions/notimplemented", "" ) +TEST_CASE( "NotImplemented exception", "" ) { REQUIRE_THROWS( thisFunctionNotImplemented( 7 ) ); } diff --git a/projects/SelfTest/GeneratorTests.cpp b/projects/SelfTest/GeneratorTests.cpp index b21e22dd..a961b698 100644 --- a/projects/SelfTest/GeneratorTests.cpp +++ b/projects/SelfTest/GeneratorTests.cpp @@ -16,7 +16,7 @@ inline int multiply( int a, int b ) return a*b; } -CATCH_TEST_CASE( "./succeeding/generators/1", "Generators over two ranges" ) +CATCH_TEST_CASE( "Generators over two ranges", "[generators]" ) { using namespace Catch::Generators; @@ -29,7 +29,7 @@ CATCH_TEST_CASE( "./succeeding/generators/1", "Generators over two ranges" ) struct IntPair { int first, second; }; -CATCH_TEST_CASE( "./succeeding/generators/2", "Generator over a range of pairs" ) +CATCH_TEST_CASE( "Generator over a range of pairs", "[generators]" ) { using namespace Catch::Generators; diff --git a/projects/SelfTest/MessageTests.cpp b/projects/SelfTest/MessageTests.cpp index 9ba6eaec..2065708d 100644 --- a/projects/SelfTest/MessageTests.cpp +++ b/projects/SelfTest/MessageTests.cpp @@ -8,17 +8,17 @@ #include "catch.hpp" -TEST_CASE( "./succeeding/message", "INFO and WARN do not abort tests" ) +TEST_CASE( "INFO and WARN do not abort tests", "[messages]" ) { INFO( "this is a " << "message" ); // This should output the message if a failure occurs WARN( "this is a " << "warning" ); // This should always output the message but then continue } -TEST_CASE( "./succeeding/succeed", "SUCCEED counts as a test pass" ) +TEST_CASE( "SUCCEED counts as a test pass" ) { SUCCEED( "this is a " << "success" ); } -TEST_CASE( "./failing/message/info/1", "INFO gets logged on failure" ) +TEST_CASE( "INFO gets logged on failure", "[failing][messages][.]" ) { INFO( "this message should be logged" ); INFO( "so should this" ); @@ -26,7 +26,7 @@ TEST_CASE( "./failing/message/info/1", "INFO gets logged on failure" ) REQUIRE( a == 1 ); } -TEST_CASE( "./mixed/message/info/2", "INFO gets logged on failure" ) +TEST_CASE( "INFO gets logged on failure, even if captured before successful assertions", "[failing][messages][.]" ) { INFO( "this message may be logged later" ); int a = 2; @@ -45,13 +45,13 @@ TEST_CASE( "./mixed/message/info/2", "INFO gets logged on failure" ) CHECK( a == 2 ); } -TEST_CASE( "./failing/message/fail", "FAIL aborts the test" ) +TEST_CASE( "FAIL aborts the test", "[failing][messages][.]" ) { if( Catch::isTrue( true ) ) FAIL( "This is a " << "failure" ); // This should output the message and abort } -TEST_CASE( "./failing/message/sections", "Output from all sections is reported" ) +TEST_CASE( "Output from all sections is reported", "[failing][messages][.]" ) { SECTION( "one", "" ) { @@ -64,7 +64,7 @@ TEST_CASE( "./failing/message/sections", "Output from all sections is reported" } } -TEST_CASE( "./succeeding/message/sections/stdout", "Output from all sections is reported" ) +TEST_CASE( "Standard output from all sections is reported", "[messages]" ) { SECTION( "one", "" ) { @@ -77,7 +77,7 @@ TEST_CASE( "./succeeding/message/sections/stdout", "Output from all sections is } } -TEST_CASE( "./mixed/message/scoped", "" ) +TEST_CASE( "SCOPED_INFO is reset for each loop", "[messages][failing][.]" ) { for( int i=0; i<100; i++ ) { @@ -87,16 +87,25 @@ TEST_CASE( "./mixed/message/scoped", "" ) } } -TEST_CASE( "./succeeding/nofail", "The NO_FAIL macro reports a failure but does not fail the test" ) +TEST_CASE( "The NO_FAIL macro reports a failure but does not fail the test", "[messages]" ) { CHECK_NOFAIL( 1 == 2 ); } -TEST_CASE( "just info", "[info][isolated info][.]" ) +TEST_CASE( "just info", "[info][isolated info][messages]" ) { INFO( "this should never be seen" ); } -TEST_CASE( "just failure", "[fail][isolated info][.]" ) +TEST_CASE( "just failure", "[fail][isolated info][.][messages]" ) { FAIL( "Previous info should not be seen" ); } + + +TEST_CASE( "sends information to INFO", "[.][failing]" ) +{ + INFO( "hi" ); + int i = 7; + CAPTURE( i ); + REQUIRE( false ); +} diff --git a/projects/SelfTest/MiscTests.cpp b/projects/SelfTest/MiscTests.cpp index ad3b239c..4a9f172f 100644 --- a/projects/SelfTest/MiscTests.cpp +++ b/projects/SelfTest/MiscTests.cpp @@ -11,7 +11,7 @@ #include -TEST_CASE( "./succeeding/Misc/Sections", "random SECTION tests" ) +TEST_CASE( "random SECTION tests", "[.][sections][failing]" ) { int a = 1; int b = 2; @@ -28,7 +28,7 @@ TEST_CASE( "./succeeding/Misc/Sections", "random SECTION tests" ) } } -TEST_CASE( "./succeeding/Misc/Sections/nested", "nested SECTION tests" ) +TEST_CASE( "nested SECTION tests", "[.][sections][failing]" ) { int a = 1; int b = 2; @@ -45,7 +45,7 @@ TEST_CASE( "./succeeding/Misc/Sections/nested", "nested SECTION tests" ) } } -TEST_CASE( "./mixed/Misc/Sections/nested2", "nested SECTION tests" ) +TEST_CASE( "more nested SECTION tests", "[sections][failing][.]" ) { int a = 1; int b = 2; @@ -68,7 +68,7 @@ TEST_CASE( "./mixed/Misc/Sections/nested2", "nested SECTION tests" ) } } -TEST_CASE( "./Sections/nested/a/b", "nested SECTION tests" ) +TEST_CASE( "even more nested SECTION tests", "[sections]" ) { SECTION( "c", "" ) { @@ -86,7 +86,7 @@ TEST_CASE( "./Sections/nested/a/b", "nested SECTION tests" ) } } -TEST_CASE( "./mixed/Misc/Sections/loops", "looped SECTION tests" ) +TEST_CASE( "looped SECTION tests", "[.][failing][sections]" ) { int a = 1; @@ -101,7 +101,7 @@ TEST_CASE( "./mixed/Misc/Sections/loops", "looped SECTION tests" ) } } -TEST_CASE( "./mixed/Misc/loops", "looped tests" ) +TEST_CASE( "looped tests", "[.][failing]" ) { static const int fib[] = { 1, 1, 2, 3, 5, 8, 13, 21 }; @@ -112,7 +112,7 @@ TEST_CASE( "./mixed/Misc/loops", "looped tests" ) } } -TEST_CASE( "./succeeding/Misc/stdout,stderr", "Sends stuff to stdout and stderr" ) +TEST_CASE( "Sends stuff to stdout and stderr", "" ) { std::cout << "Some information" << std::endl; @@ -124,19 +124,12 @@ inline const char* makeString( bool makeNull ) return makeNull ? NULL : "valid string"; } -TEST_CASE( "./succeeding/Misc/null strings", "" ) +TEST_CASE( "null strings", "" ) { REQUIRE( makeString( false ) != static_cast(NULL)); REQUIRE( makeString( true ) == static_cast(NULL)); } -TEST_CASE( "./failing/info", "sends information to INFO" ) -{ - INFO( "hi" ); - int i = 7; - CAPTURE( i ); - REQUIRE( false ); -} inline bool testCheckedIf( bool flag ) { @@ -146,12 +139,12 @@ inline bool testCheckedIf( bool flag ) return false; } -TEST_CASE( "./succeeding/checkedif", "" ) +TEST_CASE( "checkedIf", "" ) { REQUIRE( testCheckedIf( true ) ); } -TEST_CASE( "./failing/checkedif", "" ) +TEST_CASE( "checkedIf, failing", "[failing][.]" ) { REQUIRE( testCheckedIf( false ) ); } @@ -164,17 +157,17 @@ inline bool testCheckedElse( bool flag ) return true; } -TEST_CASE( "./succeeding/checkedelse", "" ) +TEST_CASE( "checkedElse", "" ) { REQUIRE( testCheckedElse( true ) ); } -TEST_CASE( "./failing/checkedelse", "" ) +TEST_CASE( "checkedElse, failing", "[failing][.]" ) { REQUIRE( testCheckedElse( false ) ); } -TEST_CASE( "./misc/xmlentitycheck", "" ) +TEST_CASE( "xmlentitycheck", "" ) { SECTION( "embedded xml", "it should be possible to embed xml characters, such as <, \" or &, or even whole documents within an attribute" ) { @@ -186,13 +179,13 @@ TEST_CASE( "./misc/xmlentitycheck", "" ) } } -TEST_CASE( "./manual/onechar", "send a single char to INFO" ) +TEST_CASE( "send a single char to INFO", "[failing][.]" ) { INFO(3); REQUIRE(false); } -TEST_CASE("./succeeding/atomic if", "") +TEST_CASE( "atomic if", "[failing][0]") { size_t x = 0; @@ -207,7 +200,7 @@ inline const char* testStringForMatching() return "this string contains 'abc' as a substring"; } -TEST_CASE("./succeeding/matchers", "") +TEST_CASE("String matchers", "[matchers]" ) { REQUIRE_THAT( testStringForMatching(), Contains( "string" ) ); CHECK_THAT( testStringForMatching(), Contains( "abc" ) ); @@ -216,40 +209,40 @@ TEST_CASE("./succeeding/matchers", "") CHECK_THAT( testStringForMatching(), EndsWith( "substring" ) ); } -TEST_CASE("./failing/matchers/Contains", "") +TEST_CASE("Contains string matcher", "[.][failing][matchers]") { CHECK_THAT( testStringForMatching(), Contains( "not there" ) ); } -TEST_CASE("./failing/matchers/StartsWith", "") +TEST_CASE("StartsWith string matcher", "[.][failing][matchers]") { CHECK_THAT( testStringForMatching(), StartsWith( "string" ) ); } -TEST_CASE("./failing/matchers/EndsWith", "") +TEST_CASE("EndsWith string matcher", "[.][failing][matchers]") { CHECK_THAT( testStringForMatching(), EndsWith( "this" ) ); } -TEST_CASE("./failing/matchers/Equals", "") +TEST_CASE("Equals string matcher", "[.][failing][matchers]") { CHECK_THAT( testStringForMatching(), Equals( "something else" ) ); } -TEST_CASE("string", "Equals with NULL") +TEST_CASE("Equals string matcher, with NULL", "[matchers]") { REQUIRE_THAT("", Equals(NULL)); } -TEST_CASE("./succeeding/matchers/AllOf", "") +TEST_CASE("AllOf matcher", "[matchers]") { CHECK_THAT( testStringForMatching(), AllOf( Catch::Contains( "string" ), Catch::Contains( "abc" ) ) ); } -TEST_CASE("./succeeding/matchers/AnyOf", "") +TEST_CASE("AnyOf matcher", "[matchers]") { CHECK_THAT( testStringForMatching(), AnyOf( Catch::Contains( "string" ), Catch::Contains( "not there" ) ) ); CHECK_THAT( testStringForMatching(), AnyOf( Catch::Contains( "not there" ), Catch::Contains( "string" ) ) ); } -TEST_CASE("./succeeding/matchers/Equals", "") +TEST_CASE("Equals", "[matchers]") { CHECK_THAT( testStringForMatching(), Equals( "this string contains 'abc' as a substring" ) ); } @@ -268,7 +261,7 @@ TEST_CASE( "Factorials are computed", "[factorial]" ) { REQUIRE( Factorial(10) == 3628800 ); } -TEST_CASE( "empty", "An empty test with no assertions" ) +TEST_CASE( "An empty test with no assertions", "[empty]" ) { } @@ -333,7 +326,7 @@ TEST_CASE( "vectors can be sized and resized", "[vector]" ) { } // https://github.com/philsquared/Catch/issues/166 -TEST_CASE("./failing/CatchSectionInfiniteLoop", "") +TEST_CASE("A couple of nested sections followed by a failure", "[failing][.]") { SECTION("Outer", "") SECTION("Inner", "") diff --git a/projects/SelfTest/TestMain.cpp b/projects/SelfTest/TestMain.cpp index dc2684ed..00796e93 100644 --- a/projects/SelfTest/TestMain.cpp +++ b/projects/SelfTest/TestMain.cpp @@ -13,52 +13,6 @@ #include "internal/catch_text.h" #include "internal/catch_console_colour.hpp" -TEST_CASE( "selftest/main", "Runs all Catch self tests and checks their results" ) { - using namespace Catch; - - /////////////////////////////////////////////////////////////////////////// - SECTION( "selftest/expected result", - "Tests do what they claim" ) { - - SECTION( "selftest/expected result/failing tests", - "Tests in the 'failing' branch fail" ) { - MetaTestRunner::runMatching( "./failing/*", MetaTestRunner::Expected::ToFail, 0, 2 ); - } - - SECTION( "selftest/expected result/succeeding tests", - "Tests in the 'succeeding' branch succeed" ) { - MetaTestRunner::runMatching( "./succeeding/*", MetaTestRunner::Expected::ToSucceed, 1, 2 ); - } - } - - /////////////////////////////////////////////////////////////////////////// - SECTION( "selftest/test counts", - "Number of test cases that run is fixed" ) { - EmbeddedRunner runner; - - SECTION( "selftest/test counts/succeeding tests", - "Number of 'succeeding' tests is fixed" ) { - Totals totals = runner.runMatching( "./succeeding/*", 0, 2 ); - CHECK( totals.assertions.passed == 298 ); - CHECK( totals.assertions.failed == 0 ); - } - - SECTION( "selftest/test counts/failing tests", - "Number of 'failing' tests is fixed" ) { - Totals totals = runner.runMatching( "./failing/*", 1, 2 ); - CHECK( totals.assertions.passed == 2 ); - CHECK( totals.assertions.failed == 77 ); - } - } -} - -TEST_CASE( "meta/Misc/Sections", "looped tests" ) { - Catch::EmbeddedRunner runner; - - Catch::Totals totals = runner.runMatching( "./mixed/Misc/Sections/nested2", 0, 1 ); - CHECK( totals.assertions.passed == 2 ); - CHECK( totals.assertions.failed == 1 ); -} #ifdef __clang__ #pragma clang diagnostic ignored "-Wweak-vtables" diff --git a/projects/SelfTest/TrickyTests.cpp b/projects/SelfTest/TrickyTests.cpp index 27e1b8fd..624ba264 100644 --- a/projects/SelfTest/TrickyTests.cpp +++ b/projects/SelfTest/TrickyTests.cpp @@ -27,8 +27,8 @@ namespace Catch /////////////////////////////////////////////////////////////////////////////// TEST_CASE ( - "./succeeding/Tricky/std::pair", - "Parsing a std::pair" + "Parsing a std::pair", + "[Tricky][std::pair]" ) { std::pair aNicePair( 1, 2 ); @@ -39,8 +39,8 @@ TEST_CASE /////////////////////////////////////////////////////////////////////////////// TEST_CASE ( - "./inprogress/failing/Tricky/trailing expression", - "Where the is more to the expression after the RHS" + "Where the is more to the expression after the RHS[failing]", + "[Tricky][failing][.]" ) { // int a = 1, b = 2; @@ -50,8 +50,8 @@ TEST_CASE /////////////////////////////////////////////////////////////////////////////// TEST_CASE ( - "./inprogress/failing/Tricky/compound lhs", - "Where the LHS is not a simple value" + "Where the LHS is not a simple value[failing]", + "[Tricky][failing][.]" ) { /* @@ -76,8 +76,8 @@ struct Opaque /////////////////////////////////////////////////////////////////////////////// TEST_CASE ( - "./failing/Tricky/non streamable type", - "A failing expression with a non streamable type is still captured" + "A failing expression with a non streamable type is still captured[failing]", + "[Tricky][failing][.]" ) { @@ -92,8 +92,8 @@ TEST_CASE /////////////////////////////////////////////////////////////////////////////// TEST_CASE ( - "./failing/string literals", - "string literals of different sizes can be compared" + "string literals of different sizes can be compared[failing]", + "[Tricky][failing][.]" ) { REQUIRE( std::string( "first" ) == "second" ); @@ -103,8 +103,8 @@ TEST_CASE /////////////////////////////////////////////////////////////////////////////// TEST_CASE ( - "./succeeding/side-effects", - "An expression with side-effects should only be evaluated once" + "An expression with side-effects should only be evaluated once", + "[Tricky]" ) { int i = 7; @@ -151,8 +151,8 @@ inline bool operator==(const B::Y& lhs, const A::X& rhs) /* This, currently, does not compile with LLVM TEST_CASE ( - "./succeeding/koenig", "Operators at different namespace levels not hijacked by Koenig lookup" + "[Tricky]" ) { A::X x; @@ -171,8 +171,8 @@ namespace ObjectWithConversions /////////////////////////////////////////////////////////////////////////////// TEST_CASE ( - "./succeeding/koenig", - "Operators at different namespace levels not hijacked by Koenig lookup" + "Operators at different namespace levels not hijacked by Koenig lookup", + "[Tricky]" ) { Object o; @@ -199,7 +199,7 @@ namespace ObjectWithNonConstEqualityOperator unsigned int m_value; }; - TEST_CASE("./succeeding/non-const==", "Demonstrate that a non-const == is not used") + TEST_CASE("Demonstrate that a non-const == is not used", "[Tricky]" ) { Test t( 1 ); REQUIRE( t == 1u ); @@ -212,7 +212,7 @@ namespace EnumBitFieldTests bit30 = 0x40000000, bit31 = 0x80000000, bit30and31 = 0xc0000000}; - TEST_CASE("./succeeding/enum/bits", "Test enum bit values") + TEST_CASE( "Test enum bit values", "[Tricky]" ) { REQUIRE( 0xc0000000 == bit30and31 ); } @@ -226,7 +226,7 @@ struct Obj int* prop; }; -TEST_CASE("./succeeding/boolean member", "") +TEST_CASE("boolean member", "[Tricky]") { Obj obj; REQUIRE( obj.prop != NULL ); @@ -238,14 +238,14 @@ TEST_CASE("./succeeding/boolean member", "") // struct it is declared in - but when evaluating it in a deduced // context it appears to require the extra definition. // The issue was fixed by adding bool overloads to bypass the -// templates that were deduce it. +// templates that were there to deduce it. template struct is_true { static const bool value = B; }; -TEST_CASE( "./succeeding/unimplemented static bool", "static bools can be evaluated" ) +TEST_CASE( "(unimplemented) static bools can be evaluated", "[Tricky]" ) { SECTION("compare to true","") { @@ -277,11 +277,11 @@ TEST_CASE( "./succeeding/unimplemented static bool", "static bools can be evalua // Uncomment these tests to produce an error at test registration time /* -TEST_CASE( "./sameName", "Tests with the same name are not allowed" ) +TEST_CASE( "Tests with the same name are not allowed", "[Tricky]" ) { } -TEST_CASE( "./sameName", "Tests with the same name are not allowed" ) +TEST_CASE( "Tests with the same name are not allowed", "[Tricky]" ) { } @@ -298,7 +298,7 @@ struct Boolable bool m_value; }; -TEST_CASE( "./succeeding/SafeBool", "Objects that evaluated in boolean contexts can be checked") +TEST_CASE( "Objects that evaluated in boolean contexts can be checked", "[Tricky][SafeBool]" ) { Boolable True( true ); Boolable False( false ); @@ -308,7 +308,7 @@ TEST_CASE( "./succeeding/SafeBool", "Objects that evaluated in boolean contexts CHECK_FALSE( False ); } -TEST_CASE( "Assertions then sections", "" ) +TEST_CASE( "Assertions then sections", "[Tricky]" ) { // This was causing a failure due to the way the console reporter was handling // the current section @@ -335,7 +335,7 @@ struct Awkward operator int() const { return 7; } }; -TEST_CASE( "non streamable - with conv. op", "" ) +TEST_CASE( "non streamable - with conv. op", "[Tricky]" ) { Awkward awkward; std::string s = Catch::toString( awkward ); @@ -346,7 +346,7 @@ inline void foo() {} typedef void (*fooptr_t)(); -TEST_CASE( "Comparing function pointers", "[function pointer]" ) +TEST_CASE( "Comparing function pointers", "[Tricky][function pointer]" ) { // This was giving a warning in VS2010 // #179 @@ -358,7 +358,7 @@ TEST_CASE( "Comparing function pointers", "[function pointer]" ) class ClassName {}; -TEST_CASE( "pointer to class", "" ) +TEST_CASE( "pointer to class", "[Tricky]" ) { ClassName *p = 0; REQUIRE( p == 0 ); @@ -368,7 +368,7 @@ TEST_CASE( "pointer to class", "" ) #include -TEST_CASE( "null_ptr", "" ) +TEST_CASE( "null_ptr", "[Tricky]" ) { std::unique_ptr ptr; REQUIRE(ptr.get() == nullptr); @@ -376,7 +376,7 @@ TEST_CASE( "null_ptr", "" ) #endif -TEST_CASE( "X/level/0/a", "" ) { SUCCEED(""); } -TEST_CASE( "X/level/0/b", "[fizz]" ) { SUCCEED(""); } -TEST_CASE( "X/level/1/a", "" ) { SUCCEED(""); } -TEST_CASE( "X/level/1/b", "" ) { SUCCEED("");} +TEST_CASE( "X/level/0/a", "[Tricky]" ) { SUCCEED(""); } +TEST_CASE( "X/level/0/b", "[Tricky][fizz]" ){ SUCCEED(""); } +TEST_CASE( "X/level/1/a", "[Tricky]" ) { SUCCEED(""); } +TEST_CASE( "X/level/1/b", "[Tricky]" ) { SUCCEED(""); } diff --git a/projects/VS2010/TestCatch/TestCatch/TestCatch.vcxproj b/projects/VS2010/TestCatch/TestCatch/TestCatch.vcxproj index f140739c..619378e1 100644 --- a/projects/VS2010/TestCatch/TestCatch/TestCatch.vcxproj +++ b/projects/VS2010/TestCatch/TestCatch/TestCatch.vcxproj @@ -145,9 +145,6 @@ - - - From ca7292e3a74d4a6e99309618ad483171f428a35b Mon Sep 17 00:00:00 2001 From: Phil Nash Date: Tue, 19 Nov 2013 19:03:11 +0000 Subject: [PATCH 03/15] Removed redundant MetaTestRunner --- projects/SelfTest/ExceptionTests.cpp | 2 - projects/SelfTest/MiscTests.cpp | 1 - projects/SelfTest/TestMain.cpp | 21 +-- projects/SelfTest/catch_self_test.cpp | 31 --- projects/SelfTest/catch_self_test.hpp | 177 ------------------ .../VS2008/TestCatch/TestCatch/ReadMe.txt | 33 ---- .../TestCatch/TestCatch/TestCatch.vcproj | 12 -- .../VS2010/TestCatch/TestCatch/TestCatch.cpp | 8 - .../TestCatch/TestCatch/TestCatch.vcxproj | 2 - .../CatchSelfTest.xcodeproj/project.pbxproj | 6 - 10 files changed, 10 insertions(+), 283 deletions(-) delete mode 100644 projects/SelfTest/catch_self_test.cpp delete mode 100644 projects/SelfTest/catch_self_test.hpp delete mode 100644 projects/VS2008/TestCatch/TestCatch/ReadMe.txt delete mode 100644 projects/VS2010/TestCatch/TestCatch/TestCatch.cpp diff --git a/projects/SelfTest/ExceptionTests.cpp b/projects/SelfTest/ExceptionTests.cpp index d15c3f67..2dac0c15 100644 --- a/projects/SelfTest/ExceptionTests.cpp +++ b/projects/SelfTest/ExceptionTests.cpp @@ -11,8 +11,6 @@ #include #include -#include "catch_self_test.hpp" - namespace { inline int thisThrows() diff --git a/projects/SelfTest/MiscTests.cpp b/projects/SelfTest/MiscTests.cpp index 4a9f172f..cb93eb55 100644 --- a/projects/SelfTest/MiscTests.cpp +++ b/projects/SelfTest/MiscTests.cpp @@ -7,7 +7,6 @@ */ #include "catch.hpp" -#include "catch_self_test.hpp" #include diff --git a/projects/SelfTest/TestMain.cpp b/projects/SelfTest/TestMain.cpp index 00796e93..1d7211e5 100644 --- a/projects/SelfTest/TestMain.cpp +++ b/projects/SelfTest/TestMain.cpp @@ -5,22 +5,21 @@ * 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) */ + +#define CATCH_CONFIG_MAIN +#include "catch.hpp" + #ifdef __clang__ #pragma clang diagnostic ignored "-Wpadded" -#endif - -#include "catch_self_test.hpp" -#include "internal/catch_text.h" -#include "internal/catch_console_colour.hpp" - - -#ifdef __clang__ #pragma clang diagnostic ignored "-Wweak-vtables" #endif -#include "../../include/internal/catch_commandline.hpp" -#include "../../include/internal/catch_test_spec.h" -#include "../../include/reporters/catch_reporter_xml.hpp" +#include "internal/catch_text.h" +#include "internal/catch_console_colour.hpp" +#include "internal/catch_commandline.hpp" +#include "internal/catch_test_spec.h" + +#include "reporters/catch_reporter_xml.hpp" template void parseIntoConfig( const char * (&argv)[size], Catch::ConfigData& config ) { diff --git a/projects/SelfTest/catch_self_test.cpp b/projects/SelfTest/catch_self_test.cpp deleted file mode 100644 index c5153d68..00000000 --- a/projects/SelfTest/catch_self_test.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Created by Phil on 14/02/2012. - * Copyright 2012 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) - */ - -#define CATCH_CONFIG_MAIN -#include "catch_self_test.hpp" - -namespace Catch{ - - NullStreamingReporter::~NullStreamingReporter() {} - - Totals EmbeddedRunner::runMatching( const std::string& rawTestSpec, std::size_t groupIndex, std::size_t groupsCount, const std::string& ) { - std::ostringstream oss; - Ptr config = new Config(); - config->setStreamBuf( oss.rdbuf() ); - - Totals totals; - - // Scoped because RunContext doesn't report EndTesting until its destructor - { - RunContext runner( config.get(), m_reporter.get() ); - totals = runner.runMatching( rawTestSpec, groupIndex, groupsCount ); - } - return totals; - } - -} diff --git a/projects/SelfTest/catch_self_test.hpp b/projects/SelfTest/catch_self_test.hpp deleted file mode 100644 index 1629644d..00000000 --- a/projects/SelfTest/catch_self_test.hpp +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Created by Phil on 14/01/2011. - * Copyright 2011 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) - */ -#ifndef TWOBLUECUBES_CATCH_SELF_TEST_HPP_INCLUDED -#define TWOBLUECUBES_CATCH_SELF_TEST_HPP_INCLUDED - -#include "catch.hpp" - -// Use this external guard here as if we're using the single header version -// this will already be defined -#ifndef TWOBLUECUBES_CATCH_INTERFACES_REGISTRY_HUB_H_INCLUDED -#include "catch_interfaces_registry_hub.h" -#endif - -#include "set" - -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wpadded" -#endif - -namespace Catch { - - class NullStreamingReporter : public SharedImpl { - public: - - virtual ~NullStreamingReporter(); - - static std::string getDescription() { - return "null reporter"; - } - - private: // IStreamingReporter - - virtual ReporterPreferences getPreferences() const { - return ReporterPreferences(); - } - - virtual void noMatchingTestCases( std::string const& ) {} - virtual void testRunStarting( TestRunInfo const& ) {} - virtual void testGroupStarting( GroupInfo const& ) {} - virtual void testCaseStarting( TestCaseInfo const& ) {} - virtual void sectionStarting( SectionInfo const& ) {} - virtual void assertionStarting( AssertionInfo const& ) {} - virtual bool assertionEnded( AssertionStats const& ) { return false; } - virtual void sectionEnded( SectionStats const& ) {} - virtual void testCaseEnded( TestCaseStats const& ) {} - virtual void testGroupEnded( TestGroupStats const& ) {} - virtual void testRunEnded( TestRunStats const& ) {} - }; - - class EmbeddedRunner { - - public: - EmbeddedRunner() : m_reporter( new NullStreamingReporter() ) {} - - Totals runMatching( const std::string& rawTestSpec, - std::size_t groupIndex, - std::size_t groupsCount, - const std::string& reporter = "console" ); - - private: - Ptr m_reporter; - }; - - class MetaTestRunner { - - public: - struct Expected { enum Result { - ToSucceed, - ToFail - }; }; - - MetaTestRunner( Expected::Result expectedResult, std::size_t groupIndex, std::size_t groupsCount ) - : m_expectedResult( expectedResult ), - m_groupIndex( groupIndex ), - m_groupsCount( groupsCount ) - {} - - static void runMatching( const std::string& testSpec, - Expected::Result expectedResult, - std::size_t groupIndex, - std::size_t groupsCount ) { - forEach( getRegistryHub().getTestCaseRegistry().getMatchingTestCases( testSpec ), - MetaTestRunner( expectedResult, groupIndex, groupsCount ) ); - } - - void operator()( const TestCase& testCase ) { - std::string name; - Totals totals; - { - EmbeddedRunner runner; - name = testCase.getTestCaseInfo().name; - totals = runner.runMatching( name, m_groupIndex, m_groupsCount ); - } - switch( m_expectedResult ) { - case Expected::ToSucceed: - if( totals.assertions.failed > 0 ) { - FAIL( "Expected test case '" - << name - << "' to succeed but there was/ were " - << totals.assertions.failed << " failure(s)" ); - } - else { - SUCCEED( "Tests passed, as expected" ); - } - break; - case Expected::ToFail: - if( totals.assertions.failed == 0 ) { - FAIL( "Expected test case '" - << name - << "' to fail but there was/ were " - << totals.assertions.passed << " success(es)" ); - } - else { - SUCCEED( "Tests failed, as expected" ); - } - break; - } - } - - private: - Expected::Result m_expectedResult; - std::size_t m_groupIndex; - std::size_t m_groupsCount; - }; - - - struct LineInfoRegistry { - - static LineInfoRegistry& get() { - static LineInfoRegistry s_instance; - return s_instance; - } - - void registerLineInfo( const std::string& name, - const SourceLineInfo& info ) { - m_registry.insert( std::make_pair( name, info ) ); - } - - const SourceLineInfo* find( const std::string& name ) const { - std::map::const_iterator it = m_registry.find( name ); - return it == m_registry.end() ? NULL : &(it->second); - } - - const std::string infoForName( const std::string& name ) const { - std::map::const_iterator it = m_registry.find( name ); - if( it == m_registry.end() ) - return ""; - std::ostringstream oss; - oss << it->second; - return oss.str(); - } - - std::map m_registry; - }; - - struct LineInfoRegistrar { - LineInfoRegistrar( const char* name, const SourceLineInfo& lineInfo ) { - LineInfoRegistry::get().registerLineInfo( name, lineInfo ); - } - }; - -} - -#ifdef __clang__ -#pragma clang diagnostic pop -#endif - -#define CATCH_REGISTER_LINE_INFO( name ) ::Catch::LineInfoRegistrar INTERNAL_CATCH_UNIQUE_NAME( lineRegistrar )( name, ::Catch::SourceLineInfo( __FILE__, __LINE__ ) ); -#define CATCH_GET_LINE_INFO( name ) ::Catch::LineInfoRegistry::get().infoForName( name ) - -#endif // TWOBLUECUBES_CATCH_SELF_TEST_HPP_INCLUDED diff --git a/projects/VS2008/TestCatch/TestCatch/ReadMe.txt b/projects/VS2008/TestCatch/TestCatch/ReadMe.txt deleted file mode 100644 index 139e3319..00000000 --- a/projects/VS2008/TestCatch/TestCatch/ReadMe.txt +++ /dev/null @@ -1,33 +0,0 @@ -======================================================================== - 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/projects/VS2008/TestCatch/TestCatch/TestCatch.vcproj b/projects/VS2008/TestCatch/TestCatch/TestCatch.vcproj index 434c7411..d40c925d 100644 --- a/projects/VS2008/TestCatch/TestCatch/TestCatch.vcproj +++ b/projects/VS2008/TestCatch/TestCatch/TestCatch.vcproj @@ -296,10 +296,6 @@ RelativePath="..\..\..\..\include\internal\catch_section.hpp" > - - @@ -351,10 +347,6 @@ RelativePath="..\..\..\SelfTest\BDDTests.cpp" > - - @@ -396,10 +388,6 @@ > - - diff --git a/projects/VS2010/TestCatch/TestCatch/TestCatch.cpp b/projects/VS2010/TestCatch/TestCatch/TestCatch.cpp deleted file mode 100644 index 8dd2067d..00000000 --- a/projects/VS2010/TestCatch/TestCatch/TestCatch.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// TestCatch.cpp : Defines the entry point for the console application. -// - -int main(int argc, char* argv[]) -{ - return 0; -} - diff --git a/projects/VS2010/TestCatch/TestCatch/TestCatch.vcxproj b/projects/VS2010/TestCatch/TestCatch/TestCatch.vcxproj index 619378e1..a8f60653 100644 --- a/projects/VS2010/TestCatch/TestCatch/TestCatch.vcxproj +++ b/projects/VS2010/TestCatch/TestCatch/TestCatch.vcxproj @@ -96,7 +96,6 @@ - @@ -135,7 +134,6 @@ - diff --git a/projects/XCode4/CatchSelfTest/CatchSelfTest.xcodeproj/project.pbxproj b/projects/XCode4/CatchSelfTest/CatchSelfTest.xcodeproj/project.pbxproj index 16b0a4af..30b0b29e 100644 --- a/projects/XCode4/CatchSelfTest/CatchSelfTest.xcodeproj/project.pbxproj +++ b/projects/XCode4/CatchSelfTest/CatchSelfTest.xcodeproj/project.pbxproj @@ -36,7 +36,6 @@ 4AB3D9A01616219100C9A0F8 /* catch_interfaces_config.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4AB3D99F1616219100C9A0F8 /* catch_interfaces_config.cpp */; }; 4AB3D9A2161621B500C9A0F8 /* catch_interfaces_generators.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4AB3D9A1161621B500C9A0F8 /* catch_interfaces_generators.cpp */; }; 4ACE21CC166CA1B300FB5509 /* catch_option.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4ACE21CA166CA1B300FB5509 /* catch_option.cpp */; }; - 4AE1840B14EE4F230066340D /* catch_self_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4AE1840A14EE4F230066340D /* catch_self_test.cpp */; }; 4AEE032016142F910071E950 /* catch_common.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4AEE031F16142F910071E950 /* catch_common.cpp */; }; 4AEE032316142FC70071E950 /* catch_debugger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4AEE032216142FC70071E950 /* catch_debugger.cpp */; }; 4AEE032516142FF10071E950 /* catch_stream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4AEE032416142FF10071E950 /* catch_stream.cpp */; }; @@ -95,7 +94,6 @@ 4A6D0C20149B3D3B00DB3EAA /* CatchSelfTest */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = CatchSelfTest; sourceTree = BUILT_PRODUCTS_DIR; }; 4A6D0C26149B3D3B00DB3EAA /* CatchSelfTest.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = CatchSelfTest.1; sourceTree = ""; }; 4A6D0C2D149B3D9E00DB3EAA /* ApproxTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ApproxTests.cpp; path = ../../../SelfTest/ApproxTests.cpp; sourceTree = ""; }; - 4A6D0C2E149B3D9E00DB3EAA /* catch_self_test.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; name = catch_self_test.hpp; path = ../../../SelfTest/catch_self_test.hpp; sourceTree = ""; }; 4A6D0C2F149B3D9E00DB3EAA /* ClassTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ClassTests.cpp; path = ../../../SelfTest/ClassTests.cpp; sourceTree = ""; }; 4A6D0C30149B3D9E00DB3EAA /* ConditionTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ConditionTests.cpp; path = ../../../SelfTest/ConditionTests.cpp; sourceTree = ""; }; 4A6D0C31149B3D9E00DB3EAA /* ExceptionTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ExceptionTests.cpp; path = ../../../SelfTest/ExceptionTests.cpp; sourceTree = ""; }; @@ -163,7 +161,6 @@ 4AC91CD0155D8DA600DC5117 /* catch_expression_decomposer.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; path = catch_expression_decomposer.hpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; 4ACE21C8166CA19700FB5509 /* catch_option.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = catch_option.hpp; sourceTree = ""; }; 4ACE21CA166CA1B300FB5509 /* catch_option.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = catch_option.cpp; path = ../../../SelfTest/SurrogateCpps/catch_option.cpp; sourceTree = ""; }; - 4AE1840A14EE4F230066340D /* catch_self_test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = catch_self_test.cpp; path = ../../../SelfTest/catch_self_test.cpp; sourceTree = ""; }; 4AEE031F16142F910071E950 /* catch_common.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = catch_common.cpp; path = ../../../SelfTest/SurrogateCpps/catch_common.cpp; sourceTree = ""; }; 4AEE032216142FC70071E950 /* catch_debugger.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = catch_debugger.cpp; path = ../../../SelfTest/SurrogateCpps/catch_debugger.cpp; sourceTree = ""; }; 4AEE032416142FF10071E950 /* catch_stream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = catch_stream.cpp; path = ../../../SelfTest/SurrogateCpps/catch_stream.cpp; sourceTree = ""; }; @@ -220,8 +217,6 @@ isa = PBXGroup; children = ( 4A6D0C35149B3D9E00DB3EAA /* TestMain.cpp */, - 4A6D0C2E149B3D9E00DB3EAA /* catch_self_test.hpp */, - 4AE1840A14EE4F230066340D /* catch_self_test.cpp */, 266E9AD317290E710061DAB2 /* Introspective Tests */, 4A6D0C40149B3DAB00DB3EAA /* Tests */, 4A6D0C41149B3DE900DB3EAA /* Catch */, @@ -499,7 +494,6 @@ 4A6D0C3D149B3D9E00DB3EAA /* MiscTests.cpp in Sources */, 4A6D0C3E149B3D9E00DB3EAA /* TestMain.cpp in Sources */, 4A6D0C3F149B3D9E00DB3EAA /* TrickyTests.cpp in Sources */, - 4AE1840B14EE4F230066340D /* catch_self_test.cpp in Sources */, 4A8E4DD2160A352200194CBD /* catch_tags.cpp in Sources */, 4AEE032016142F910071E950 /* catch_common.cpp in Sources */, 4AEE032316142FC70071E950 /* catch_debugger.cpp in Sources */, From 063593828c48b34e91473e9dae1b0b4db41bdf7e Mon Sep 17 00:00:00 2001 From: Phil Nash Date: Thu, 21 Nov 2013 08:07:37 +0000 Subject: [PATCH 04/15] Removed deleted file from CMake --- projects/CMake/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/projects/CMake/CMakeLists.txt b/projects/CMake/CMakeLists.txt index 5e4d8517..0a556f24 100644 --- a/projects/CMake/CMakeLists.txt +++ b/projects/CMake/CMakeLists.txt @@ -11,7 +11,6 @@ set(SELF_TEST_DIR ${CATCH_DIR}/projects/SelfTest) set(SOURCES ${SELF_TEST_DIR}/ApproxTests.cpp ${SELF_TEST_DIR}/BDDTests.cpp - ${SELF_TEST_DIR}/catch_self_test.cpp ${SELF_TEST_DIR}/ClassTests.cpp ${SELF_TEST_DIR}/CmdLineTests.cpp ${SELF_TEST_DIR}/ConditionTests.cpp From ba13f3f098454a31ac62690f9eb1a1ec6dbd1b55 Mon Sep 17 00:00:00 2001 From: Phil Nash Date: Thu, 21 Nov 2013 08:08:05 +0000 Subject: [PATCH 05/15] Restored second arg to a TEST_CASE for non variadic compilers --- projects/SelfTest/MessageTests.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/SelfTest/MessageTests.cpp b/projects/SelfTest/MessageTests.cpp index 2065708d..e0c44848 100644 --- a/projects/SelfTest/MessageTests.cpp +++ b/projects/SelfTest/MessageTests.cpp @@ -13,7 +13,7 @@ TEST_CASE( "INFO and WARN do not abort tests", "[messages]" ) INFO( "this is a " << "message" ); // This should output the message if a failure occurs WARN( "this is a " << "warning" ); // This should always output the message but then continue } -TEST_CASE( "SUCCEED counts as a test pass" ) +TEST_CASE( "SUCCEED counts as a test pass", "[messages]" ) { SUCCEED( "this is a " << "success" ); } From 69a921f2d67f859bfc4d944277b5cb63cd7f4e01 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Thu, 21 Nov 2013 14:05:04 +0100 Subject: [PATCH 06/15] Add documentation for the CMake build system - new file "docs/build-system.md" to document the integration of Catch with popular build systems. - document how to configure Catch as a CMake external project. --- docs/build-systems.md | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 docs/build-systems.md diff --git a/docs/build-systems.md b/docs/build-systems.md new file mode 100644 index 00000000..a0aed10a --- /dev/null +++ b/docs/build-systems.md @@ -0,0 +1,36 @@ +# Integration with build systems + +## CMake + +You can use the following CMake script to automatically fetch Catch from github and configure it as an external project: + +```CMake +cmake_minimum_required(VERSION 2.8.8) +project(catch_builder CXX) +include(ExternalProject) + +ExternalProject_Add( + catch + PREFIX ${CMAKE_BINARY_DIR}/catch + GIT_REPOSITORY https://github.com/philsquared/Catch.git + TIMEOUT 10 + UPDATE_COMMAND ${GIT_EXECUTABLE} pull + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + LOG_DOWNLOAD ON + ) + +# Expose required variable (CATCH_INCLUDE_DIR) to parent scope +ExternalProject_Get_Property(catch source_dir) +set(CATCH_INCLUDE_DIR ${source_dir}/include CACHE INTERNAL "Path to include folder for Catch") +``` + +If you put it in, e.g., `${PROJECT_SRC_DIR}/${EXT_PROJECTS_DIR}/catch/`, you can use it in your project by adding the following to your root CMake file: + +```CMake +# Includes Catch in the project: +add_subdirectory(${EXT_PROJECTS_DIR}/catch) +include_directories(${CATCH_INCLUDE_DIR} ${COMMON_INCLUDES}) +enable_testing(true) # Enables unit-testing. +``` \ No newline at end of file From 782c2b58913fa8d95ba2c7155ca2a40cbad3ee6b Mon Sep 17 00:00:00 2001 From: Phil Nash Date: Tue, 26 Nov 2013 20:57:34 +0000 Subject: [PATCH 07/15] Added ability to load names of tests to run from a file - use -f to specify filename. Blank lines and lines starting with # are ignored - also added --list-test-names-only to list test names out to file in a form that can be immediate read in by -f --- include/internal/catch_commandline.hpp | 41 +++++++++++++++++++++----- include/internal/catch_config.hpp | 3 ++ include/internal/catch_list.hpp | 16 ++++++++++ 3 files changed, 52 insertions(+), 8 deletions(-) diff --git a/include/internal/catch_commandline.hpp b/include/internal/catch_commandline.hpp index 3b32f2b2..5b80761f 100644 --- a/include/internal/catch_commandline.hpp +++ b/include/internal/catch_commandline.hpp @@ -12,6 +12,8 @@ #include "catch_common.h" #include "clara.h" +#include + namespace Catch { inline void abortAfterFirst( ConfigData& config ) { config.abortAfter = 1; } @@ -38,7 +40,18 @@ namespace Catch { ? ShowDurations::Always : ShowDurations::Never; } - + inline void loadTestNamesFromFile( ConfigData& config, std::string const& _filename ) { + std::ifstream f( _filename.c_str() ); + if( !f.is_open() ) + throw std::domain_error( "Unable to load input file: " + _filename ); + + std::string line; + while( std::getline( f, line ) ) { + line = trim(line); + if( !line.empty() && !startsWith( line, "#" ) ) + addTestOrTags( config, line ); + } + } inline Clara::CommandLine makeCommandLineParser() { @@ -53,19 +66,15 @@ namespace Catch { .longOpt( "help" ); cli.bind( &ConfigData::listTests ) - .describe( "list all (or matching) test cases" ) + .describe( "list all/matching test cases" ) .shortOpt( "l") .longOpt( "list-tests" ); cli.bind( &ConfigData::listTags ) - .describe( "list all (or matching) tags" ) + .describe( "list all/matching tags" ) .shortOpt( "t") .longOpt( "list-tags" ); - cli.bind( &ConfigData::listReporters ) - .describe( "list all reporters" ) - .longOpt( "list-reporters" ); - cli.bind( &ConfigData::showSuccessfulTests ) .describe( "include successful tests in output" ) .shortOpt( "s") @@ -88,7 +97,7 @@ namespace Catch { .hint( "filename" ); cli.bind( &ConfigData::reporterName ) - .describe( "reporter to use - defaults to console" ) + .describe( "reporter to use (defaults to console)" ) .shortOpt( "r") .longOpt( "reporter" ) // .hint( "name[:filename]" ); @@ -133,6 +142,22 @@ namespace Catch { .longOpt( "durations" ) .hint( "yes/no" ); + cli.bind( &loadTestNamesFromFile ) + .describe( "load test names to run from a file" ) + .shortOpt( "f") + .longOpt( "input-file" ) + .hint( "filename" ); + + // Less common commands which don't have a short form + cli.bind( &ConfigData::listTestNamesOnly ) + .describe( "list all/matching test cases names only" ) + .longOpt( "list-test-names-only" ); + + cli.bind( &ConfigData::listReporters ) + .describe( "list all reporters" ) + .longOpt( "list-reporters" ); + + return cli; } diff --git a/include/internal/catch_config.hpp b/include/internal/catch_config.hpp index f561b260..51b5913a 100644 --- a/include/internal/catch_config.hpp +++ b/include/internal/catch_config.hpp @@ -30,6 +30,7 @@ namespace Catch { : listTests( false ), listTags( false ), listReporters( false ), + listTestNamesOnly( false ), showSuccessfulTests( false ), shouldDebugBreak( false ), noThrow( false ), @@ -43,6 +44,7 @@ namespace Catch { bool listTests; bool listTags; bool listReporters; + bool listTestNamesOnly; bool showSuccessfulTests; bool shouldDebugBreak; @@ -112,6 +114,7 @@ namespace Catch { } bool listTests() const { return m_data.listTests; } + bool listTestNamesOnly() const { return m_data.listTestNamesOnly; } bool listTags() const { return m_data.listTags; } bool listReporters() const { return m_data.listReporters; } diff --git a/include/internal/catch_list.hpp b/include/internal/catch_list.hpp index a0b0ac4e..70d7668c 100644 --- a/include/internal/catch_list.hpp +++ b/include/internal/catch_list.hpp @@ -60,6 +60,20 @@ namespace Catch { return matchedTests; } + inline std::size_t listTestsNamesOnly( Config const& config ) { + std::size_t matchedTests = 0; + std::vector const& allTests = getRegistryHub().getTestCaseRegistry().getAllTests(); + for( std::vector::const_iterator it = allTests.begin(), itEnd = allTests.end(); + it != itEnd; + ++it ) + if( matchesFilters( config.filters(), *it ) ) { + matchedTests++; + TestCaseInfo const& testCaseInfo = it->getTestCaseInfo(); + std::cout << testCaseInfo.name << std::endl; + } + return matchedTests; + } + inline std::size_t listTags( Config const& config ) { if( config.filters().empty() ) std::cout << "All available tags:\n"; @@ -131,6 +145,8 @@ namespace Catch { Option listedCount; if( config.listTests() ) listedCount = listedCount.valueOr(0) + listTests( config ); + if( config.listTestNamesOnly() ) + listedCount = listedCount.valueOr(0) + listTestsNamesOnly( config ); if( config.listTags() ) listedCount = listedCount.valueOr(0) + listTags( config ); if( config.listReporters() ) From 5ecb72b9bb65cd8fed2aec4da23a3bc21bbccd74 Mon Sep 17 00:00:00 2001 From: Phil Nash Date: Tue, 26 Nov 2013 20:57:45 +0000 Subject: [PATCH 08/15] Build 14 --- README.md | 2 +- include/internal/catch_version.hpp | 2 +- single_include/catch.hpp | 83 ++++++++++++++++++++++++------ 3 files changed, 69 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 3579e112..4d5f7507 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![catch logo](catch-logo-small.png) -*v1.0 build 13 (master branch)* +*v1.0 build 14 (master branch)* Build status (on Travis CI) [![Build Status](https://travis-ci.org/philsquared/Catch.png)](https://travis-ci.org/philsquared/Catch) diff --git a/include/internal/catch_version.hpp b/include/internal/catch_version.hpp index 89b4e04f..466a9a43 100644 --- a/include/internal/catch_version.hpp +++ b/include/internal/catch_version.hpp @@ -13,7 +13,7 @@ namespace Catch { // These numbers are maintained by a script - Version libraryVersion( 1, 0, 13, "master" ); + Version libraryVersion( 1, 0, 14, "master" ); } #endif // TWOBLUECUBES_CATCH_VERSION_HPP_INCLUDED diff --git a/single_include/catch.hpp b/single_include/catch.hpp index 2fc6b728..b326de06 100644 --- a/single_include/catch.hpp +++ b/single_include/catch.hpp @@ -1,6 +1,6 @@ /* - * CATCH v1.0 build 13 (master branch) - * Generated: 2013-11-13 08:10:05.836093 + * CATCH v1.0 build 14 (master branch) + * Generated: 2013-11-26 20:54:38.067005 * ---------------------------------------------------------- * This file has been merged from multiple headers. Please don't edit it directly * Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved. @@ -2125,6 +2125,7 @@ namespace Catch { : listTests( false ), listTags( false ), listReporters( false ), + listTestNamesOnly( false ), showSuccessfulTests( false ), shouldDebugBreak( false ), noThrow( false ), @@ -2138,6 +2139,7 @@ namespace Catch { bool listTests; bool listTags; bool listReporters; + bool listTestNamesOnly; bool showSuccessfulTests; bool shouldDebugBreak; @@ -2206,6 +2208,7 @@ namespace Catch { } bool listTests() const { return m_data.listTests; } + bool listTestNamesOnly() const { return m_data.listTestNamesOnly; } bool listTags() const { return m_data.listTags; } bool listReporters() const { return m_data.listReporters; } @@ -4128,6 +4131,13 @@ namespace Clara { int position; }; + // NOTE: std::auto_ptr is deprecated in c++11/c++0x +#if defined(__cplusplus) && __cplusplus > 199711L + typedef std::unique_ptr ArgAutoPtr; +#else + typedef std::auto_ptr ArgAutoPtr; +#endif + class ArgBinder { public: template @@ -4152,7 +4162,7 @@ namespace Clara { else if( m_arg.isAnyPositional() ) { if( m_cl->m_arg.get() ) throw std::logic_error( "Only one unpositional argument can be added" ); - m_cl->m_arg = std::auto_ptr( new Arg( m_arg ) ); + m_cl->m_arg = ArgAutoPtr( new Arg( m_arg ) ); } else m_cl->m_options.push_back( m_arg ); @@ -4196,7 +4206,7 @@ namespace Clara { m_highestSpecifiedArgPosition( other.m_highestSpecifiedArgPosition ) { if( other.m_arg.get() ) - m_arg = std::auto_ptr( new Arg( *other.m_arg ) ); + m_arg = ArgAutoPtr( new Arg( *other.m_arg ) ); } template @@ -4366,12 +4376,14 @@ namespace Clara { Detail::BoundArgFunction m_boundProcessName; std::vector m_options; std::map m_positionalArgs; - std::auto_ptr m_arg; + ArgAutoPtr m_arg; int m_highestSpecifiedArgPosition; }; } // end namespace Clara +#include + namespace Catch { inline void abortAfterFirst( ConfigData& config ) { config.abortAfter = 1; } @@ -4398,6 +4410,18 @@ namespace Catch { ? ShowDurations::Always : ShowDurations::Never; } + inline void loadTestNamesFromFile( ConfigData& config, std::string const& _filename ) { + std::ifstream f( _filename.c_str() ); + if( !f.is_open() ) + throw std::domain_error( "Unable to load input file: " + _filename ); + + std::string line; + while( std::getline( f, line ) ) { + line = trim(line); + if( !line.empty() && !startsWith( line, "#" ) ) + addTestOrTags( config, line ); + } + } inline Clara::CommandLine makeCommandLineParser() { @@ -4412,19 +4436,15 @@ namespace Catch { .longOpt( "help" ); cli.bind( &ConfigData::listTests ) - .describe( "list all (or matching) test cases" ) + .describe( "list all/matching test cases" ) .shortOpt( "l") .longOpt( "list-tests" ); cli.bind( &ConfigData::listTags ) - .describe( "list all (or matching) tags" ) + .describe( "list all/matching tags" ) .shortOpt( "t") .longOpt( "list-tags" ); - cli.bind( &ConfigData::listReporters ) - .describe( "list all reporters" ) - .longOpt( "list-reporters" ); - cli.bind( &ConfigData::showSuccessfulTests ) .describe( "include successful tests in output" ) .shortOpt( "s") @@ -4447,7 +4467,7 @@ namespace Catch { .hint( "filename" ); cli.bind( &ConfigData::reporterName ) - .describe( "reporter to use - defaults to console" ) + .describe( "reporter to use (defaults to console)" ) .shortOpt( "r") .longOpt( "reporter" ) // .hint( "name[:filename]" ); @@ -4492,6 +4512,21 @@ namespace Catch { .longOpt( "durations" ) .hint( "yes/no" ); + cli.bind( &loadTestNamesFromFile ) + .describe( "load test names to run from a file" ) + .shortOpt( "f") + .longOpt( "input-file" ) + .hint( "filename" ); + + // Less common commands which don't have a short form + cli.bind( &ConfigData::listTestNamesOnly ) + .describe( "list all/matching test cases names only" ) + .longOpt( "list-test-names-only" ); + + cli.bind( &ConfigData::listReporters ) + .describe( "list all reporters" ) + .longOpt( "list-reporters" ); + return cli; } @@ -4604,6 +4639,20 @@ namespace Catch { return matchedTests; } + inline std::size_t listTestsNamesOnly( Config const& config ) { + std::size_t matchedTests = 0; + std::vector const& allTests = getRegistryHub().getTestCaseRegistry().getAllTests(); + for( std::vector::const_iterator it = allTests.begin(), itEnd = allTests.end(); + it != itEnd; + ++it ) + if( matchesFilters( config.filters(), *it ) ) { + matchedTests++; + TestCaseInfo const& testCaseInfo = it->getTestCaseInfo(); + std::cout << testCaseInfo.name << std::endl; + } + return matchedTests; + } + inline std::size_t listTags( Config const& config ) { if( config.filters().empty() ) std::cout << "All available tags:\n"; @@ -4675,6 +4724,8 @@ namespace Catch { Option listedCount; if( config.listTests() ) listedCount = listedCount.valueOr(0) + listTests( config ); + if( config.listTestNamesOnly() ) + listedCount = listedCount.valueOr(0) + listTestsNamesOnly( config ); if( config.listTags() ) listedCount = listedCount.valueOr(0) + listTags( config ); if( config.listReporters() ) @@ -5423,8 +5474,8 @@ namespace Catch { else { TestCase const& prev = *m_functions.find( testCase ); std::cerr << "error: TEST_CASE( \"" << name << "\" ) already defined.\n" - << "\tFirst seen at " << SourceLineInfo( prev.getTestCaseInfo().lineInfo ) << "\n" - << "\tRedefined at " << SourceLineInfo( testCase.getTestCaseInfo().lineInfo ) << std::endl; + << "\tFirst seen at " << prev.getTestCaseInfo().lineInfo << "\n" + << "\tRedefined at " << testCase.getTestCaseInfo().lineInfo << std::endl; exit(1); } } @@ -6209,7 +6260,7 @@ namespace Catch { SourceLineInfo const& _lineInfo ) { std::string desc = _descOrTags; - bool isHidden( startsWith( _name, "./" ) ); + bool isHidden( startsWith( _name, "./" ) ); // Legacy support std::set tags; TagExtracter( tags ).parse( desc ); if( tags.find( "hide" ) != tags.end() || tags.find( "." ) != tags.end() ) @@ -6317,7 +6368,7 @@ namespace Catch { namespace Catch { // These numbers are maintained by a script - Version libraryVersion( 1, 0, 13, "master" ); + Version libraryVersion( 1, 0, 14, "master" ); } // #included from: catch_text.hpp From c032dfa41c658201563f9a7352570183132639a7 Mon Sep 17 00:00:00 2001 From: Petter Strandmark Date: Tue, 26 Nov 2013 19:37:37 +0100 Subject: [PATCH 09/15] Fix fileno not always present. fileno(stdout) = STDOUT_FILENO. This was a problem when compiling on Cygwin with gcc 4.8. --- include/internal/catch_console_colour_impl.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/internal/catch_console_colour_impl.hpp b/include/internal/catch_console_colour_impl.hpp index 0183f785..b20762f3 100644 --- a/include/internal/catch_console_colour_impl.hpp +++ b/include/internal/catch_console_colour_impl.hpp @@ -117,7 +117,7 @@ namespace { }; inline bool shouldUseColourForPlatform() { - return isatty( fileno(stdout) ); + return isatty(STDOUT_FILENO); } PosixColourImpl platformColourImpl; From c4a089c12b905843819bf0d3f17b45c9a51af3a2 Mon Sep 17 00:00:00 2001 From: Phil Nash Date: Tue, 3 Dec 2013 18:52:41 +0000 Subject: [PATCH 10/15] Refactored a lot of code from headers into impl headers only compiled into one TU - also added noimpl option to single header script - which only generates the non impl code --- include/catch.hpp | 6 +- include/internal/catch_capture.hpp | 5 +- include/internal/catch_common.h | 72 +---- include/internal/catch_common.hpp | 86 ++++++ include/internal/catch_config.hpp | 2 +- include/internal/catch_debugger.h | 49 ++++ include/internal/catch_debugger.hpp | 67 ++--- include/internal/catch_impl.hpp | 7 +- include/internal/catch_interfaces_capture.h | 2 +- .../internal/catch_interfaces_registry_hub.h | 7 +- include/internal/catch_interfaces_reporter.h | 217 +------------- include/internal/catch_interfaces_runner.h | 4 - .../internal/catch_legacy_reporter_adapter.h | 20 ++ include/internal/catch_list.hpp | 1 + include/internal/catch_objc.hpp | 5 +- include/internal/catch_section.h | 49 ++++ include/internal/catch_section.hpp | 54 ++-- include/internal/catch_section_info.h | 31 ++ include/internal/catch_stream.h | 33 +++ include/internal/catch_stream.hpp | 35 +-- include/internal/catch_tags.h | 109 +++++++ include/internal/catch_tags.hpp | 277 +++++++----------- include/internal/catch_test_case_info.hpp | 2 +- include/internal/catch_test_spec.h | 125 +------- include/internal/catch_test_spec.hpp | 133 +++++++++ include/reporters/catch_reporter_bases.hpp | 192 ++++++++++++ include/reporters/catch_reporter_console.hpp | 3 +- include/reporters/catch_reporter_junit.hpp | 3 +- include/reporters/catch_reporter_xml.hpp | 3 +- .../SelfTest/SurrogateCpps/catch_debugger.cpp | 2 +- .../SelfTest/SurrogateCpps/catch_stream.cpp | 2 +- .../SelfTest/SurrogateCpps/catch_tags.cpp | 2 +- .../CatchSelfTest.xcodeproj/project.pbxproj | 16 + scripts/generateSingleHeader.py | 39 ++- 34 files changed, 978 insertions(+), 682 deletions(-) create mode 100644 include/internal/catch_common.hpp create mode 100644 include/internal/catch_debugger.h create mode 100644 include/internal/catch_section.h create mode 100644 include/internal/catch_section_info.h create mode 100644 include/internal/catch_stream.h create mode 100644 include/internal/catch_tags.h create mode 100644 include/internal/catch_test_spec.hpp create mode 100644 include/reporters/catch_reporter_bases.hpp diff --git a/include/catch.hpp b/include/catch.hpp index 600815f7..28e7f9bc 100644 --- a/include/catch.hpp +++ b/include/catch.hpp @@ -21,7 +21,7 @@ #include "internal/catch_context.h" #include "internal/catch_test_registry.hpp" #include "internal/catch_capture.hpp" -#include "internal/catch_section.hpp" +#include "internal/catch_section.h" #include "internal/catch_generators.hpp" #include "internal/catch_interfaces_exception.h" #include "internal/catch_approx.hpp" @@ -39,11 +39,11 @@ #if defined( CATCH_CONFIG_MAIN ) || defined( CATCH_CONFIG_RUNNER ) #include "internal/catch_impl.hpp" -#endif +#endif // CATCH_CONFIG_MAIN || CATCH_CONFIG_RUNNER #ifdef CATCH_CONFIG_MAIN #include "internal/catch_default_main.hpp" -#endif +#endif // CATCH_CONFIG_MAIN ////// diff --git a/include/internal/catch_capture.hpp b/include/internal/catch_capture.hpp index 849dee97..a352a622 100644 --- a/include/internal/catch_capture.hpp +++ b/include/internal/catch_capture.hpp @@ -12,11 +12,12 @@ #include "catch_expressionresult_builder.h" #include "catch_message.h" #include "catch_interfaces_capture.h" -#include "catch_debugger.hpp" +#include "catch_debugger.h" #include "catch_context.h" #include "catch_common.h" #include "catch_tostring.hpp" #include "catch_interfaces_registry_hub.h" +#include "catch_interfaces_config.h" #include "internal/catch_compiler_capabilities.h" #include @@ -66,7 +67,7 @@ struct TestFailureException{}; /////////////////////////////////////////////////////////////////////////////// #define INTERNAL_CATCH_ACCEPT_EXPR( evaluatedExpr, resultDisposition, originalExpr ) \ if( Catch::ResultAction::Value internal_catch_action = Catch::getResultCapture().acceptExpression( evaluatedExpr, INTERNAL_CATCH_ASSERTIONINFO_NAME ) ) { \ - if( internal_catch_action & Catch::ResultAction::Debug ) BreakIntoDebugger(); \ + if( internal_catch_action & Catch::ResultAction::Debug ) CATCH_BREAK_INTO_DEBUGGER(); \ if( internal_catch_action & Catch::ResultAction::Abort ) throw Catch::TestFailureException(); \ if( !Catch::shouldContinueOnFailure( resultDisposition ) ) throw Catch::TestFailureException(); \ Catch::isTrue( false && originalExpr ); \ diff --git a/include/internal/catch_common.h b/include/internal/catch_common.h index 7759987d..650e1fbe 100644 --- a/include/internal/catch_common.h +++ b/include/internal/catch_common.h @@ -67,36 +67,17 @@ namespace Catch { std::for_each( container.begin(), container.end(), function ); } - inline bool startsWith( std::string const& s, std::string const& prefix ) { - return s.size() >= prefix.size() && s.substr( 0, prefix.size() ) == prefix; - } - inline bool endsWith( std::string const& s, std::string const& suffix ) { - return s.size() >= suffix.size() && s.substr( s.size()-suffix.size(), suffix.size() ) == suffix; - } - inline bool contains( std::string const& s, std::string const& infix ) { - return s.find( infix ) != std::string::npos; - } - inline void toLowerInPlace( std::string& s ) { - std::transform( s.begin(), s.end(), s.begin(), ::tolower ); - } - inline std::string toLower( std::string const& s ) { - std::string lc = s; - toLowerInPlace( lc ); - return lc; - } + bool startsWith( std::string const& s, std::string const& prefix ); + bool endsWith( std::string const& s, std::string const& suffix ); + bool contains( std::string const& s, std::string const& infix ); + void toLowerInPlace( std::string& s ); + std::string toLower( std::string const& s ); + std::string trim( std::string const& str ); struct pluralise { - pluralise( std::size_t count, std::string const& label ) - : m_count( count ), - m_label( label ) - {} + pluralise( std::size_t count, std::string const& label ); - friend std::ostream& operator << ( std::ostream& os, pluralise const& pluraliser ) { - os << pluraliser.m_count << " " << pluraliser.m_label; - if( pluraliser.m_count != 1 ) - os << "s"; - return os; - } + friend std::ostream& operator << ( std::ostream& os, pluralise const& pluraliser ); std::size_t m_count; std::string m_label; @@ -104,43 +85,22 @@ namespace Catch { struct SourceLineInfo { - SourceLineInfo() : line( 0 ){} - SourceLineInfo( std::string const& _file, std::size_t _line ) - : file( _file ), - line( _line ) - {} - SourceLineInfo( SourceLineInfo const& other ) - : file( other.file ), - line( other.line ) - {} - bool empty() const { - return file.empty(); - } - bool operator == ( SourceLineInfo const& other ) const { - return line == other.line && file == other.file; - } + SourceLineInfo(); + SourceLineInfo( std::string const& _file, std::size_t _line ); + SourceLineInfo( SourceLineInfo const& other ); + bool empty() const; + bool operator == ( SourceLineInfo const& other ) const; + std::string file; std::size_t line; }; - inline std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info ) { -#ifndef __GNUG__ - os << info.file << "(" << info.line << ")"; -#else - os << info.file << ":" << info.line; -#endif - return os; - } + std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info ); // This is just here to avoid compiler warnings with macro constants and boolean literals inline bool isTrue( bool value ){ return value; } - inline void throwLogicError( std::string const& message, SourceLineInfo const& locationInfo ) { - std::ostringstream oss; - oss << locationInfo << ": Internal Catch error: '" << message << "'"; - if( isTrue( true )) - throw std::logic_error( oss.str() ); - } + void throwLogicError( std::string const& message, SourceLineInfo const& locationInfo ); } #define CATCH_INTERNAL_LINEINFO ::Catch::SourceLineInfo( __FILE__, static_cast( __LINE__ ) ) diff --git a/include/internal/catch_common.hpp b/include/internal/catch_common.hpp new file mode 100644 index 00000000..4fbf1ffc --- /dev/null +++ b/include/internal/catch_common.hpp @@ -0,0 +1,86 @@ +/* + * Created by Phil on 27/11/2013. + * Copyright 2013 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) + */ +#ifndef TWOBLUECUBES_CATCH_COMMON_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_COMMON_HPP_INCLUDED + +#include "catch_common.h" + +namespace Catch { + + bool startsWith( std::string const& s, std::string const& prefix ) { + return s.size() >= prefix.size() && s.substr( 0, prefix.size() ) == prefix; + } + bool endsWith( std::string const& s, std::string const& suffix ) { + return s.size() >= suffix.size() && s.substr( s.size()-suffix.size(), suffix.size() ) == suffix; + } + bool contains( std::string const& s, std::string const& infix ) { + return s.find( infix ) != std::string::npos; + } + void toLowerInPlace( std::string& s ) { + std::transform( s.begin(), s.end(), s.begin(), ::tolower ); + } + std::string toLower( std::string const& s ) { + std::string lc = s; + toLowerInPlace( lc ); + return lc; + } + std::string trim( std::string const& str ) { + static char const* whitespaceChars = "\n\r\t "; + std::string::size_type start = str.find_first_not_of( whitespaceChars ); + std::string::size_type end = str.find_last_not_of( whitespaceChars ); + + return start != std::string::npos ? str.substr( start, 1+end-start ) : ""; + } + + pluralise::pluralise( std::size_t count, std::string const& label ) + : m_count( count ), + m_label( label ) + {} + + std::ostream& operator << ( std::ostream& os, pluralise const& pluraliser ) { + os << pluraliser.m_count << " " << pluraliser.m_label; + if( pluraliser.m_count != 1 ) + os << "s"; + return os; + } + + SourceLineInfo::SourceLineInfo() : line( 0 ){} + SourceLineInfo::SourceLineInfo( std::string const& _file, std::size_t _line ) + : file( _file ), + line( _line ) + {} + SourceLineInfo::SourceLineInfo( SourceLineInfo const& other ) + : file( other.file ), + line( other.line ) + {} + bool SourceLineInfo::empty() const { + return file.empty(); + } + bool SourceLineInfo::operator == ( SourceLineInfo const& other ) const { + return line == other.line && file == other.file; + } + + std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info ) { +#ifndef __GNUG__ + os << info.file << "(" << info.line << ")"; +#else + os << info.file << ":" << info.line; +#endif + return os; + } + + void throwLogicError( std::string const& message, SourceLineInfo const& locationInfo ) { + std::ostringstream oss; + oss << locationInfo << ": Internal Catch error: '" << message << "'"; + if( isTrue( true )) + throw std::logic_error( oss.str() ); + } +} + +#endif // TWOBLUECUBES_CATCH_COMMON_HPP_INCLUDED + diff --git a/include/internal/catch_config.hpp b/include/internal/catch_config.hpp index 51b5913a..30cd34b9 100644 --- a/include/internal/catch_config.hpp +++ b/include/internal/catch_config.hpp @@ -11,7 +11,7 @@ #include "catch_test_spec.h" #include "catch_context.h" #include "catch_interfaces_config.h" -#include "catch_stream.hpp" +#include "catch_stream.h" #include #include diff --git a/include/internal/catch_debugger.h b/include/internal/catch_debugger.h new file mode 100644 index 00000000..0fb6621b --- /dev/null +++ b/include/internal/catch_debugger.h @@ -0,0 +1,49 @@ +/* + * Created by Phil on 3/12/2013. + * Copyright 2013 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) + * + */ +#ifndef TWOBLUECUBES_CATCH_DEBUGGER_H_INCLUDED +#define TWOBLUECUBES_CATCH_DEBUGGER_H_INCLUDED + +#include "catch_platform.h" + +#include + +namespace Catch{ + + bool isDebuggerActive(); + void writeToDebugConsole( std::string const& text ); +} + +#ifdef CATCH_PLATFORM_MAC + + // The following code snippet based on: + // http://cocoawithlove.com/2008/03/break-into-debugger.html + #ifdef DEBUG + #if defined(__ppc64__) || defined(__ppc__) + #define CATCH_BREAK_INTO_DEBUGGER() \ + if( Catch::isDebuggerActive() ) { \ + __asm__("li r0, 20\nsc\nnop\nli r0, 37\nli r4, 2\nsc\nnop\n" \ + : : : "memory","r0","r3","r4" ); \ + } + #else + #define CATCH_BREAK_INTO_DEBUGGER() if( Catch::isDebuggerActive() ) {__asm__("int $3\n" : : );} + #endif + #endif + +#elif defined(_MSC_VER) + #define CATCH_BREAK_INTO_DEBUGGER() if( Catch::isDebuggerActive() ) { __debugbreak(); } +#elif defined(__MINGW32__) + extern "C" __declspec(dllimport) void __stdcall DebugBreak(); + #define CATCH_BREAK_INTO_DEBUGGER() if( Catch::isDebuggerActive() ) { DebugBreak(); } +#endif + +#ifndef CATCH_BREAK_INTO_DEBUGGER +#define CATCH_BREAK_INTO_DEBUGGER() +#endif + +#endif // TWOBLUECUBES_CATCH_DEBUGGER_H_INCLUDED diff --git a/include/internal/catch_debugger.hpp b/include/internal/catch_debugger.hpp index 9979dff8..f3ad100f 100644 --- a/include/internal/catch_debugger.hpp +++ b/include/internal/catch_debugger.hpp @@ -5,14 +5,13 @@ * 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) * - * Provides a BreakIntoDebugger() macro for Windows and Mac (so far) */ #ifndef TWOBLUECUBES_CATCH_DEBUGGER_HPP_INCLUDED #define TWOBLUECUBES_CATCH_DEBUGGER_HPP_INCLUDED -#include +#include "catch_debugger.h" -#include "catch_platform.h" +#include #ifdef CATCH_PLATFORM_MAC @@ -29,7 +28,7 @@ // Returns true if the current process is being debugged (either // running under the debugger or has a debugger attached post facto). - inline bool isDebuggerActive(){ + bool isDebuggerActive(){ int junk; int mib[4]; @@ -59,52 +58,42 @@ return ( (info.kp_proc.p_flag & P_TRACED) != 0 ); } - } - - // The following code snippet taken from: - // http://cocoawithlove.com/2008/03/break-into-debugger.html - #ifdef DEBUG - #if defined(__ppc64__) || defined(__ppc__) - #define BreakIntoDebugger() \ - if( Catch::isDebuggerActive() ) { \ - __asm__("li r0, 20\nsc\nnop\nli r0, 37\nli r4, 2\nsc\nnop\n" \ - : : : "memory","r0","r3","r4" ); \ - } - #else - #define BreakIntoDebugger() if( Catch::isDebuggerActive() ) {__asm__("int $3\n" : : );} - #endif - #else - inline void BreakIntoDebugger(){} - #endif + } // namespace Catch #elif defined(_MSC_VER) extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent(); - #define BreakIntoDebugger() if (IsDebuggerPresent() ) { __debugbreak(); } - inline bool isDebuggerActive() { - return IsDebuggerPresent() != 0; + namespace Catch { + bool isDebuggerActive() { + return IsDebuggerPresent() != 0; + } } #elif defined(__MINGW32__) extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent(); - extern "C" __declspec(dllimport) void __stdcall DebugBreak(); - #define BreakIntoDebugger() if (IsDebuggerPresent() ) { DebugBreak(); } - inline bool isDebuggerActive() { - return IsDebuggerPresent() != 0; + namespace Catch { + bool isDebuggerActive() { + return IsDebuggerPresent() != 0; + } } #else - inline void BreakIntoDebugger(){} + namespace Catch { inline bool isDebuggerActive() { return false; } -#endif + } +#endif // Platform #ifdef CATCH_PLATFORM_WINDOWS -extern "C" __declspec(dllimport) void __stdcall OutputDebugStringA( const char* ); -inline void writeToDebugConsole( std::string const& text ) { - ::OutputDebugStringA( text.c_str() ); -} + extern "C" __declspec(dllimport) void __stdcall OutputDebugStringA( const char* ); + namespace Catch { + void writeToDebugConsole( std::string const& text ) { + ::OutputDebugStringA( text.c_str() ); + } + } #else -inline void writeToDebugConsole( std::string const& text ) { - // !TBD: Need a version for Mac/ XCode and other IDEs - std::cout << text; -} -#endif // CATCH_PLATFORM_WINDOWS + namespace Catch { + void writeToDebugConsole( std::string const& text ) { + // !TBD: Need a version for Mac/ XCode and other IDEs + std::cout << text; + } + } +#endif // Platform #endif // TWOBLUECUBES_CATCH_DEBUGGER_HPP_INCLUDED diff --git a/include/internal/catch_impl.hpp b/include/internal/catch_impl.hpp index 30ac219d..01522355 100644 --- a/include/internal/catch_impl.hpp +++ b/include/internal/catch_impl.hpp @@ -26,11 +26,15 @@ #include "catch_expressionresult_builder.hpp" #include "catch_test_case_info.hpp" #include "catch_tags.hpp" +#include "catch_test_spec.hpp" #include "catch_version.hpp" #include "catch_text.hpp" #include "catch_message.hpp" #include "catch_legacy_reporter_adapter.hpp" #include "catch_timer.hpp" +#include "catch_common.hpp" +#include "catch_section.hpp" +#include "catch_debugger.hpp" #include "../reporters/catch_reporter_xml.hpp" #include "../reporters/catch_reporter_junit.hpp" @@ -71,9 +75,6 @@ namespace Catch { FreeFunctionTestCase::~FreeFunctionTestCase() {} IGeneratorInfo::~IGeneratorInfo() {} IGeneratorsForTest::~IGeneratorsForTest() {} - TagParser::~TagParser() {} - TagExtracter::~TagExtracter() {} - TagExpressionParser::~TagExpressionParser() {} Matchers::Impl::StdString::Equals::~Equals() {} Matchers::Impl::StdString::Contains::~Contains() {} diff --git a/include/internal/catch_interfaces_capture.h b/include/internal/catch_interfaces_capture.h index 2601ab46..de779e07 100644 --- a/include/internal/catch_interfaces_capture.h +++ b/include/internal/catch_interfaces_capture.h @@ -10,7 +10,6 @@ #include #include "catch_result_type.h" -#include "catch_totals.hpp" #include "catch_common.h" namespace Catch { @@ -22,6 +21,7 @@ namespace Catch { struct SectionInfo; struct MessageInfo; class ScopedMessageBuilder; + struct Counts; struct IResultCapture { diff --git a/include/internal/catch_interfaces_registry_hub.h b/include/internal/catch_interfaces_registry_hub.h index 7fae3abd..b657183b 100644 --- a/include/internal/catch_interfaces_registry_hub.h +++ b/include/internal/catch_interfaces_registry_hub.h @@ -8,10 +8,7 @@ #ifndef TWOBLUECUBES_CATCH_INTERFACES_REGISTRY_HUB_H_INCLUDED #define TWOBLUECUBES_CATCH_INTERFACES_REGISTRY_HUB_H_INCLUDED -#include "catch_interfaces_reporter.h" -#include "catch_interfaces_config.h" - -#include +#include namespace Catch { @@ -19,6 +16,8 @@ namespace Catch { struct ITestCaseRegistry; struct IExceptionTranslatorRegistry; struct IExceptionTranslator; + struct IReporterRegistry; + struct IReporterFactory; struct IRegistryHub { virtual ~IRegistryHub(); diff --git a/include/internal/catch_interfaces_reporter.h b/include/internal/catch_interfaces_reporter.h index 1de4778e..eafaaa3a 100644 --- a/include/internal/catch_interfaces_reporter.h +++ b/include/internal/catch_interfaces_reporter.h @@ -8,6 +8,7 @@ #ifndef TWOBLUECUBES_CATCH_INTERFACES_REPORTER_H_INCLUDED #define TWOBLUECUBES_CATCH_INTERFACES_REPORTER_H_INCLUDED +#include "catch_section_info.h" #include "catch_common.h" #include "catch_totals.hpp" #include "catch_ptr.hpp" @@ -80,20 +81,6 @@ namespace Catch std::size_t groupsCounts; }; - struct SectionInfo { - SectionInfo( std::string const& _name, - std::string const& _description, - SourceLineInfo const& _lineInfo ) - : name( _name ), - description( _description ), - lineInfo( _lineInfo ) - {} - - std::string name; - std::string description; - SourceLineInfo lineInfo; - }; - struct AssertionStats { AssertionStats( AssertionResult const& _assertionResult, std::vector const& _infoMessages, @@ -223,201 +210,6 @@ namespace Catch virtual void testRunEnded( TestRunStats const& testRunStats ) = 0; }; - struct StreamingReporterBase : SharedImpl { - - StreamingReporterBase( ReporterConfig const& _config ) - : m_config( _config.fullConfig() ), - stream( _config.stream() ) - {} - - virtual ~StreamingReporterBase(); - - virtual void noMatchingTestCases( std::string const& ) {} - - virtual void testRunStarting( TestRunInfo const& _testRunInfo ) { - currentTestRunInfo = _testRunInfo; - } - virtual void testGroupStarting( GroupInfo const& _groupInfo ) { - currentGroupInfo = _groupInfo; - } - - virtual void testCaseStarting( TestCaseInfo const& _testInfo ) { - currentTestCaseInfo = _testInfo; - } - virtual void sectionStarting( SectionInfo const& _sectionInfo ) { - m_sectionStack.push_back( _sectionInfo ); - } - - virtual void sectionEnded( SectionStats const& /* _sectionStats */ ) { - m_sectionStack.pop_back(); - } - virtual void testCaseEnded( TestCaseStats const& /* _testCaseStats */ ) { - currentTestCaseInfo.reset(); - assert( m_sectionStack.empty() ); - } - virtual void testGroupEnded( TestGroupStats const& /* _testGroupStats */ ) { - currentGroupInfo.reset(); - } - virtual void testRunEnded( TestRunStats const& /* _testRunStats */ ) { - currentTestCaseInfo.reset(); - currentGroupInfo.reset(); - currentTestRunInfo.reset(); - } - - Ptr m_config; - std::ostream& stream; - - LazyStat currentTestRunInfo; - LazyStat currentGroupInfo; - LazyStat currentTestCaseInfo; - - std::vector m_sectionStack; - }; - - struct CumulativeReporterBase : SharedImpl { - template - struct Node : SharedImpl<> { - explicit Node( T const& _value ) : value( _value ) {} - virtual ~Node() {} - - typedef std::vector > ChildNodes; - T value; - ChildNodes children; - }; - struct SectionNode : SharedImpl<> { - explicit SectionNode( SectionStats const& _stats ) : stats( _stats ) {} - virtual ~SectionNode(); - - bool operator == ( SectionNode const& other ) const { - return stats.sectionInfo.lineInfo == other.stats.sectionInfo.lineInfo; - } - bool operator == ( Ptr const& other ) const { - return operator==( *other ); - } - - SectionStats stats; - typedef std::vector > ChildSections; - typedef std::vector Assertions; - ChildSections childSections; - Assertions assertions; - std::string stdOut; - std::string stdErr; - }; - friend bool operator == ( Ptr const& node, SectionInfo const& other ) { - return node->stats.sectionInfo.lineInfo == other.lineInfo; - } - - typedef Node TestCaseNode; - typedef Node TestGroupNode; - typedef Node TestRunNode; - - CumulativeReporterBase( ReporterConfig const& _config ) - : m_config( _config.fullConfig() ), - stream( _config.stream() ) - {} - ~CumulativeReporterBase(); - - virtual void testRunStarting( TestRunInfo const& ) {} - virtual void testGroupStarting( GroupInfo const& ) {} - - virtual void testCaseStarting( TestCaseInfo const& ) {} - - virtual void sectionStarting( SectionInfo const& sectionInfo ) { - SectionStats incompleteStats( sectionInfo, Counts(), 0, false ); - Ptr node; - if( m_sectionStack.empty() ) { - if( !m_rootSection ) - m_rootSection = new SectionNode( incompleteStats ); - node = m_rootSection; - } - else { - SectionNode& parentNode = *m_sectionStack.back(); - SectionNode::ChildSections::const_iterator it = - std::find( parentNode.childSections.begin(), parentNode.childSections.end(), sectionInfo ); - if( it == parentNode.childSections.end() ) { - node = new SectionNode( incompleteStats ); - parentNode.childSections.push_back( node ); - } - else - node = *it; - } - m_sectionStack.push_back( node ); - m_deepestSection = node; - } - - virtual void assertionStarting( AssertionInfo const& ) {} - - virtual bool assertionEnded( AssertionStats const& assertionStats ) { - assert( !m_sectionStack.empty() ); - SectionNode& sectionNode = *m_sectionStack.back(); - sectionNode.assertions.push_back( assertionStats ); - return true; - } - virtual void sectionEnded( SectionStats const& sectionStats ) { - assert( !m_sectionStack.empty() ); - SectionNode& node = *m_sectionStack.back(); - node.stats = sectionStats; - m_sectionStack.pop_back(); - } - virtual void testCaseEnded( TestCaseStats const& testCaseStats ) { - Ptr node = new TestCaseNode( testCaseStats ); - assert( m_sectionStack.size() == 0 ); - node->children.push_back( m_rootSection ); - m_testCases.push_back( node ); - m_rootSection.reset(); - - assert( m_deepestSection ); - m_deepestSection->stdOut = testCaseStats.stdOut; - m_deepestSection->stdErr = testCaseStats.stdErr; - } - virtual void testGroupEnded( TestGroupStats const& testGroupStats ) { - Ptr node = new TestGroupNode( testGroupStats ); - node->children.swap( m_testCases ); - m_testGroups.push_back( node ); - } - virtual void testRunEnded( TestRunStats const& testRunStats ) { - Ptr node = new TestRunNode( testRunStats ); - node->children.swap( m_testGroups ); - m_testRuns.push_back( node ); - testRunEnded(); - } - virtual void testRunEnded() = 0; - - Ptr m_config; - std::ostream& stream; - std::vector m_assertions; - std::vector > > m_sections; - std::vector > m_testCases; - std::vector > m_testGroups; - - std::vector > m_testRuns; - - Ptr m_rootSection; - Ptr m_deepestSection; - std::vector > m_sectionStack; - - }; - - // Deprecated - struct IReporter : IShared { - virtual ~IReporter(); - - virtual bool shouldRedirectStdout() const = 0; - - virtual void StartTesting() = 0; - virtual void EndTesting( Totals const& totals ) = 0; - virtual void StartGroup( std::string const& groupName ) = 0; - virtual void EndGroup( std::string const& groupName, Totals const& totals ) = 0; - virtual void StartTestCase( TestCaseInfo const& testInfo ) = 0; - virtual void EndTestCase( TestCaseInfo const& testInfo, Totals const& totals, std::string const& stdOut, std::string const& stdErr ) = 0; - virtual void StartSection( std::string const& sectionName, std::string const& description ) = 0; - virtual void EndSection( std::string const& sectionName, Counts const& assertions ) = 0; - virtual void NoAssertionsInSection( std::string const& sectionName ) = 0; - virtual void NoAssertionsInTestCase( std::string const& testName ) = 0; - virtual void Aborted() = 0; - virtual void Result( AssertionResult const& result ) = 0; - }; - struct IReporterFactory { virtual ~IReporterFactory(); @@ -433,13 +225,6 @@ namespace Catch virtual FactoryMap const& getFactories() const = 0; }; - inline std::string trim( std::string const& str ) { - static char const* whitespaceChars = "\n\r\t "; - std::string::size_type start = str.find_first_not_of( whitespaceChars ); - std::string::size_type end = str.find_last_not_of( whitespaceChars ); - - return start != std::string::npos ? str.substr( start, 1+end-start ) : ""; - } } #endif // TWOBLUECUBES_CATCH_INTERFACES_REPORTER_H_INCLUDED diff --git a/include/internal/catch_interfaces_runner.h b/include/internal/catch_interfaces_runner.h index ab127b9f..6438f205 100644 --- a/include/internal/catch_interfaces_runner.h +++ b/include/internal/catch_interfaces_runner.h @@ -8,10 +8,6 @@ #ifndef TWOBLUECUBES_CATCH_INTERFACES_RUNNER_H_INCLUDED #define TWOBLUECUBES_CATCH_INTERFACES_RUNNER_H_INCLUDED -#include "catch_totals.hpp" - -#include - namespace Catch { class TestCase; diff --git a/include/internal/catch_legacy_reporter_adapter.h b/include/internal/catch_legacy_reporter_adapter.h index 32d03f15..fb579c7c 100644 --- a/include/internal/catch_legacy_reporter_adapter.h +++ b/include/internal/catch_legacy_reporter_adapter.h @@ -12,6 +12,26 @@ namespace Catch { + // Deprecated + struct IReporter : IShared { + virtual ~IReporter(); + + virtual bool shouldRedirectStdout() const = 0; + + virtual void StartTesting() = 0; + virtual void EndTesting( Totals const& totals ) = 0; + virtual void StartGroup( std::string const& groupName ) = 0; + virtual void EndGroup( std::string const& groupName, Totals const& totals ) = 0; + virtual void StartTestCase( TestCaseInfo const& testInfo ) = 0; + virtual void EndTestCase( TestCaseInfo const& testInfo, Totals const& totals, std::string const& stdOut, std::string const& stdErr ) = 0; + virtual void StartSection( std::string const& sectionName, std::string const& description ) = 0; + virtual void EndSection( std::string const& sectionName, Counts const& assertions ) = 0; + virtual void NoAssertionsInSection( std::string const& sectionName ) = 0; + virtual void NoAssertionsInTestCase( std::string const& testName ) = 0; + virtual void Aborted() = 0; + virtual void Result( AssertionResult const& result ) = 0; + }; + class LegacyReporterAdapter : public SharedImpl { public: diff --git a/include/internal/catch_list.hpp b/include/internal/catch_list.hpp index 70d7668c..1ee3d1f5 100644 --- a/include/internal/catch_list.hpp +++ b/include/internal/catch_list.hpp @@ -11,6 +11,7 @@ #include "catch_commandline.hpp" #include "catch_text.h" #include "catch_console_colour.hpp" +#include "catch_interfaces_reporter.h" #include #include diff --git a/include/internal/catch_objc.hpp b/include/internal/catch_objc.hpp index 45d64ba9..85181f44 100644 --- a/include/internal/catch_objc.hpp +++ b/include/internal/catch_objc.hpp @@ -56,9 +56,6 @@ namespace Catch { namespace Detail{ - inline bool startsWith( std::string const& str, std::string const& sub ) { - return str.length() > sub.length() && str.substr( 0, sub.length() ) == sub; - } inline std::string getAnnotation( Class cls, std::string const& annotationName, @@ -88,7 +85,7 @@ namespace Catch { for( u_int m = 0; m < count ; m++ ) { SEL selector = method_getName(methods[m]); std::string methodName = sel_getName(selector); - if( Detail::startsWith( methodName, "Catch_TestCase_" ) ) { + if( startsWith( methodName, "Catch_TestCase_" ) ) { std::string testCaseName = methodName.substr( 15 ); std::string name = Detail::getAnnotation( cls, "Name", testCaseName ); std::string desc = Detail::getAnnotation( cls, "Description", testCaseName ); diff --git a/include/internal/catch_section.h b/include/internal/catch_section.h new file mode 100644 index 00000000..c1a81f6f --- /dev/null +++ b/include/internal/catch_section.h @@ -0,0 +1,49 @@ +/* + * Created by Phil on 03/12/2013. + * Copyright 2013 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) + */ +#ifndef TWOBLUECUBES_CATCH_SECTION_H_INCLUDED +#define TWOBLUECUBES_CATCH_SECTION_H_INCLUDED + +#include "catch_section_info.h" +#include "catch_totals.hpp" +#include "catch_timer.h" + +#include + +namespace Catch { + + class Section { + public: + Section( SourceLineInfo const& lineInfo, + std::string const& name, + std::string const& description = "" ); + ~Section(); + + // This indicates whether the section should be executed or not + operator bool(); + + private: + + SectionInfo m_info; + + std::string m_name; + Counts m_assertions; + bool m_sectionIncluded; + Timer m_timer; + }; + +} // end namespace Catch + +#ifdef CATCH_CONFIG_VARIADIC_MACROS + #define INTERNAL_CATCH_SECTION( ... ) \ + if( Catch::Section INTERNAL_CATCH_UNIQUE_NAME( catch_internal_Section ) = Catch::Section( CATCH_INTERNAL_LINEINFO, __VA_ARGS__ ) ) +#else + #define INTERNAL_CATCH_SECTION( name, desc ) \ + if( Catch::Section INTERNAL_CATCH_UNIQUE_NAME( catch_internal_Section ) = Catch::Section( CATCH_INTERNAL_LINEINFO, name, desc ) ) +#endif + +#endif // TWOBLUECUBES_CATCH_SECTION_H_INCLUDED diff --git a/include/internal/catch_section.hpp b/include/internal/catch_section.hpp index e58e72a8..96fc8320 100644 --- a/include/internal/catch_section.hpp +++ b/include/internal/catch_section.hpp @@ -8,53 +8,33 @@ #ifndef TWOBLUECUBES_CATCH_SECTION_HPP_INCLUDED #define TWOBLUECUBES_CATCH_SECTION_HPP_INCLUDED +#include "catch_section.h" #include "catch_capture.hpp" -#include "catch_totals.hpp" #include "catch_compiler_capabilities.h" #include "catch_timer.h" -#include - namespace Catch { - class Section { - public: - Section( SourceLineInfo const& lineInfo, - std::string const& name, - std::string const& description = "" ) - : m_info( name, description, lineInfo ), - m_sectionIncluded( getCurrentContext().getResultCapture().sectionStarted( m_info, m_assertions ) ) - { - m_timer.start(); - } + Section::Section( SourceLineInfo const& lineInfo, + std::string const& name, + std::string const& description ) + : m_info( name, description, lineInfo ), + m_sectionIncluded( getCurrentContext().getResultCapture().sectionStarted( m_info, m_assertions ) ) + { + m_timer.start(); + } - ~Section() { - if( m_sectionIncluded ) - getCurrentContext().getResultCapture().sectionEnded( m_info, m_assertions, m_timer.getElapsedSeconds() ); - } + Section::~Section() { + if( m_sectionIncluded ) + getCurrentContext().getResultCapture().sectionEnded( m_info, m_assertions, m_timer.getElapsedSeconds() ); + } - // This indicates whether the section should be executed or not - operator bool() { - return m_sectionIncluded; - } + // This indicates whether the section should be executed or not + Section::operator bool() { + return m_sectionIncluded; + } - private: - SectionInfo m_info; - - std::string m_name; - Counts m_assertions; - bool m_sectionIncluded; - Timer m_timer; - }; } // end namespace Catch -#ifdef CATCH_CONFIG_VARIADIC_MACROS - #define INTERNAL_CATCH_SECTION( ... ) \ - if( Catch::Section INTERNAL_CATCH_UNIQUE_NAME( catch_internal_Section ) = Catch::Section( CATCH_INTERNAL_LINEINFO, __VA_ARGS__ ) ) -#else - #define INTERNAL_CATCH_SECTION( name, desc ) \ - if( Catch::Section INTERNAL_CATCH_UNIQUE_NAME( catch_internal_Section ) = Catch::Section( CATCH_INTERNAL_LINEINFO, name, desc ) ) -#endif - #endif // TWOBLUECUBES_CATCH_SECTION_HPP_INCLUDED diff --git a/include/internal/catch_section_info.h b/include/internal/catch_section_info.h new file mode 100644 index 00000000..6bcc72a9 --- /dev/null +++ b/include/internal/catch_section_info.h @@ -0,0 +1,31 @@ +/* + * Created by Phil on 03/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) + */ +#ifndef TWOBLUECUBES_CATCH_SECTION_INFO_H_INCLUDED +#define TWOBLUECUBES_CATCH_SECTION_INFO_H_INCLUDED + +#include "catch_common.h" + +namespace Catch { + + struct SectionInfo { + SectionInfo( std::string const& _name, + std::string const& _description, + SourceLineInfo const& _lineInfo ) + : name( _name ), + description( _description ), + lineInfo( _lineInfo ) + {} + + std::string name; + std::string description; + SourceLineInfo lineInfo; + }; + +} // end namespace Catch + +#endif // TWOBLUECUBES_CATCH_SECTION_INFO_H_INCLUDED diff --git a/include/internal/catch_stream.h b/include/internal/catch_stream.h new file mode 100644 index 00000000..70ddb58c --- /dev/null +++ b/include/internal/catch_stream.h @@ -0,0 +1,33 @@ +/* + * Created by Phil on 2/12/2013. + * Copyright 2013 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) + * + */ +#ifndef TWOBLUECUBES_CATCH_STREAM_H_INCLUDED +#define TWOBLUECUBES_CATCH_STREAM_H_INCLUDED + +#include + +#ifdef __clang__ +#pragma clang diagnostic ignored "-Wpadded" +#endif + +namespace Catch { + + class Stream { + public: + Stream(); + Stream( std::streambuf* _streamBuf, bool _isOwned ); + void release(); + + std::streambuf* streamBuf; + + private: + bool isOwned; + }; +} + +#endif // TWOBLUECUBES_CATCH_STREAM_H_INCLUDED diff --git a/include/internal/catch_stream.hpp b/include/internal/catch_stream.hpp index eea576ef..784ef86b 100644 --- a/include/internal/catch_stream.hpp +++ b/include/internal/catch_stream.hpp @@ -9,8 +9,9 @@ #ifndef TWOBLUECUBES_CATCH_STREAM_HPP_INCLUDED #define TWOBLUECUBES_CATCH_STREAM_HPP_INCLUDED +#include "catch_stream.h" #include "catch_streambuf.h" -#include "catch_debugger.hpp" +#include "catch_debugger.h" #include #include @@ -62,29 +63,21 @@ namespace Catch { } }; - class Stream { - public: - Stream() - : streamBuf( NULL ), isOwned( false ) - {} + Stream::Stream() + : streamBuf( NULL ), isOwned( false ) + {} - Stream( std::streambuf* _streamBuf, bool _isOwned ) - : streamBuf( _streamBuf ), isOwned( _isOwned ) - {} + Stream::Stream( std::streambuf* _streamBuf, bool _isOwned ) + : streamBuf( _streamBuf ), isOwned( _isOwned ) + {} - void release() { - if( isOwned ) { - delete streamBuf; - streamBuf = NULL; - isOwned = false; - } + void Stream::release() { + if( isOwned ) { + delete streamBuf; + streamBuf = NULL; + isOwned = false; } - - std::streambuf* streamBuf; - - private: - bool isOwned; - }; + } } #endif // TWOBLUECUBES_CATCH_STREAM_HPP_INCLUDED diff --git a/include/internal/catch_tags.h b/include/internal/catch_tags.h new file mode 100644 index 00000000..8fd20b7e --- /dev/null +++ b/include/internal/catch_tags.h @@ -0,0 +1,109 @@ +/* + * Created by Phil on 2/12/2013. + * Copyright 2013 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) + */ +#ifndef TWOBLUECUBES_CATCH_TAGS_H_INCLUDED +#define TWOBLUECUBES_CATCH_TAGS_H_INCLUDED + +#include "catch_common.h" + +#include +#include +#include +#include + +#ifdef __clang__ +#pragma clang diagnostic ignored "-Wpadded" +#endif + +namespace Catch { + class TagParser { + public: + virtual ~TagParser(); + + void parse( std::string const& str ); + + protected: + virtual void acceptTag( std::string const& tag ) = 0; + virtual void acceptChar( char c ) = 0; + virtual void endParse() {} + + private: + }; + + class TagExtracter : public TagParser { + public: + + TagExtracter( std::set& tags ); + virtual ~TagExtracter(); + + void parse( std::string& description ); + + private: + virtual void acceptTag( std::string const& tag ); + virtual void acceptChar( char c ); + + TagExtracter& operator=(TagExtracter const&); + + std::set& m_tags; + std::string m_remainder; + }; + + class Tag { + public: + Tag(); + Tag( std::string const& name, bool isNegated ); + std::string getName() const; + bool isNegated() const; + bool operator ! () const; + + private: + std::string m_name; + bool m_isNegated; + }; + + class TagSet { + typedef std::map TagMap; + public: + void add( Tag const& tag ); + bool empty() const; + bool matches( std::set const& tags ) const; + + private: + TagMap m_tags; + }; + + + class TagExpression { + public: + bool matches( std::set const& tags ) const; + + private: + friend class TagExpressionParser; + + std::vector m_tagSets; + }; + + class TagExpressionParser : public TagParser { + public: + TagExpressionParser( TagExpression& exp ); + ~TagExpressionParser(); + + private: + virtual void acceptTag( std::string const& tag ); + virtual void acceptChar( char c ); + virtual void endParse(); + + TagExpressionParser& operator=(TagExpressionParser const&); + + bool m_isNegated; + TagSet m_currentTagSet; + TagExpression& m_exp; + }; + +} // end namespace Catch + +#endif // TWOBLUECUBES_CATCH_TAGS_HPP_INCLUDED diff --git a/include/internal/catch_tags.hpp b/include/internal/catch_tags.hpp index 36ecd1d6..d02ed8dd 100644 --- a/include/internal/catch_tags.hpp +++ b/include/internal/catch_tags.hpp @@ -8,188 +8,129 @@ #ifndef TWOBLUECUBES_CATCH_TAGS_HPP_INCLUDED #define TWOBLUECUBES_CATCH_TAGS_HPP_INCLUDED -#include "catch_common.h" - -#include -#include -#include -#include - -#ifdef __clang__ -#pragma clang diagnostic ignored "-Wpadded" -#endif +#include "catch_tags.h" namespace Catch { - class TagParser { - public: - virtual ~TagParser(); + TagParser::~TagParser() {} - void parse( std::string const& str ) { - std::size_t pos = 0; - while( pos < str.size() ) { - char c = str[pos]; - if( c == '[' ) { - std::size_t end = str.find_first_of( ']', pos ); - if( end != std::string::npos ) { - acceptTag( str.substr( pos+1, end-pos-1 ) ); - pos = end+1; - } - else { - acceptChar( c ); - pos++; - } + void TagParser::parse( std::string const& str ) { + std::size_t pos = 0; + while( pos < str.size() ) { + char c = str[pos]; + if( c == '[' ) { + std::size_t end = str.find_first_of( ']', pos ); + if( end != std::string::npos ) { + acceptTag( str.substr( pos+1, end-pos-1 ) ); + pos = end+1; } else { acceptChar( c ); pos++; } } - endParse(); - } - - protected: - virtual void acceptTag( std::string const& tag ) = 0; - virtual void acceptChar( char c ) = 0; - virtual void endParse() {} - - private: - }; - - class TagExtracter : public TagParser { - public: - - TagExtracter( std::set& tags ) - : m_tags( tags ) - {} - virtual ~TagExtracter(); - - void parse( std::string& description ) { - TagParser::parse( description ); - description = m_remainder; - } - - private: - virtual void acceptTag( std::string const& tag ) { - m_tags.insert( toLower( tag ) ); - } - virtual void acceptChar( char c ) { - m_remainder += c; - } - - TagExtracter& operator=(TagExtracter const&); - - std::set& m_tags; - std::string m_remainder; - }; - - class Tag { - public: - Tag() - : m_isNegated( false ) - {} - - Tag( std::string const& name, bool isNegated ) - : m_name( name ), - m_isNegated( isNegated ) - {} - - std::string getName() const { - return m_name; - } - bool isNegated() const { - return m_isNegated; - } - - bool operator ! () const { - return m_name.empty(); - } - - private: - std::string m_name; - bool m_isNegated; - }; - - class TagSet { - typedef std::map TagMap; - public: - void add( Tag const& tag ) { - m_tags.insert( std::make_pair( toLower( tag.getName() ), tag ) ); - } - - bool empty() const { - return m_tags.empty(); - } - - bool matches( std::set const& tags ) const { - for( TagMap::const_iterator - it = m_tags.begin(), itEnd = m_tags.end(); - it != itEnd; - ++it ) { - bool found = tags.find( it->first ) != tags.end(); - if( found == it->second.isNegated() ) - return false; - } - return true; - } - - private: - TagMap m_tags; - }; - - class TagExpression { - public: - bool matches( std::set const& tags ) const { - for( std::vector::const_iterator - it = m_tagSets.begin(), itEnd = m_tagSets.end(); - it != itEnd; - ++it ) - if( it->matches( tags ) ) - return true; - return false; - } - - private: - friend class TagExpressionParser; - - std::vector m_tagSets; - }; - - class TagExpressionParser : public TagParser { - public: - TagExpressionParser( TagExpression& exp ) - : m_isNegated( false ), - m_exp( exp ) - {} - - ~TagExpressionParser(); - - private: - virtual void acceptTag( std::string const& tag ) { - m_currentTagSet.add( Tag( tag, m_isNegated ) ); - m_isNegated = false; - } - virtual void acceptChar( char c ) { - switch( c ) { - case '~': - m_isNegated = true; - break; - case ',': - m_exp.m_tagSets.push_back( m_currentTagSet ); - m_currentTagSet = TagSet(); - break; + else { + acceptChar( c ); + pos++; } } - virtual void endParse() { - if( !m_currentTagSet.empty() ) + endParse(); + } + + TagExtracter::TagExtracter( std::set& tags ) + : m_tags( tags ) + {} + + TagExtracter::~TagExtracter() {} + + void TagExtracter::parse( std::string& description ) { + TagParser::parse( description ); + description = m_remainder; + } + + void TagExtracter::acceptTag( std::string const& tag ) { + m_tags.insert( toLower( tag ) ); + } + void TagExtracter::acceptChar( char c ) { + m_remainder += c; + } + + Tag::Tag() : m_isNegated( false ) {} + Tag::Tag( std::string const& name, bool isNegated ) + : m_name( name ), + m_isNegated( isNegated ) + {} + + std::string Tag::getName() const { + return m_name; + } + bool Tag::isNegated() const { + return m_isNegated; + } + + bool Tag::operator ! () const { + return m_name.empty(); + } + + + void TagSet::add( Tag const& tag ) { + m_tags.insert( std::make_pair( toLower( tag.getName() ), tag ) ); + } + + bool TagSet::empty() const { + return m_tags.empty(); + } + + bool TagSet::matches( std::set const& tags ) const { + for( TagMap::const_iterator + it = m_tags.begin(), itEnd = m_tags.end(); + it != itEnd; + ++it ) { + bool found = tags.find( it->first ) != tags.end(); + if( found == it->second.isNegated() ) + return false; + } + return true; + } + + + bool TagExpression::matches( std::set const& tags ) const { + for( std::vector::const_iterator + it = m_tagSets.begin(), itEnd = m_tagSets.end(); + it != itEnd; + ++it ) + if( it->matches( tags ) ) + return true; + return false; + } + + TagExpressionParser::TagExpressionParser( TagExpression& exp ) + : m_isNegated( false ), + m_exp( exp ) + {} + + TagExpressionParser::~TagExpressionParser() {} + + void TagExpressionParser::acceptTag( std::string const& tag ) { + m_currentTagSet.add( Tag( tag, m_isNegated ) ); + m_isNegated = false; + } + + void TagExpressionParser::acceptChar( char c ) { + switch( c ) { + case '~': + m_isNegated = true; + break; + case ',': m_exp.m_tagSets.push_back( m_currentTagSet ); + m_currentTagSet = TagSet(); + break; } + } - TagExpressionParser& operator=(TagExpressionParser const&); - - bool m_isNegated; - TagSet m_currentTagSet; - TagExpression& m_exp; - }; + void TagExpressionParser::endParse() { + if( !m_currentTagSet.empty() ) + m_exp.m_tagSets.push_back( m_currentTagSet ); + } } // end namespace Catch diff --git a/include/internal/catch_test_case_info.hpp b/include/internal/catch_test_case_info.hpp index 59fc39f4..3d46320f 100644 --- a/include/internal/catch_test_case_info.hpp +++ b/include/internal/catch_test_case_info.hpp @@ -8,7 +8,7 @@ #ifndef TWOBLUECUBES_CATCH_TEST_CASE_INFO_HPP_INCLUDED #define TWOBLUECUBES_CATCH_TEST_CASE_INFO_HPP_INCLUDED -#include "catch_tags.hpp" +#include "catch_tags.h" #include "catch_test_case_info.h" #include "catch_interfaces_testcase.h" #include "catch_common.h" diff --git a/include/internal/catch_test_spec.h b/include/internal/catch_test_spec.h index 05f877cf..758f49e2 100644 --- a/include/internal/catch_test_spec.h +++ b/include/internal/catch_test_spec.h @@ -8,15 +8,15 @@ #ifndef TWOBLUECUBES_CATCH_TEST_SPEC_H_INCLUDED #define TWOBLUECUBES_CATCH_TEST_SPEC_H_INCLUDED -#include "catch_test_case_info.h" -#include "catch_tags.hpp" -#include "catch_common.h" +#include "catch_tags.h" #include #include namespace Catch { + class TestCase; + struct IfFilterMatches{ enum DoWhat { AutoDetectBehaviour, IncludeTests, @@ -32,69 +32,13 @@ namespace Catch { }; public: - TestCaseFilter( std::string const& testSpec, IfFilterMatches::DoWhat matchBehaviour = IfFilterMatches::AutoDetectBehaviour ) - : m_stringToMatch( toLower( testSpec ) ), - m_filterType( matchBehaviour ), - m_wildcardPosition( NoWildcard ) - { - if( m_filterType == IfFilterMatches::AutoDetectBehaviour ) { - if( startsWith( m_stringToMatch, "exclude:" ) ) { - m_stringToMatch = m_stringToMatch.substr( 8 ); - m_filterType = IfFilterMatches::ExcludeTests; - } - else if( startsWith( m_stringToMatch, "~" ) ) { - m_stringToMatch = m_stringToMatch.substr( 1 ); - m_filterType = IfFilterMatches::ExcludeTests; - } - else { - m_filterType = IfFilterMatches::IncludeTests; - } - } + TestCaseFilter( std::string const& testSpec, IfFilterMatches::DoWhat matchBehaviour = IfFilterMatches::AutoDetectBehaviour ); - if( startsWith( m_stringToMatch, "*" ) ) { - m_stringToMatch = m_stringToMatch.substr( 1 ); - m_wildcardPosition = (WildcardPosition)( m_wildcardPosition | WildcardAtStart ); - } - if( endsWith( m_stringToMatch, "*" ) ) { - m_stringToMatch = m_stringToMatch.substr( 0, m_stringToMatch.size()-1 ); - m_wildcardPosition = (WildcardPosition)( m_wildcardPosition | WildcardAtEnd ); - } - } + IfFilterMatches::DoWhat getFilterType() const; + bool shouldInclude( TestCase const& testCase ) const; - IfFilterMatches::DoWhat getFilterType() const { - return m_filterType; - } - - bool shouldInclude( TestCase const& testCase ) const { - return isMatch( testCase ) == (m_filterType == IfFilterMatches::IncludeTests); - } private: - -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wunreachable-code" -#endif - - bool isMatch( TestCase const& testCase ) const { - std::string name = testCase.getTestCaseInfo().name; - toLowerInPlace( name ); - - switch( m_wildcardPosition ) { - case NoWildcard: - return m_stringToMatch == name; - case WildcardAtStart: - return endsWith( name, m_stringToMatch ); - case WildcardAtEnd: - return startsWith( name, m_stringToMatch ); - case WildcardAtBothEnds: - return contains( name, m_stringToMatch ); - } - throw std::logic_error( "Unhandled wildcard type" ); - } - -#ifdef __clang__ -#pragma clang diagnostic pop -#endif + bool isMatch( TestCase const& testCase ) const; std::string m_stringToMatch; IfFilterMatches::DoWhat m_filterType; @@ -103,57 +47,12 @@ namespace Catch { class TestCaseFilters { public: - TestCaseFilters( std::string const& name ) : m_name( name ) {} + TestCaseFilters( std::string const& name ); + std::string getName() const; + void addFilter( TestCaseFilter const& filter ); + void addTags( std::string const& tagPattern ); + bool shouldInclude( TestCase const& testCase ) const; - std::string getName() const { - return m_name; - } - - void addFilter( TestCaseFilter const& filter ) { - if( filter.getFilterType() == IfFilterMatches::ExcludeTests ) - m_exclusionFilters.push_back( filter ); - else - m_inclusionFilters.push_back( filter ); - } - - void addTags( std::string const& tagPattern ) { - TagExpression exp; - TagExpressionParser( exp ).parse( tagPattern ); - - m_tagExpressions.push_back( exp ); - } - - bool shouldInclude( TestCase const& testCase ) const { - if( !m_tagExpressions.empty() ) { - std::vector::const_iterator it = m_tagExpressions.begin(); - std::vector::const_iterator itEnd = m_tagExpressions.end(); - for(; it != itEnd; ++it ) - if( it->matches( testCase.getTags() ) ) - break; - if( it == itEnd ) - return false; - } - - if( !m_inclusionFilters.empty() ) { - std::vector::const_iterator it = m_inclusionFilters.begin(); - std::vector::const_iterator itEnd = m_inclusionFilters.end(); - for(; it != itEnd; ++it ) - if( it->shouldInclude( testCase ) ) - break; - if( it == itEnd ) - return false; - } - else if( m_exclusionFilters.empty() && m_tagExpressions.empty() ) { - return !testCase.isHidden(); - } - - std::vector::const_iterator it = m_exclusionFilters.begin(); - std::vector::const_iterator itEnd = m_exclusionFilters.end(); - for(; it != itEnd; ++it ) - if( !it->shouldInclude( testCase ) ) - return false; - return true; - } private: std::vector m_tagExpressions; std::vector m_inclusionFilters; diff --git a/include/internal/catch_test_spec.hpp b/include/internal/catch_test_spec.hpp new file mode 100644 index 00000000..6df01bc7 --- /dev/null +++ b/include/internal/catch_test_spec.hpp @@ -0,0 +1,133 @@ +/* + * Created by Phil on 2/12/2013. + * Copyright 2013 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) + */ +#ifndef TWOBLUECUBES_CATCH_TEST_SPEC_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_TEST_SPEC_HPP_INCLUDED + +#include "catch_test_spec.hpp" +#include "catch_test_case_info.h" +#include "catch_common.h" + +namespace Catch { + + TestCaseFilter::TestCaseFilter( std::string const& testSpec, IfFilterMatches::DoWhat matchBehaviour ) + : m_stringToMatch( toLower( testSpec ) ), + m_filterType( matchBehaviour ), + m_wildcardPosition( NoWildcard ) + { + if( m_filterType == IfFilterMatches::AutoDetectBehaviour ) { + if( startsWith( m_stringToMatch, "exclude:" ) ) { + m_stringToMatch = m_stringToMatch.substr( 8 ); + m_filterType = IfFilterMatches::ExcludeTests; + } + else if( startsWith( m_stringToMatch, "~" ) ) { + m_stringToMatch = m_stringToMatch.substr( 1 ); + m_filterType = IfFilterMatches::ExcludeTests; + } + else { + m_filterType = IfFilterMatches::IncludeTests; + } + } + + if( startsWith( m_stringToMatch, "*" ) ) { + m_stringToMatch = m_stringToMatch.substr( 1 ); + m_wildcardPosition = (WildcardPosition)( m_wildcardPosition | WildcardAtStart ); + } + if( endsWith( m_stringToMatch, "*" ) ) { + m_stringToMatch = m_stringToMatch.substr( 0, m_stringToMatch.size()-1 ); + m_wildcardPosition = (WildcardPosition)( m_wildcardPosition | WildcardAtEnd ); + } + } + + IfFilterMatches::DoWhat TestCaseFilter::getFilterType() const { + return m_filterType; + } + + bool TestCaseFilter::shouldInclude( TestCase const& testCase ) const { + return isMatch( testCase ) == (m_filterType == IfFilterMatches::IncludeTests); + } + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunreachable-code" +#endif + + bool TestCaseFilter::isMatch( TestCase const& testCase ) const { + std::string name = testCase.getTestCaseInfo().name; + toLowerInPlace( name ); + + switch( m_wildcardPosition ) { + case NoWildcard: + return m_stringToMatch == name; + case WildcardAtStart: + return endsWith( name, m_stringToMatch ); + case WildcardAtEnd: + return startsWith( name, m_stringToMatch ); + case WildcardAtBothEnds: + return contains( name, m_stringToMatch ); + } + throw std::logic_error( "Unhandled wildcard type" ); + } + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + + TestCaseFilters::TestCaseFilters( std::string const& name ) : m_name( name ) {} + + std::string TestCaseFilters::getName() const { + return m_name; + } + + void TestCaseFilters::addFilter( TestCaseFilter const& filter ) { + if( filter.getFilterType() == IfFilterMatches::ExcludeTests ) + m_exclusionFilters.push_back( filter ); + else + m_inclusionFilters.push_back( filter ); + } + + void TestCaseFilters::addTags( std::string const& tagPattern ) { + TagExpression exp; + TagExpressionParser( exp ).parse( tagPattern ); + + m_tagExpressions.push_back( exp ); + } + + bool TestCaseFilters::shouldInclude( TestCase const& testCase ) const { + if( !m_tagExpressions.empty() ) { + std::vector::const_iterator it = m_tagExpressions.begin(); + std::vector::const_iterator itEnd = m_tagExpressions.end(); + for(; it != itEnd; ++it ) + if( it->matches( testCase.getTags() ) ) + break; + if( it == itEnd ) + return false; + } + + if( !m_inclusionFilters.empty() ) { + std::vector::const_iterator it = m_inclusionFilters.begin(); + std::vector::const_iterator itEnd = m_inclusionFilters.end(); + for(; it != itEnd; ++it ) + if( it->shouldInclude( testCase ) ) + break; + if( it == itEnd ) + return false; + } + else if( m_exclusionFilters.empty() && m_tagExpressions.empty() ) { + return !testCase.isHidden(); + } + + std::vector::const_iterator it = m_exclusionFilters.begin(); + std::vector::const_iterator itEnd = m_exclusionFilters.end(); + for(; it != itEnd; ++it ) + if( !it->shouldInclude( testCase ) ) + return false; + return true; + } +} + +#endif // TWOBLUECUBES_CATCH_TEST_SPEC_HPP_INCLUDED diff --git a/include/reporters/catch_reporter_bases.hpp b/include/reporters/catch_reporter_bases.hpp new file mode 100644 index 00000000..a109d860 --- /dev/null +++ b/include/reporters/catch_reporter_bases.hpp @@ -0,0 +1,192 @@ +/* + * Created by Phil on 27/11/2013. + * Copyright 2013 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) + */ +#ifndef TWOBLUECUBES_CATCH_REPORTER_BASES_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_REPORTER_BASES_HPP_INCLUDED + +#include "../internal/catch_interfaces_reporter.h" + +namespace Catch { + + struct StreamingReporterBase : SharedImpl { + + StreamingReporterBase( ReporterConfig const& _config ) + : m_config( _config.fullConfig() ), + stream( _config.stream() ) + {} + + virtual ~StreamingReporterBase(); + + virtual void noMatchingTestCases( std::string const& ) {} + + virtual void testRunStarting( TestRunInfo const& _testRunInfo ) { + currentTestRunInfo = _testRunInfo; + } + virtual void testGroupStarting( GroupInfo const& _groupInfo ) { + currentGroupInfo = _groupInfo; + } + + virtual void testCaseStarting( TestCaseInfo const& _testInfo ) { + currentTestCaseInfo = _testInfo; + } + virtual void sectionStarting( SectionInfo const& _sectionInfo ) { + m_sectionStack.push_back( _sectionInfo ); + } + + virtual void sectionEnded( SectionStats const& /* _sectionStats */ ) { + m_sectionStack.pop_back(); + } + virtual void testCaseEnded( TestCaseStats const& /* _testCaseStats */ ) { + currentTestCaseInfo.reset(); + assert( m_sectionStack.empty() ); + } + virtual void testGroupEnded( TestGroupStats const& /* _testGroupStats */ ) { + currentGroupInfo.reset(); + } + virtual void testRunEnded( TestRunStats const& /* _testRunStats */ ) { + currentTestCaseInfo.reset(); + currentGroupInfo.reset(); + currentTestRunInfo.reset(); + } + + Ptr m_config; + std::ostream& stream; + + LazyStat currentTestRunInfo; + LazyStat currentGroupInfo; + LazyStat currentTestCaseInfo; + + std::vector m_sectionStack; + }; + + struct CumulativeReporterBase : SharedImpl { + template + struct Node : SharedImpl<> { + explicit Node( T const& _value ) : value( _value ) {} + virtual ~Node() {} + + typedef std::vector > ChildNodes; + T value; + ChildNodes children; + }; + struct SectionNode : SharedImpl<> { + explicit SectionNode( SectionStats const& _stats ) : stats( _stats ) {} + virtual ~SectionNode(); + + bool operator == ( SectionNode const& other ) const { + return stats.sectionInfo.lineInfo == other.stats.sectionInfo.lineInfo; + } + bool operator == ( Ptr const& other ) const { + return operator==( *other ); + } + + SectionStats stats; + typedef std::vector > ChildSections; + typedef std::vector Assertions; + ChildSections childSections; + Assertions assertions; + std::string stdOut; + std::string stdErr; + }; + friend bool operator == ( Ptr const& node, SectionInfo const& other ) { + return node->stats.sectionInfo.lineInfo == other.lineInfo; + } + + typedef Node TestCaseNode; + typedef Node TestGroupNode; + typedef Node TestRunNode; + + CumulativeReporterBase( ReporterConfig const& _config ) + : m_config( _config.fullConfig() ), + stream( _config.stream() ) + {} + ~CumulativeReporterBase(); + + virtual void testRunStarting( TestRunInfo const& ) {} + virtual void testGroupStarting( GroupInfo const& ) {} + + virtual void testCaseStarting( TestCaseInfo const& ) {} + + virtual void sectionStarting( SectionInfo const& sectionInfo ) { + SectionStats incompleteStats( sectionInfo, Counts(), 0, false ); + Ptr node; + if( m_sectionStack.empty() ) { + if( !m_rootSection ) + m_rootSection = new SectionNode( incompleteStats ); + node = m_rootSection; + } + else { + SectionNode& parentNode = *m_sectionStack.back(); + SectionNode::ChildSections::const_iterator it = + std::find( parentNode.childSections.begin(), parentNode.childSections.end(), sectionInfo ); + if( it == parentNode.childSections.end() ) { + node = new SectionNode( incompleteStats ); + parentNode.childSections.push_back( node ); + } + else + node = *it; + } + m_sectionStack.push_back( node ); + m_deepestSection = node; + } + + virtual void assertionStarting( AssertionInfo const& ) {} + + virtual bool assertionEnded( AssertionStats const& assertionStats ) { + assert( !m_sectionStack.empty() ); + SectionNode& sectionNode = *m_sectionStack.back(); + sectionNode.assertions.push_back( assertionStats ); + return true; + } + virtual void sectionEnded( SectionStats const& sectionStats ) { + assert( !m_sectionStack.empty() ); + SectionNode& node = *m_sectionStack.back(); + node.stats = sectionStats; + m_sectionStack.pop_back(); + } + virtual void testCaseEnded( TestCaseStats const& testCaseStats ) { + Ptr node = new TestCaseNode( testCaseStats ); + assert( m_sectionStack.size() == 0 ); + node->children.push_back( m_rootSection ); + m_testCases.push_back( node ); + m_rootSection.reset(); + + assert( m_deepestSection ); + m_deepestSection->stdOut = testCaseStats.stdOut; + m_deepestSection->stdErr = testCaseStats.stdErr; + } + virtual void testGroupEnded( TestGroupStats const& testGroupStats ) { + Ptr node = new TestGroupNode( testGroupStats ); + node->children.swap( m_testCases ); + m_testGroups.push_back( node ); + } + virtual void testRunEnded( TestRunStats const& testRunStats ) { + Ptr node = new TestRunNode( testRunStats ); + node->children.swap( m_testGroups ); + m_testRuns.push_back( node ); + testRunEnded(); + } + virtual void testRunEnded() = 0; + + Ptr m_config; + std::ostream& stream; + std::vector m_assertions; + std::vector > > m_sections; + std::vector > m_testCases; + std::vector > m_testGroups; + + std::vector > m_testRuns; + + Ptr m_rootSection; + Ptr m_deepestSection; + std::vector > m_sectionStack; + + }; + +} // end namespace Catch + +#endif // TWOBLUECUBES_CATCH_REPORTER_BASES_HPP_INCLUDED diff --git a/include/reporters/catch_reporter_console.hpp b/include/reporters/catch_reporter_console.hpp index 17b07a7f..60ada648 100644 --- a/include/reporters/catch_reporter_console.hpp +++ b/include/reporters/catch_reporter_console.hpp @@ -8,7 +8,8 @@ #ifndef TWOBLUECUBES_CATCH_REPORTER_CONSOLE_HPP_INCLUDED #define TWOBLUECUBES_CATCH_REPORTER_CONSOLE_HPP_INCLUDED -#include "../internal/catch_interfaces_reporter.h" +#include "catch_reporter_bases.hpp" + #include "../internal/catch_reporter_registrars.hpp" #include "../internal/catch_console_colour.hpp" diff --git a/include/reporters/catch_reporter_junit.hpp b/include/reporters/catch_reporter_junit.hpp index c9cf9293..db12635b 100644 --- a/include/reporters/catch_reporter_junit.hpp +++ b/include/reporters/catch_reporter_junit.hpp @@ -8,8 +8,9 @@ #ifndef TWOBLUECUBES_CATCH_REPORTER_JUNIT_HPP_INCLUDED #define TWOBLUECUBES_CATCH_REPORTER_JUNIT_HPP_INCLUDED +#include "catch_reporter_bases.hpp" + #include "../internal/catch_tostring.hpp" -#include "../internal/catch_interfaces_reporter.h" #include "../internal/catch_reporter_registrars.hpp" #include "../internal/catch_xmlwriter.hpp" diff --git a/include/reporters/catch_reporter_xml.hpp b/include/reporters/catch_reporter_xml.hpp index 4c8095e0..11ecd910 100644 --- a/include/reporters/catch_reporter_xml.hpp +++ b/include/reporters/catch_reporter_xml.hpp @@ -8,8 +8,9 @@ #ifndef TWOBLUECUBES_CATCH_REPORTER_XML_HPP_INCLUDED #define TWOBLUECUBES_CATCH_REPORTER_XML_HPP_INCLUDED +#include "catch_reporter_bases.hpp" + #include "../internal/catch_capture.hpp" -#include "../internal/catch_interfaces_reporter.h" #include "../internal/catch_reporter_registrars.hpp" #include "../internal/catch_xmlwriter.hpp" diff --git a/projects/SelfTest/SurrogateCpps/catch_debugger.cpp b/projects/SelfTest/SurrogateCpps/catch_debugger.cpp index f6b39f5e..33f76ae6 100644 --- a/projects/SelfTest/SurrogateCpps/catch_debugger.cpp +++ b/projects/SelfTest/SurrogateCpps/catch_debugger.cpp @@ -1,2 +1,2 @@ // This file is only here to verify (to the extent possible) the self sufficiency of the header -#include "catch_debugger.hpp" +#include "catch_debugger.h" diff --git a/projects/SelfTest/SurrogateCpps/catch_stream.cpp b/projects/SelfTest/SurrogateCpps/catch_stream.cpp index 43458dec..9911aec6 100644 --- a/projects/SelfTest/SurrogateCpps/catch_stream.cpp +++ b/projects/SelfTest/SurrogateCpps/catch_stream.cpp @@ -1,2 +1,2 @@ // This file is only here to verify (to the extent possible) the self sufficiency of the header -#include "catch_stream.hpp" +#include "catch_stream.h" diff --git a/projects/SelfTest/SurrogateCpps/catch_tags.cpp b/projects/SelfTest/SurrogateCpps/catch_tags.cpp index 63d15406..36e8789b 100644 --- a/projects/SelfTest/SurrogateCpps/catch_tags.cpp +++ b/projects/SelfTest/SurrogateCpps/catch_tags.cpp @@ -1,2 +1,2 @@ // This file is only here to verify (to the extent possible) the self sufficiency of the header -#include "catch_tags.hpp" +#include "catch_tags.h" diff --git a/projects/XCode4/CatchSelfTest/CatchSelfTest.xcodeproj/project.pbxproj b/projects/XCode4/CatchSelfTest/CatchSelfTest.xcodeproj/project.pbxproj index 30b0b29e..c6a13fb8 100644 --- a/projects/XCode4/CatchSelfTest/CatchSelfTest.xcodeproj/project.pbxproj +++ b/projects/XCode4/CatchSelfTest/CatchSelfTest.xcodeproj/project.pbxproj @@ -56,6 +56,14 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 261488FA184C81130041FBEB /* catch_test_spec.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = catch_test_spec.hpp; sourceTree = ""; }; + 261488FB184C83EA0041FBEB /* catch_tags.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = catch_tags.h; sourceTree = ""; }; + 261488FC184D1DC10041FBEB /* catch_stream.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = catch_stream.h; sourceTree = ""; }; + 261488FD184D21290041FBEB /* catch_section_info.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = catch_section_info.h; sourceTree = ""; }; + 261488FE184DC32F0041FBEB /* catch_section.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = catch_section.h; sourceTree = ""; }; + 261488FF184DC4A20041FBEB /* catch_debugger.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = catch_debugger.h; sourceTree = ""; }; + 262E7399184673A800CAC268 /* catch_reporter_bases.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = catch_reporter_bases.hpp; sourceTree = ""; }; + 262E739A1846759000CAC268 /* catch_common.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = catch_common.hpp; sourceTree = ""; }; 263FD06017AF8DF200988A20 /* catch_timer.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_timer.hpp; sourceTree = ""; }; 263FD06117AF8DF200988A20 /* catch_timer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = catch_timer.h; sourceTree = ""; }; 266B06B616F3A60A004ED264 /* VariadicMacrosTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = VariadicMacrosTests.cpp; path = ../../../SelfTest/VariadicMacrosTests.cpp; sourceTree = ""; }; @@ -277,6 +285,7 @@ 4A6D0C65149B3E3D00DB3EAA /* reporters */ = { isa = PBXGroup; children = ( + 262E7399184673A800CAC268 /* catch_reporter_bases.hpp */, 4A6D0C67149B3E3D00DB3EAA /* catch_reporter_junit.hpp */, 4A6D0C68149B3E3D00DB3EAA /* catch_reporter_xml.hpp */, 4AB42F84166F3E1A0099F2C8 /* catch_reporter_console.hpp */, @@ -314,6 +323,7 @@ 4AC91CB4155B9EBF00DC5117 /* impl */ = { isa = PBXGroup; children = ( + 261488FA184C81130041FBEB /* catch_test_spec.hpp */, 263FD06017AF8DF200988A20 /* catch_timer.hpp */, 266E9AD117230ACF0061DAB2 /* catch_text.hpp */, 4A4B0F9C15CEFA8300AE2392 /* catch_impl.hpp */, @@ -341,6 +351,7 @@ 4A6D0C5D149B3E3D00DB3EAA /* catch_assertionresult.h */, 4A9D84B315599AC900FBB209 /* catch_expressionresult_builder.h */, 4A6D0C5F149B3E3D00DB3EAA /* catch_section.hpp */, + 261488FE184DC32F0041FBEB /* catch_section.h */, 4A3D7DD01503869D005F9203 /* catch_matchers.hpp */, 4A9D84B11558FC0400FBB209 /* catch_tostring.hpp */, 4A6D0C46149B3E3D00DB3EAA /* catch_approx.hpp */, @@ -349,6 +360,7 @@ 4AC91CD0155D8DA600DC5117 /* catch_expression_decomposer.hpp */, 4A4B0F9A15CEF84800AE2392 /* catch_notimplemented_exception.h */, 26847E5B16BBAB790043B9C1 /* catch_message.h */, + 261488FD184D21290041FBEB /* catch_section_info.h */, ); name = Assertions; sourceTree = ""; @@ -375,6 +387,7 @@ 4A084F1D15DAD15F0027E631 /* catch_test_spec.h */, 4A8E4DCC160A344100194CBD /* catch_tags.hpp */, 26948287179EF7F900ED166E /* catch_test_case_tracker.hpp */, + 261488FB184C83EA0041FBEB /* catch_tags.h */, ); name = "Test execution"; sourceTree = ""; @@ -411,6 +424,7 @@ 266ECD8D1713614B0030D735 /* catch_legacy_reporter_adapter.h */, 4A6D0C49149B3E3D00DB3EAA /* catch_common.h */, 4A6D0C4B149B3E3D00DB3EAA /* catch_debugger.hpp */, + 261488FF184DC4A20041FBEB /* catch_debugger.h */, 4A6D0C60149B3E3D00DB3EAA /* catch_stream.hpp */, 4A6D0C64149B3E3D00DB3EAA /* catch_xmlwriter.hpp */, 4AB1C73714F97C1300F31DF7 /* catch_console_colour.hpp */, @@ -422,6 +436,8 @@ 26DACF2F17206D3400A21326 /* catch_text.h */, 263FD06117AF8DF200988A20 /* catch_timer.h */, 26AEAF1617BEA18E009E32C9 /* catch_platform.h */, + 262E739A1846759000CAC268 /* catch_common.hpp */, + 261488FC184D1DC10041FBEB /* catch_stream.h */, ); name = Infrastructure; sourceTree = ""; diff --git a/scripts/generateSingleHeader.py b/scripts/generateSingleHeader.py index ba4c5cde..0f7aa9ed 100644 --- a/scripts/generateSingleHeader.py +++ b/scripts/generateSingleHeader.py @@ -2,6 +2,7 @@ import os import sys import re import datetime +import string from scriptCommon import catchPath @@ -9,6 +10,9 @@ versionParser = re.compile( r'(\s*Version\slibraryVersion)\s*\(\s*(.*)\s*,\s*(.* includesParser = re.compile( r'\s*#include\s*"(.*)"' ) guardParser = re.compile( r'\s*#.*_INCLUDED') defineParser = re.compile( r'\s*#define') +ifParser = re.compile( r'\s*#if') +endIfParser = re.compile( r'\s*#endif') +ifImplParser = re.compile( r'\s*#if.*(CATCH_CONFIG_MAIN|CATCH_CONFIG_RUNNER)') commentParser1 = re.compile( r'^\s*/\*') commentParser2 = re.compile( r'^\s*\*') blankParser = re.compile( r'^\s*$') @@ -18,21 +22,48 @@ versionPath = os.path.join( rootPath, "internal/catch_version.hpp" ) readmePath = os.path.join( catchPath, "README.md" ) outputPath = os.path.join( catchPath, 'single_include/catch.hpp' ) -bumpVersion = len(sys.argv) < 2 or sys.argv[1] <> "nobump" +bumpVersion = True +includeImpl = True + +for arg in sys.argv[1:]: + arg = string.lower(arg) + if arg == "nobump": + bumpVersion = False + print "Not bumping version number" + elif arg == "noimpl": + includeImpl = False + bumpVersion = False + print "Not including impl code (and not bumping version)" + else: + print "\n** Unrecognised argument: " + arg + " **\n" + exit(1) out = open( outputPath, 'w' ) +ifdefs = 0 +implIfDefs = -1 + +def write( line ): + if includeImpl or implIfDefs == -1: + out.write( line ) def parseFile( path, filename ): + global ifdefs + global implIfDefs + f = open( path + filename, 'r' ) blanks = 0 for line in f: + if ifParser.match( line ): + ifdefs = ifdefs + 1 + elif endIfParser.match( line ): + ifdefs = ifdefs - 1 m = includesParser.match( line ) if m: header = m.group(1) headerPath, sep, headerFile = header.rpartition( "/" ) if not headerFile in seenHeaders: seenHeaders.add( headerFile ) - out.write( "// #included from: {0}\n".format( header ) ) + write( "// #included from: {0}\n".format( header ) ) if( headerPath == "internal" and path.endswith( "internal/" ) ): headerPath = "" sep = "" @@ -40,13 +71,15 @@ def parseFile( path, filename ): parseFile( path + headerPath + sep, headerFile ) else: parseFile( rootPath + headerPath + sep, headerFile ) + elif ifImplParser.match(line): + implIfDefs = ifdefs elif (not guardParser.match( line ) or defineParser.match( line ) ) and not commentParser1.match( line )and not commentParser2.match( line ): if blankParser.match( line ): blanks = blanks + 1 else: blanks = 0 if blanks < 2: - out.write( line.rstrip() + "\n" ) + write( line.rstrip() + "\n" ) class Version: def __init__(self): From 3649fdf285b30b577273914e31b68580c0855756 Mon Sep 17 00:00:00 2001 From: Phil Nash Date: Tue, 3 Dec 2013 18:53:55 +0000 Subject: [PATCH 11/15] Build 15 --- README.md | 2 +- include/internal/catch_version.hpp | 2 +- single_include/catch.hpp | 2959 +++++++++++++++------------- 3 files changed, 1558 insertions(+), 1405 deletions(-) diff --git a/README.md b/README.md index 4d5f7507..ff20b3ff 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![catch logo](catch-logo-small.png) -*v1.0 build 14 (master branch)* +*v1.0 build 15 (master branch)* Build status (on Travis CI) [![Build Status](https://travis-ci.org/philsquared/Catch.png)](https://travis-ci.org/philsquared/Catch) diff --git a/include/internal/catch_version.hpp b/include/internal/catch_version.hpp index 466a9a43..6548fc98 100644 --- a/include/internal/catch_version.hpp +++ b/include/internal/catch_version.hpp @@ -13,7 +13,7 @@ namespace Catch { // These numbers are maintained by a script - Version libraryVersion( 1, 0, 14, "master" ); + Version libraryVersion( 1, 0, 15, "master" ); } #endif // TWOBLUECUBES_CATCH_VERSION_HPP_INCLUDED diff --git a/single_include/catch.hpp b/single_include/catch.hpp index b326de06..86385c66 100644 --- a/single_include/catch.hpp +++ b/single_include/catch.hpp @@ -1,6 +1,6 @@ /* - * CATCH v1.0 build 14 (master branch) - * Generated: 2013-11-26 20:54:38.067005 + * CATCH v1.0 build 15 (master branch) + * Generated: 2013-12-03 18:52:51.480072 * ---------------------------------------------------------- * This file has been merged from multiple headers. Please don't edit it directly * Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved. @@ -159,36 +159,17 @@ namespace Catch { std::for_each( container.begin(), container.end(), function ); } - inline bool startsWith( std::string const& s, std::string const& prefix ) { - return s.size() >= prefix.size() && s.substr( 0, prefix.size() ) == prefix; - } - inline bool endsWith( std::string const& s, std::string const& suffix ) { - return s.size() >= suffix.size() && s.substr( s.size()-suffix.size(), suffix.size() ) == suffix; - } - inline bool contains( std::string const& s, std::string const& infix ) { - return s.find( infix ) != std::string::npos; - } - inline void toLowerInPlace( std::string& s ) { - std::transform( s.begin(), s.end(), s.begin(), ::tolower ); - } - inline std::string toLower( std::string const& s ) { - std::string lc = s; - toLowerInPlace( lc ); - return lc; - } + bool startsWith( std::string const& s, std::string const& prefix ); + bool endsWith( std::string const& s, std::string const& suffix ); + bool contains( std::string const& s, std::string const& infix ); + void toLowerInPlace( std::string& s ); + std::string toLower( std::string const& s ); + std::string trim( std::string const& str ); struct pluralise { - pluralise( std::size_t count, std::string const& label ) - : m_count( count ), - m_label( label ) - {} + pluralise( std::size_t count, std::string const& label ); - friend std::ostream& operator << ( std::ostream& os, pluralise const& pluraliser ) { - os << pluraliser.m_count << " " << pluraliser.m_label; - if( pluraliser.m_count != 1 ) - os << "s"; - return os; - } + friend std::ostream& operator << ( std::ostream& os, pluralise const& pluraliser ); std::size_t m_count; std::string m_label; @@ -196,43 +177,22 @@ namespace Catch { struct SourceLineInfo { - SourceLineInfo() : line( 0 ){} - SourceLineInfo( std::string const& _file, std::size_t _line ) - : file( _file ), - line( _line ) - {} - SourceLineInfo( SourceLineInfo const& other ) - : file( other.file ), - line( other.line ) - {} - bool empty() const { - return file.empty(); - } - bool operator == ( SourceLineInfo const& other ) const { - return line == other.line && file == other.file; - } + SourceLineInfo(); + SourceLineInfo( std::string const& _file, std::size_t _line ); + SourceLineInfo( SourceLineInfo const& other ); + bool empty() const; + bool operator == ( SourceLineInfo const& other ) const; + std::string file; std::size_t line; }; - inline std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info ) { -#ifndef __GNUG__ - os << info.file << "(" << info.line << ")"; -#else - os << info.file << ":" << info.line; -#endif - return os; - } + std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info ); // This is just here to avoid compiler warnings with macro constants and boolean literals inline bool isTrue( bool value ){ return value; } - inline void throwLogicError( std::string const& message, SourceLineInfo const& locationInfo ) { - std::ostringstream oss; - oss << locationInfo << ": Internal Catch error: '" << message << "'"; - if( isTrue( true )) - throw std::logic_error( oss.str() ); - } + void throwLogicError( std::string const& message, SourceLineInfo const& locationInfo ); } #define CATCH_INTERNAL_LINEINFO ::Catch::SourceLineInfo( __FILE__, static_cast( __LINE__ ) ) @@ -1358,65 +1318,6 @@ namespace Catch { #define TWOBLUECUBES_CATCH_INTERFACES_CAPTURE_H_INCLUDED #include -// #included from: catch_totals.hpp -#define TWOBLUECUBES_CATCH_TOTALS_HPP_INCLUDED - -#include - -namespace Catch { - - struct Counts { - Counts() : passed( 0 ), failed( 0 ) {} - - Counts operator - ( Counts const& other ) const { - Counts diff; - diff.passed = passed - other.passed; - diff.failed = failed - other.failed; - return diff; - } - Counts& operator += ( Counts const& other ) { - passed += other.passed; - failed += other.failed; - return *this; - } - - std::size_t total() const { - return passed + failed; - } - - std::size_t passed; - std::size_t failed; - }; - - struct Totals { - - Totals operator - ( Totals const& other ) const { - Totals diff; - diff.assertions = assertions - other.assertions; - diff.testCases = testCases - other.testCases; - return diff; - } - - Totals delta( Totals const& prevTotals ) const { - Totals diff = *this - prevTotals; - if( diff.assertions.failed > 0 ) - ++diff.testCases.failed; - else - ++diff.testCases.passed; - return diff; - } - - Totals& operator += ( Totals const& other ) { - assertions += other.assertions; - testCases += other.testCases; - return *this; - } - - Counts assertions; - Counts testCases; - }; -} - namespace Catch { @@ -1427,6 +1328,7 @@ namespace Catch { struct SectionInfo; struct MessageInfo; class ScopedMessageBuilder; + struct Counts; struct IResultCapture { @@ -1448,10 +1350,8 @@ namespace Catch { }; } -// #included from: catch_debugger.hpp -#define TWOBLUECUBES_CATCH_DEBUGGER_HPP_INCLUDED - -#include +// #included from: catch_debugger.h +#define TWOBLUECUBES_CATCH_DEBUGGER_H_INCLUDED // #included from: catch_platform.h #define TWOBLUECUBES_CATCH_PLATFORM_H_INCLUDED @@ -1464,516 +1364,74 @@ namespace Catch { #define CATCH_PLATFORM_WINDOWS #endif +#include + +namespace Catch{ + + bool isDebuggerActive(); + void writeToDebugConsole( std::string const& text ); +} + #ifdef CATCH_PLATFORM_MAC - #include - #include - #include - #include - #include - - namespace Catch{ - - // The following function is taken directly from the following technical note: - // http://developer.apple.com/library/mac/#qa/qa2004/qa1361.html - - // Returns true if the current process is being debugged (either - // running under the debugger or has a debugger attached post facto). - inline bool isDebuggerActive(){ - - int junk; - int mib[4]; - struct kinfo_proc info; - size_t size; - - // Initialize the flags so that, if sysctl fails for some bizarre - // reason, we get a predictable result. - - info.kp_proc.p_flag = 0; - - // Initialize mib, which tells sysctl the info we want, in this case - // we're looking for information about a specific process ID. - - mib[0] = CTL_KERN; - mib[1] = KERN_PROC; - mib[2] = KERN_PROC_PID; - mib[3] = getpid(); - - // Call sysctl. - - size = sizeof(info); - junk = sysctl(mib, sizeof(mib) / sizeof(*mib), &info, &size, NULL, 0); - assert(junk == 0); - - // We're being debugged if the P_TRACED flag is set. - - return ( (info.kp_proc.p_flag & P_TRACED) != 0 ); - } - } - - // The following code snippet taken from: + // The following code snippet based on: // http://cocoawithlove.com/2008/03/break-into-debugger.html #ifdef DEBUG #if defined(__ppc64__) || defined(__ppc__) - #define BreakIntoDebugger() \ - if( Catch::isDebuggerActive() ) { \ - __asm__("li r0, 20\nsc\nnop\nli r0, 37\nli r4, 2\nsc\nnop\n" \ - : : : "memory","r0","r3","r4" ); \ - } + #define CATCH_BREAK_INTO_DEBUGGER() \ + if( Catch::isDebuggerActive() ) { \ + __asm__("li r0, 20\nsc\nnop\nli r0, 37\nli r4, 2\nsc\nnop\n" \ + : : : "memory","r0","r3","r4" ); \ + } #else - #define BreakIntoDebugger() if( Catch::isDebuggerActive() ) {__asm__("int $3\n" : : );} + #define CATCH_BREAK_INTO_DEBUGGER() if( Catch::isDebuggerActive() ) {__asm__("int $3\n" : : );} #endif - #else - inline void BreakIntoDebugger(){} #endif #elif defined(_MSC_VER) - extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent(); - #define BreakIntoDebugger() if (IsDebuggerPresent() ) { __debugbreak(); } - inline bool isDebuggerActive() { - return IsDebuggerPresent() != 0; - } + #define CATCH_BREAK_INTO_DEBUGGER() if( Catch::isDebuggerActive() ) { __debugbreak(); } #elif defined(__MINGW32__) - extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent(); extern "C" __declspec(dllimport) void __stdcall DebugBreak(); - #define BreakIntoDebugger() if (IsDebuggerPresent() ) { DebugBreak(); } - inline bool isDebuggerActive() { - return IsDebuggerPresent() != 0; - } -#else - inline void BreakIntoDebugger(){} - inline bool isDebuggerActive() { return false; } + #define CATCH_BREAK_INTO_DEBUGGER() if( Catch::isDebuggerActive() ) { DebugBreak(); } #endif -#ifdef CATCH_PLATFORM_WINDOWS -extern "C" __declspec(dllimport) void __stdcall OutputDebugStringA( const char* ); -inline void writeToDebugConsole( std::string const& text ) { - ::OutputDebugStringA( text.c_str() ); -} -#else -inline void writeToDebugConsole( std::string const& text ) { - // !TBD: Need a version for Mac/ XCode and other IDEs - std::cout << text; -} -#endif // CATCH_PLATFORM_WINDOWS +#ifndef CATCH_BREAK_INTO_DEBUGGER +#define CATCH_BREAK_INTO_DEBUGGER() +#endif // #included from: catch_interfaces_registry_hub.h #define TWOBLUECUBES_CATCH_INTERFACES_REGISTRY_HUB_H_INCLUDED -// #included from: catch_interfaces_reporter.h -#define TWOBLUECUBES_CATCH_INTERFACES_REPORTER_H_INCLUDED - -// #included from: catch_config.hpp -#define TWOBLUECUBES_CATCH_CONFIG_HPP_INCLUDED - -// #included from: catch_test_spec.h -#define TWOBLUECUBES_CATCH_TEST_SPEC_H_INCLUDED - -// #included from: catch_test_case_info.h -#define TWOBLUECUBES_CATCH_TEST_CASE_INFO_H_INCLUDED - #include -#include - -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wpadded" -#endif namespace Catch { - struct ITestCase; + class TestCase; + struct ITestCaseRegistry; + struct IExceptionTranslatorRegistry; + struct IExceptionTranslator; + struct IReporterRegistry; + struct IReporterFactory; - struct TestCaseInfo { - TestCaseInfo( std::string const& _name, - std::string const& _className, - std::string const& _description, - std::set const& _tags, - bool _isHidden, - SourceLineInfo const& _lineInfo ); + struct IRegistryHub { + virtual ~IRegistryHub(); - TestCaseInfo( TestCaseInfo const& other ); - - std::string name; - std::string className; - std::string description; - std::set tags; - std::string tagsAsString; - SourceLineInfo lineInfo; - bool isHidden; + virtual IReporterRegistry const& getReporterRegistry() const = 0; + virtual ITestCaseRegistry const& getTestCaseRegistry() const = 0; + virtual IExceptionTranslatorRegistry& getExceptionTranslatorRegistry() = 0; }; - class TestCase : protected TestCaseInfo { - public: - - TestCase( ITestCase* testCase, TestCaseInfo const& info ); - TestCase( TestCase const& other ); - - TestCase withName( std::string const& _newName ) const; - - void invoke() const; - - TestCaseInfo const& getTestCaseInfo() const; - - bool isHidden() const; - bool hasTag( std::string const& tag ) const; - bool matchesTags( std::string const& tagPattern ) const; - std::set const& getTags() const; - - void swap( TestCase& other ); - bool operator == ( TestCase const& other ) const; - bool operator < ( TestCase const& other ) const; - TestCase& operator = ( TestCase const& other ); - - private: - Ptr test; + struct IMutableRegistryHub { + virtual ~IMutableRegistryHub(); + virtual void registerReporter( std::string const& name, IReporterFactory* factory ) = 0; + virtual void registerTest( TestCase const& testInfo ) = 0; + virtual void registerTranslator( const IExceptionTranslator* translator ) = 0; }; - TestCase makeTestCase( ITestCase* testCase, - std::string const& className, - std::string const& name, - std::string const& description, - SourceLineInfo const& lineInfo ); -} - -#ifdef __clang__ -#pragma clang diagnostic pop -#endif - -// #included from: catch_tags.hpp -#define TWOBLUECUBES_CATCH_TAGS_HPP_INCLUDED - -#include -#include -#include -#include - -#ifdef __clang__ -#pragma clang diagnostic ignored "-Wpadded" -#endif - -namespace Catch { - class TagParser { - public: - virtual ~TagParser(); - - void parse( std::string const& str ) { - std::size_t pos = 0; - while( pos < str.size() ) { - char c = str[pos]; - if( c == '[' ) { - std::size_t end = str.find_first_of( ']', pos ); - if( end != std::string::npos ) { - acceptTag( str.substr( pos+1, end-pos-1 ) ); - pos = end+1; - } - else { - acceptChar( c ); - pos++; - } - } - else { - acceptChar( c ); - pos++; - } - } - endParse(); - } - - protected: - virtual void acceptTag( std::string const& tag ) = 0; - virtual void acceptChar( char c ) = 0; - virtual void endParse() {} - - private: - }; - - class TagExtracter : public TagParser { - public: - - TagExtracter( std::set& tags ) - : m_tags( tags ) - {} - virtual ~TagExtracter(); - - void parse( std::string& description ) { - TagParser::parse( description ); - description = m_remainder; - } - - private: - virtual void acceptTag( std::string const& tag ) { - m_tags.insert( toLower( tag ) ); - } - virtual void acceptChar( char c ) { - m_remainder += c; - } - - TagExtracter& operator=(TagExtracter const&); - - std::set& m_tags; - std::string m_remainder; - }; - - class Tag { - public: - Tag() - : m_isNegated( false ) - {} - - Tag( std::string const& name, bool isNegated ) - : m_name( name ), - m_isNegated( isNegated ) - {} - - std::string getName() const { - return m_name; - } - bool isNegated() const { - return m_isNegated; - } - - bool operator ! () const { - return m_name.empty(); - } - - private: - std::string m_name; - bool m_isNegated; - }; - - class TagSet { - typedef std::map TagMap; - public: - void add( Tag const& tag ) { - m_tags.insert( std::make_pair( toLower( tag.getName() ), tag ) ); - } - - bool empty() const { - return m_tags.empty(); - } - - bool matches( std::set const& tags ) const { - for( TagMap::const_iterator - it = m_tags.begin(), itEnd = m_tags.end(); - it != itEnd; - ++it ) { - bool found = tags.find( it->first ) != tags.end(); - if( found == it->second.isNegated() ) - return false; - } - return true; - } - - private: - TagMap m_tags; - }; - - class TagExpression { - public: - bool matches( std::set const& tags ) const { - for( std::vector::const_iterator - it = m_tagSets.begin(), itEnd = m_tagSets.end(); - it != itEnd; - ++it ) - if( it->matches( tags ) ) - return true; - return false; - } - - private: - friend class TagExpressionParser; - - std::vector m_tagSets; - }; - - class TagExpressionParser : public TagParser { - public: - TagExpressionParser( TagExpression& exp ) - : m_isNegated( false ), - m_exp( exp ) - {} - - ~TagExpressionParser(); - - private: - virtual void acceptTag( std::string const& tag ) { - m_currentTagSet.add( Tag( tag, m_isNegated ) ); - m_isNegated = false; - } - virtual void acceptChar( char c ) { - switch( c ) { - case '~': - m_isNegated = true; - break; - case ',': - m_exp.m_tagSets.push_back( m_currentTagSet ); - m_currentTagSet = TagSet(); - break; - } - } - virtual void endParse() { - if( !m_currentTagSet.empty() ) - m_exp.m_tagSets.push_back( m_currentTagSet ); - } - - TagExpressionParser& operator=(TagExpressionParser const&); - - bool m_isNegated; - TagSet m_currentTagSet; - TagExpression& m_exp; - }; - -} // end namespace Catch - -#include -#include - -namespace Catch { - - struct IfFilterMatches{ enum DoWhat { - AutoDetectBehaviour, - IncludeTests, - ExcludeTests - }; }; - - class TestCaseFilter { - enum WildcardPosition { - NoWildcard = 0, - WildcardAtStart = 1, - WildcardAtEnd = 2, - WildcardAtBothEnds = WildcardAtStart | WildcardAtEnd - }; - - public: - TestCaseFilter( std::string const& testSpec, IfFilterMatches::DoWhat matchBehaviour = IfFilterMatches::AutoDetectBehaviour ) - : m_stringToMatch( toLower( testSpec ) ), - m_filterType( matchBehaviour ), - m_wildcardPosition( NoWildcard ) - { - if( m_filterType == IfFilterMatches::AutoDetectBehaviour ) { - if( startsWith( m_stringToMatch, "exclude:" ) ) { - m_stringToMatch = m_stringToMatch.substr( 8 ); - m_filterType = IfFilterMatches::ExcludeTests; - } - else if( startsWith( m_stringToMatch, "~" ) ) { - m_stringToMatch = m_stringToMatch.substr( 1 ); - m_filterType = IfFilterMatches::ExcludeTests; - } - else { - m_filterType = IfFilterMatches::IncludeTests; - } - } - - if( startsWith( m_stringToMatch, "*" ) ) { - m_stringToMatch = m_stringToMatch.substr( 1 ); - m_wildcardPosition = (WildcardPosition)( m_wildcardPosition | WildcardAtStart ); - } - if( endsWith( m_stringToMatch, "*" ) ) { - m_stringToMatch = m_stringToMatch.substr( 0, m_stringToMatch.size()-1 ); - m_wildcardPosition = (WildcardPosition)( m_wildcardPosition | WildcardAtEnd ); - } - } - - IfFilterMatches::DoWhat getFilterType() const { - return m_filterType; - } - - bool shouldInclude( TestCase const& testCase ) const { - return isMatch( testCase ) == (m_filterType == IfFilterMatches::IncludeTests); - } - private: - -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wunreachable-code" -#endif - - bool isMatch( TestCase const& testCase ) const { - std::string name = testCase.getTestCaseInfo().name; - toLowerInPlace( name ); - - switch( m_wildcardPosition ) { - case NoWildcard: - return m_stringToMatch == name; - case WildcardAtStart: - return endsWith( name, m_stringToMatch ); - case WildcardAtEnd: - return startsWith( name, m_stringToMatch ); - case WildcardAtBothEnds: - return contains( name, m_stringToMatch ); - } - throw std::logic_error( "Unhandled wildcard type" ); - } - -#ifdef __clang__ -#pragma clang diagnostic pop -#endif - - std::string m_stringToMatch; - IfFilterMatches::DoWhat m_filterType; - WildcardPosition m_wildcardPosition; - }; - - class TestCaseFilters { - public: - TestCaseFilters( std::string const& name ) : m_name( name ) {} - - std::string getName() const { - return m_name; - } - - void addFilter( TestCaseFilter const& filter ) { - if( filter.getFilterType() == IfFilterMatches::ExcludeTests ) - m_exclusionFilters.push_back( filter ); - else - m_inclusionFilters.push_back( filter ); - } - - void addTags( std::string const& tagPattern ) { - TagExpression exp; - TagExpressionParser( exp ).parse( tagPattern ); - - m_tagExpressions.push_back( exp ); - } - - bool shouldInclude( TestCase const& testCase ) const { - if( !m_tagExpressions.empty() ) { - std::vector::const_iterator it = m_tagExpressions.begin(); - std::vector::const_iterator itEnd = m_tagExpressions.end(); - for(; it != itEnd; ++it ) - if( it->matches( testCase.getTags() ) ) - break; - if( it == itEnd ) - return false; - } - - if( !m_inclusionFilters.empty() ) { - std::vector::const_iterator it = m_inclusionFilters.begin(); - std::vector::const_iterator itEnd = m_inclusionFilters.end(); - for(; it != itEnd; ++it ) - if( it->shouldInclude( testCase ) ) - break; - if( it == itEnd ) - return false; - } - else if( m_exclusionFilters.empty() && m_tagExpressions.empty() ) { - return !testCase.isHidden(); - } - - std::vector::const_iterator it = m_exclusionFilters.begin(); - std::vector::const_iterator itEnd = m_exclusionFilters.end(); - for(; it != itEnd; ++it ) - if( !it->shouldInclude( testCase ) ) - return false; - return true; - } - private: - std::vector m_tagExpressions; - std::vector m_inclusionFilters; - std::vector m_exclusionFilters; - std::string m_name; - }; + IRegistryHub& getRegistryHub(); + IMutableRegistryHub& getMutableRegistryHub(); + void cleanUp(); + std::string translateActiveException(); } @@ -2017,773 +1475,6 @@ namespace Catch { }; } -// #included from: catch_stream.hpp -#define TWOBLUECUBES_CATCH_STREAM_HPP_INCLUDED - -// #included from: catch_streambuf.h -#define TWOBLUECUBES_CATCH_STREAMBUF_H_INCLUDED - -#include - -namespace Catch { - - class StreamBufBase : public std::streambuf { - public: - virtual ~StreamBufBase() throw(); - }; -} - -#include -#include - -namespace Catch { - - template - class StreamBufImpl : public StreamBufBase { - char data[bufferSize]; - WriterF m_writer; - - public: - StreamBufImpl() { - setp( data, data + sizeof(data) ); - } - - ~StreamBufImpl() throw() { - sync(); - } - - private: - int overflow( int c ) { - sync(); - - if( c != EOF ) { - if( pbase() == epptr() ) - m_writer( std::string( 1, static_cast( c ) ) ); - else - sputc( static_cast( c ) ); - } - return 0; - } - - int sync() { - if( pbase() != pptr() ) { - m_writer( std::string( pbase(), static_cast( pptr() - pbase() ) ) ); - setp( pbase(), epptr() ); - } - return 0; - } - }; - - /////////////////////////////////////////////////////////////////////////// - - struct OutputDebugWriter { - - void operator()( std::string const&str ) { - writeToDebugConsole( str ); - } - }; - - class Stream { - public: - Stream() - : streamBuf( NULL ), isOwned( false ) - {} - - Stream( std::streambuf* _streamBuf, bool _isOwned ) - : streamBuf( _streamBuf ), isOwned( _isOwned ) - {} - - void release() { - if( isOwned ) { - delete streamBuf; - streamBuf = NULL; - isOwned = false; - } - } - - std::streambuf* streamBuf; - - private: - bool isOwned; - }; -} - -#include -#include -#include -#include - -#ifndef CATCH_CONFIG_CONSOLE_WIDTH -#define CATCH_CONFIG_CONSOLE_WIDTH 80 -#endif - -namespace Catch { - - struct ConfigData { - - ConfigData() - : listTests( false ), - listTags( false ), - listReporters( false ), - listTestNamesOnly( false ), - showSuccessfulTests( false ), - shouldDebugBreak( false ), - noThrow( false ), - showHelp( false ), - abortAfter( -1 ), - verbosity( Verbosity::Normal ), - warnings( WarnAbout::Nothing ), - showDurations( ShowDurations::DefaultForReporter ) - {} - - bool listTests; - bool listTags; - bool listReporters; - bool listTestNamesOnly; - - bool showSuccessfulTests; - bool shouldDebugBreak; - bool noThrow; - bool showHelp; - - int abortAfter; - - Verbosity::Level verbosity; - WarnAbout::What warnings; - ShowDurations::OrNot showDurations; - - std::string reporterName; - std::string outputFilename; - std::string name; - std::string processName; - - std::vector testsOrTags; - }; - - class Config : public SharedImpl { - private: - Config( Config const& other ); - Config& operator = ( Config const& other ); - virtual void dummy(); - public: - - Config() - : m_os( std::cout.rdbuf() ) - {} - - Config( ConfigData const& data ) - : m_data( data ), - m_os( std::cout.rdbuf() ) - { - if( !data.testsOrTags.empty() ) { - std::string groupName; - for( std::size_t i = 0; i < data.testsOrTags.size(); ++i ) { - if( i != 0 ) - groupName += " "; - groupName += data.testsOrTags[i]; - } - TestCaseFilters filters( groupName ); - for( std::size_t i = 0; i < data.testsOrTags.size(); ++i ) { - std::string filter = data.testsOrTags[i]; - if( startsWith( filter, "[" ) || startsWith( filter, "~[" ) ) - filters.addTags( filter ); - else - filters.addFilter( TestCaseFilter( filter ) ); - } - m_filterSets.push_back( filters ); - } - } - - virtual ~Config() { - m_os.rdbuf( std::cout.rdbuf() ); - m_stream.release(); - } - - void setFilename( std::string const& filename ) { - m_data.outputFilename = filename; - } - - std::string const& getFilename() const { - return m_data.outputFilename ; - } - - bool listTests() const { return m_data.listTests; } - bool listTestNamesOnly() const { return m_data.listTestNamesOnly; } - bool listTags() const { return m_data.listTags; } - bool listReporters() const { return m_data.listReporters; } - - std::string getProcessName() const { - return m_data.processName; - } - - bool shouldDebugBreak() const { - return m_data.shouldDebugBreak; - } - - void setStreamBuf( std::streambuf* buf ) { - m_os.rdbuf( buf ? buf : std::cout.rdbuf() ); - } - - void useStream( std::string const& streamName ) { - Stream stream = createStream( streamName ); - setStreamBuf( stream.streamBuf ); - m_stream.release(); - m_stream = stream; - } - - std::string getReporterName() const { return m_data.reporterName; } - - void addTestSpec( std::string const& testSpec ) { - TestCaseFilters filters( testSpec ); - filters.addFilter( TestCaseFilter( testSpec ) ); - m_filterSets.push_back( filters ); - } - - int abortAfter() const { - return m_data.abortAfter; - } - - std::vector const& filters() const { - return m_filterSets; - } - - bool showHelp() const { return m_data.showHelp; } - - // IConfig interface - virtual bool allowThrows() const { return !m_data.noThrow; } - virtual std::ostream& stream() const { return m_os; } - virtual std::string name() const { return m_data.name.empty() ? m_data.processName : m_data.name; } - virtual bool includeSuccessfulResults() const { return m_data.showSuccessfulTests; } - virtual bool warnAboutMissingAssertions() const { return m_data.warnings & WarnAbout::NoAssertions; } - virtual ShowDurations::OrNot showDurations() const { return m_data.showDurations; } - - private: - ConfigData m_data; - - Stream m_stream; - mutable std::ostream m_os; - std::vector m_filterSets; - }; - -} // end namespace Catch - -// #included from: catch_option.hpp -#define TWOBLUECUBES_CATCH_OPTION_HPP_INCLUDED - -namespace Catch { - - // An optional type - template - class Option { - public: - Option() : nullableValue( NULL ) {} - Option( T const& _value ) - : nullableValue( new( storage ) T( _value ) ) - {} - Option( Option const& _other ) - : nullableValue( _other ? new( storage ) T( *_other ) : NULL ) - {} - - ~Option() { - reset(); - } - - Option& operator= ( Option const& _other ) { - reset(); - if( _other ) - nullableValue = new( storage ) T( *_other ); - return *this; - } - Option& operator = ( T const& _value ) { - reset(); - nullableValue = new( storage ) T( _value ); - return *this; - } - - void reset() { - if( nullableValue ) - nullableValue->~T(); - nullableValue = NULL; - } - - T& operator*() { return *nullableValue; } - T const& operator*() const { return *nullableValue; } - T* operator->() { return nullableValue; } - const T* operator->() const { return nullableValue; } - - T valueOr( T const& defaultValue ) const { - return nullableValue ? *nullableValue : defaultValue; - } - - bool some() const { return nullableValue != NULL; } - bool none() const { return nullableValue == NULL; } - - bool operator !() const { return nullableValue == NULL; } - operator SafeBool::type() const { - return SafeBool::makeSafe( some() ); - } - - private: - T* nullableValue; - char storage[sizeof(T)]; - }; - -} // end namespace Catch - -#include -#include -#include -#include - -namespace Catch -{ - struct ReporterConfig { - explicit ReporterConfig( Ptr const& _fullConfig ) - : m_stream( &_fullConfig->stream() ), m_fullConfig( _fullConfig ) {} - - ReporterConfig( Ptr const& _fullConfig, std::ostream& _stream ) - : m_stream( &_stream ), m_fullConfig( _fullConfig ) {} - - std::ostream& stream() const { return *m_stream; } - Ptr fullConfig() const { return m_fullConfig; } - - private: - std::ostream* m_stream; - Ptr m_fullConfig; - }; - - struct ReporterPreferences { - ReporterPreferences() - : shouldRedirectStdOut( false ) - {} - - bool shouldRedirectStdOut; - }; - - template - struct LazyStat : Option { - LazyStat() : used( false ) {} - LazyStat& operator=( T const& _value ) { - Option::operator=( _value ); - used = false; - return *this; - } - void reset() { - Option::reset(); - used = false; - } - bool used; - }; - - struct TestRunInfo { - TestRunInfo( std::string const& _name ) : name( _name ) {} - std::string name; - }; - struct GroupInfo { - GroupInfo( std::string const& _name, - std::size_t _groupIndex, - std::size_t _groupsCount ) - : name( _name ), - groupIndex( _groupIndex ), - groupsCounts( _groupsCount ) - {} - - std::string name; - std::size_t groupIndex; - std::size_t groupsCounts; - }; - - struct SectionInfo { - SectionInfo( std::string const& _name, - std::string const& _description, - SourceLineInfo const& _lineInfo ) - : name( _name ), - description( _description ), - lineInfo( _lineInfo ) - {} - - std::string name; - std::string description; - SourceLineInfo lineInfo; - }; - - struct AssertionStats { - AssertionStats( AssertionResult const& _assertionResult, - std::vector const& _infoMessages, - Totals const& _totals ) - : assertionResult( _assertionResult ), - infoMessages( _infoMessages ), - totals( _totals ) - { - if( assertionResult.hasMessage() ) { - // Copy message into messages list. - // !TBD This should have been done earlier, somewhere - MessageBuilder builder( assertionResult.getTestMacroName(), assertionResult.getSourceInfo(), assertionResult.getResultType() ); - builder << assertionResult.getMessage(); - builder.m_info.message = builder.m_stream.str(); - - infoMessages.push_back( builder.m_info ); - } - } - virtual ~AssertionStats(); - - AssertionResult assertionResult; - std::vector infoMessages; - Totals totals; - }; - - struct SectionStats { - SectionStats( SectionInfo const& _sectionInfo, - Counts const& _assertions, - double _durationInSeconds, - bool _missingAssertions ) - : sectionInfo( _sectionInfo ), - assertions( _assertions ), - durationInSeconds( _durationInSeconds ), - missingAssertions( _missingAssertions ) - {} - virtual ~SectionStats(); - - SectionInfo sectionInfo; - Counts assertions; - double durationInSeconds; - bool missingAssertions; - }; - - struct TestCaseStats { - TestCaseStats( TestCaseInfo const& _testInfo, - Totals const& _totals, - std::string const& _stdOut, - std::string const& _stdErr, - bool _aborting ) - : testInfo( _testInfo ), - totals( _totals ), - stdOut( _stdOut ), - stdErr( _stdErr ), - aborting( _aborting ) - {} - virtual ~TestCaseStats(); - - TestCaseInfo testInfo; - Totals totals; - std::string stdOut; - std::string stdErr; - bool aborting; - }; - - struct TestGroupStats { - TestGroupStats( GroupInfo const& _groupInfo, - Totals const& _totals, - bool _aborting ) - : groupInfo( _groupInfo ), - totals( _totals ), - aborting( _aborting ) - {} - TestGroupStats( GroupInfo const& _groupInfo ) - : groupInfo( _groupInfo ), - aborting( false ) - {} - virtual ~TestGroupStats(); - - GroupInfo groupInfo; - Totals totals; - bool aborting; - }; - - struct TestRunStats { - TestRunStats( TestRunInfo const& _runInfo, - Totals const& _totals, - bool _aborting ) - : runInfo( _runInfo ), - totals( _totals ), - aborting( _aborting ) - {} - TestRunStats( TestRunStats const& _other ) - : runInfo( _other.runInfo ), - totals( _other.totals ), - aborting( _other.aborting ) - {} - virtual ~TestRunStats(); - - TestRunInfo runInfo; - Totals totals; - bool aborting; - }; - - struct IStreamingReporter : IShared { - virtual ~IStreamingReporter(); - - // Implementing class must also provide the following static method: - // static std::string getDescription(); - - virtual ReporterPreferences getPreferences() const = 0; - - virtual void noMatchingTestCases( std::string const& spec ) = 0; - - virtual void testRunStarting( TestRunInfo const& testRunInfo ) = 0; - virtual void testGroupStarting( GroupInfo const& groupInfo ) = 0; - - virtual void testCaseStarting( TestCaseInfo const& testInfo ) = 0; - virtual void sectionStarting( SectionInfo const& sectionInfo ) = 0; - - virtual void assertionStarting( AssertionInfo const& assertionInfo ) = 0; - - virtual bool assertionEnded( AssertionStats const& assertionStats ) = 0; - virtual void sectionEnded( SectionStats const& sectionStats ) = 0; - virtual void testCaseEnded( TestCaseStats const& testCaseStats ) = 0; - virtual void testGroupEnded( TestGroupStats const& testGroupStats ) = 0; - virtual void testRunEnded( TestRunStats const& testRunStats ) = 0; - }; - - struct StreamingReporterBase : SharedImpl { - - StreamingReporterBase( ReporterConfig const& _config ) - : m_config( _config.fullConfig() ), - stream( _config.stream() ) - {} - - virtual ~StreamingReporterBase(); - - virtual void noMatchingTestCases( std::string const& ) {} - - virtual void testRunStarting( TestRunInfo const& _testRunInfo ) { - currentTestRunInfo = _testRunInfo; - } - virtual void testGroupStarting( GroupInfo const& _groupInfo ) { - currentGroupInfo = _groupInfo; - } - - virtual void testCaseStarting( TestCaseInfo const& _testInfo ) { - currentTestCaseInfo = _testInfo; - } - virtual void sectionStarting( SectionInfo const& _sectionInfo ) { - m_sectionStack.push_back( _sectionInfo ); - } - - virtual void sectionEnded( SectionStats const& /* _sectionStats */ ) { - m_sectionStack.pop_back(); - } - virtual void testCaseEnded( TestCaseStats const& /* _testCaseStats */ ) { - currentTestCaseInfo.reset(); - assert( m_sectionStack.empty() ); - } - virtual void testGroupEnded( TestGroupStats const& /* _testGroupStats */ ) { - currentGroupInfo.reset(); - } - virtual void testRunEnded( TestRunStats const& /* _testRunStats */ ) { - currentTestCaseInfo.reset(); - currentGroupInfo.reset(); - currentTestRunInfo.reset(); - } - - Ptr m_config; - std::ostream& stream; - - LazyStat currentTestRunInfo; - LazyStat currentGroupInfo; - LazyStat currentTestCaseInfo; - - std::vector m_sectionStack; - }; - - struct CumulativeReporterBase : SharedImpl { - template - struct Node : SharedImpl<> { - explicit Node( T const& _value ) : value( _value ) {} - virtual ~Node() {} - - typedef std::vector > ChildNodes; - T value; - ChildNodes children; - }; - struct SectionNode : SharedImpl<> { - explicit SectionNode( SectionStats const& _stats ) : stats( _stats ) {} - virtual ~SectionNode(); - - bool operator == ( SectionNode const& other ) const { - return stats.sectionInfo.lineInfo == other.stats.sectionInfo.lineInfo; - } - bool operator == ( Ptr const& other ) const { - return operator==( *other ); - } - - SectionStats stats; - typedef std::vector > ChildSections; - typedef std::vector Assertions; - ChildSections childSections; - Assertions assertions; - std::string stdOut; - std::string stdErr; - }; - friend bool operator == ( Ptr const& node, SectionInfo const& other ) { - return node->stats.sectionInfo.lineInfo == other.lineInfo; - } - - typedef Node TestCaseNode; - typedef Node TestGroupNode; - typedef Node TestRunNode; - - CumulativeReporterBase( ReporterConfig const& _config ) - : m_config( _config.fullConfig() ), - stream( _config.stream() ) - {} - ~CumulativeReporterBase(); - - virtual void testRunStarting( TestRunInfo const& ) {} - virtual void testGroupStarting( GroupInfo const& ) {} - - virtual void testCaseStarting( TestCaseInfo const& ) {} - - virtual void sectionStarting( SectionInfo const& sectionInfo ) { - SectionStats incompleteStats( sectionInfo, Counts(), 0, false ); - Ptr node; - if( m_sectionStack.empty() ) { - if( !m_rootSection ) - m_rootSection = new SectionNode( incompleteStats ); - node = m_rootSection; - } - else { - SectionNode& parentNode = *m_sectionStack.back(); - SectionNode::ChildSections::const_iterator it = - std::find( parentNode.childSections.begin(), parentNode.childSections.end(), sectionInfo ); - if( it == parentNode.childSections.end() ) { - node = new SectionNode( incompleteStats ); - parentNode.childSections.push_back( node ); - } - else - node = *it; - } - m_sectionStack.push_back( node ); - m_deepestSection = node; - } - - virtual void assertionStarting( AssertionInfo const& ) {} - - virtual bool assertionEnded( AssertionStats const& assertionStats ) { - assert( !m_sectionStack.empty() ); - SectionNode& sectionNode = *m_sectionStack.back(); - sectionNode.assertions.push_back( assertionStats ); - return true; - } - virtual void sectionEnded( SectionStats const& sectionStats ) { - assert( !m_sectionStack.empty() ); - SectionNode& node = *m_sectionStack.back(); - node.stats = sectionStats; - m_sectionStack.pop_back(); - } - virtual void testCaseEnded( TestCaseStats const& testCaseStats ) { - Ptr node = new TestCaseNode( testCaseStats ); - assert( m_sectionStack.size() == 0 ); - node->children.push_back( m_rootSection ); - m_testCases.push_back( node ); - m_rootSection.reset(); - - assert( m_deepestSection ); - m_deepestSection->stdOut = testCaseStats.stdOut; - m_deepestSection->stdErr = testCaseStats.stdErr; - } - virtual void testGroupEnded( TestGroupStats const& testGroupStats ) { - Ptr node = new TestGroupNode( testGroupStats ); - node->children.swap( m_testCases ); - m_testGroups.push_back( node ); - } - virtual void testRunEnded( TestRunStats const& testRunStats ) { - Ptr node = new TestRunNode( testRunStats ); - node->children.swap( m_testGroups ); - m_testRuns.push_back( node ); - testRunEnded(); - } - virtual void testRunEnded() = 0; - - Ptr m_config; - std::ostream& stream; - std::vector m_assertions; - std::vector > > m_sections; - std::vector > m_testCases; - std::vector > m_testGroups; - - std::vector > m_testRuns; - - Ptr m_rootSection; - Ptr m_deepestSection; - std::vector > m_sectionStack; - - }; - - // Deprecated - struct IReporter : IShared { - virtual ~IReporter(); - - virtual bool shouldRedirectStdout() const = 0; - - virtual void StartTesting() = 0; - virtual void EndTesting( Totals const& totals ) = 0; - virtual void StartGroup( std::string const& groupName ) = 0; - virtual void EndGroup( std::string const& groupName, Totals const& totals ) = 0; - virtual void StartTestCase( TestCaseInfo const& testInfo ) = 0; - virtual void EndTestCase( TestCaseInfo const& testInfo, Totals const& totals, std::string const& stdOut, std::string const& stdErr ) = 0; - virtual void StartSection( std::string const& sectionName, std::string const& description ) = 0; - virtual void EndSection( std::string const& sectionName, Counts const& assertions ) = 0; - virtual void NoAssertionsInSection( std::string const& sectionName ) = 0; - virtual void NoAssertionsInTestCase( std::string const& testName ) = 0; - virtual void Aborted() = 0; - virtual void Result( AssertionResult const& result ) = 0; - }; - - struct IReporterFactory { - virtual ~IReporterFactory(); - virtual IStreamingReporter* create( ReporterConfig const& config ) const = 0; - virtual std::string getDescription() const = 0; - }; - - struct IReporterRegistry { - typedef std::map FactoryMap; - - virtual ~IReporterRegistry(); - virtual IStreamingReporter* create( std::string const& name, Ptr const& config ) const = 0; - virtual FactoryMap const& getFactories() const = 0; - }; - - inline std::string trim( std::string const& str ) { - static char const* whitespaceChars = "\n\r\t "; - std::string::size_type start = str.find_first_not_of( whitespaceChars ); - std::string::size_type end = str.find_last_not_of( whitespaceChars ); - - return start != std::string::npos ? str.substr( start, 1+end-start ) : ""; - } -} - -#include - -namespace Catch { - - class TestCase; - struct ITestCaseRegistry; - struct IExceptionTranslatorRegistry; - struct IExceptionTranslator; - - struct IRegistryHub { - virtual ~IRegistryHub(); - - virtual IReporterRegistry const& getReporterRegistry() const = 0; - virtual ITestCaseRegistry const& getTestCaseRegistry() const = 0; - virtual IExceptionTranslatorRegistry& getExceptionTranslatorRegistry() = 0; - }; - - struct IMutableRegistryHub { - virtual ~IMutableRegistryHub(); - virtual void registerReporter( std::string const& name, IReporterFactory* factory ) = 0; - virtual void registerTest( TestCase const& testInfo ) = 0; - virtual void registerTranslator( const IExceptionTranslator* translator ) = 0; - }; - - IRegistryHub& getRegistryHub(); - IMutableRegistryHub& getMutableRegistryHub(); - void cleanUp(); - std::string translateActiveException(); - -} - #include namespace Catch { @@ -2831,7 +1522,7 @@ struct TestFailureException{}; /////////////////////////////////////////////////////////////////////////////// #define INTERNAL_CATCH_ACCEPT_EXPR( evaluatedExpr, resultDisposition, originalExpr ) \ if( Catch::ResultAction::Value internal_catch_action = Catch::getResultCapture().acceptExpression( evaluatedExpr, INTERNAL_CATCH_ASSERTIONINFO_NAME ) ) { \ - if( internal_catch_action & Catch::ResultAction::Debug ) BreakIntoDebugger(); \ + if( internal_catch_action & Catch::ResultAction::Debug ) CATCH_BREAK_INTO_DEBUGGER(); \ if( internal_catch_action & Catch::ResultAction::Abort ) throw Catch::TestFailureException(); \ if( !Catch::shouldContinueOnFailure( resultDisposition ) ) throw Catch::TestFailureException(); \ Catch::isTrue( false && originalExpr ); \ @@ -2936,8 +1627,88 @@ struct TestFailureException{}; } \ } while( Catch::isTrue( false ) ) -// #included from: internal/catch_section.hpp -#define TWOBLUECUBES_CATCH_SECTION_HPP_INCLUDED +// #included from: internal/catch_section.h +#define TWOBLUECUBES_CATCH_SECTION_H_INCLUDED + +// #included from: catch_section_info.h +#define TWOBLUECUBES_CATCH_SECTION_INFO_H_INCLUDED + +namespace Catch { + + struct SectionInfo { + SectionInfo( std::string const& _name, + std::string const& _description, + SourceLineInfo const& _lineInfo ) + : name( _name ), + description( _description ), + lineInfo( _lineInfo ) + {} + + std::string name; + std::string description; + SourceLineInfo lineInfo; + }; + +} // end namespace Catch + +// #included from: catch_totals.hpp +#define TWOBLUECUBES_CATCH_TOTALS_HPP_INCLUDED + +#include + +namespace Catch { + + struct Counts { + Counts() : passed( 0 ), failed( 0 ) {} + + Counts operator - ( Counts const& other ) const { + Counts diff; + diff.passed = passed - other.passed; + diff.failed = failed - other.failed; + return diff; + } + Counts& operator += ( Counts const& other ) { + passed += other.passed; + failed += other.failed; + return *this; + } + + std::size_t total() const { + return passed + failed; + } + + std::size_t passed; + std::size_t failed; + }; + + struct Totals { + + Totals operator - ( Totals const& other ) const { + Totals diff; + diff.assertions = assertions - other.assertions; + diff.testCases = testCases - other.testCases; + return diff; + } + + Totals delta( Totals const& prevTotals ) const { + Totals diff = *this - prevTotals; + if( diff.assertions.failed > 0 ) + ++diff.testCases.failed; + else + ++diff.testCases.passed; + return diff; + } + + Totals& operator += ( Totals const& other ) { + assertions += other.assertions; + testCases += other.testCases; + return *this; + } + + Counts assertions; + Counts testCases; + }; +} // #included from: catch_timer.h #define TWOBLUECUBES_CATCH_TIMER_H_INCLUDED @@ -2972,24 +1743,14 @@ namespace Catch { public: Section( SourceLineInfo const& lineInfo, std::string const& name, - std::string const& description = "" ) - : m_info( name, description, lineInfo ), - m_sectionIncluded( getCurrentContext().getResultCapture().sectionStarted( m_info, m_assertions ) ) - { - m_timer.start(); - } - - ~Section() { - if( m_sectionIncluded ) - getCurrentContext().getResultCapture().sectionEnded( m_info, m_assertions, m_timer.getElapsedSeconds() ); - } + std::string const& description = "" ); + ~Section(); // This indicates whether the section should be executed or not - operator bool() { - return m_sectionIncluded; - } + operator bool(); private: + SectionInfo m_info; std::string m_name; @@ -3553,10 +2314,79 @@ using namespace Matchers; // These files are included here so the single_include script doesn't put them // in the conditionally compiled sections -// #included from: internal/catch_interfaces_runner.h -#define TWOBLUECUBES_CATCH_INTERFACES_RUNNER_H_INCLUDED +// #included from: internal/catch_test_case_info.h +#define TWOBLUECUBES_CATCH_TEST_CASE_INFO_H_INCLUDED #include +#include + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wpadded" +#endif + +namespace Catch { + + struct ITestCase; + + struct TestCaseInfo { + TestCaseInfo( std::string const& _name, + std::string const& _className, + std::string const& _description, + std::set const& _tags, + bool _isHidden, + SourceLineInfo const& _lineInfo ); + + TestCaseInfo( TestCaseInfo const& other ); + + std::string name; + std::string className; + std::string description; + std::set tags; + std::string tagsAsString; + SourceLineInfo lineInfo; + bool isHidden; + }; + + class TestCase : protected TestCaseInfo { + public: + + TestCase( ITestCase* testCase, TestCaseInfo const& info ); + TestCase( TestCase const& other ); + + TestCase withName( std::string const& _newName ) const; + + void invoke() const; + + TestCaseInfo const& getTestCaseInfo() const; + + bool isHidden() const; + bool hasTag( std::string const& tag ) const; + bool matchesTags( std::string const& tagPattern ) const; + std::set const& getTags() const; + + void swap( TestCase& other ); + bool operator == ( TestCase const& other ) const; + bool operator < ( TestCase const& other ) const; + TestCase& operator = ( TestCase const& other ); + + private: + Ptr test; + }; + + TestCase makeTestCase( ITestCase* testCase, + std::string const& className, + std::string const& name, + std::string const& description, + SourceLineInfo const& lineInfo ); +} + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + +// #included from: internal/catch_interfaces_runner.h +#define TWOBLUECUBES_CATCH_INTERFACES_RUNNER_H_INCLUDED namespace Catch { class TestCase; @@ -3616,10 +2446,6 @@ namespace Catch { namespace Detail{ - inline bool startsWith( std::string const& str, std::string const& sub ) { - return str.length() > sub.length() && str.substr( 0, sub.length() ) == sub; - } - inline std::string getAnnotation( Class cls, std::string const& annotationName, std::string const& testCaseName ) { @@ -3648,7 +2474,7 @@ namespace Catch { for( u_int m = 0; m < count ; m++ ) { SEL selector = method_getName(methods[m]); std::string methodName = sel_getName(selector); - if( Detail::startsWith( methodName, "Catch_TestCase_" ) ) { + if( startsWith( methodName, "Catch_TestCase_" ) ) { std::string testCaseName = methodName.substr( 15 ); std::string name = Detail::getAnnotation( cls, "Name", testCaseName ); std::string desc = Detail::getAnnotation( cls, "Description", testCaseName ); @@ -3765,7 +2591,6 @@ return @ desc; \ #endif -#if defined( CATCH_CONFIG_MAIN ) || defined( CATCH_CONFIG_RUNNER ) // #included from: internal/catch_impl.hpp #define TWOBLUECUBES_CATCH_IMPL_HPP_INCLUDED @@ -3783,6 +2608,345 @@ return @ desc; \ // #included from: internal/catch_commandline.hpp #define TWOBLUECUBES_CATCH_COMMANDLINE_HPP_INCLUDED +// #included from: catch_config.hpp +#define TWOBLUECUBES_CATCH_CONFIG_HPP_INCLUDED + +// #included from: catch_test_spec.h +#define TWOBLUECUBES_CATCH_TEST_SPEC_H_INCLUDED + +// #included from: catch_tags.h +#define TWOBLUECUBES_CATCH_TAGS_H_INCLUDED + +#include +#include +#include +#include + +#ifdef __clang__ +#pragma clang diagnostic ignored "-Wpadded" +#endif + +namespace Catch { + class TagParser { + public: + virtual ~TagParser(); + + void parse( std::string const& str ); + + protected: + virtual void acceptTag( std::string const& tag ) = 0; + virtual void acceptChar( char c ) = 0; + virtual void endParse() {} + + private: + }; + + class TagExtracter : public TagParser { + public: + + TagExtracter( std::set& tags ); + virtual ~TagExtracter(); + + void parse( std::string& description ); + + private: + virtual void acceptTag( std::string const& tag ); + virtual void acceptChar( char c ); + + TagExtracter& operator=(TagExtracter const&); + + std::set& m_tags; + std::string m_remainder; + }; + + class Tag { + public: + Tag(); + Tag( std::string const& name, bool isNegated ); + std::string getName() const; + bool isNegated() const; + bool operator ! () const; + + private: + std::string m_name; + bool m_isNegated; + }; + + class TagSet { + typedef std::map TagMap; + public: + void add( Tag const& tag ); + bool empty() const; + bool matches( std::set const& tags ) const; + + private: + TagMap m_tags; + }; + + class TagExpression { + public: + bool matches( std::set const& tags ) const; + + private: + friend class TagExpressionParser; + + std::vector m_tagSets; + }; + + class TagExpressionParser : public TagParser { + public: + TagExpressionParser( TagExpression& exp ); + ~TagExpressionParser(); + + private: + virtual void acceptTag( std::string const& tag ); + virtual void acceptChar( char c ); + virtual void endParse(); + + TagExpressionParser& operator=(TagExpressionParser const&); + + bool m_isNegated; + TagSet m_currentTagSet; + TagExpression& m_exp; + }; + +} // end namespace Catch + +#include +#include + +namespace Catch { + + class TestCase; + + struct IfFilterMatches{ enum DoWhat { + AutoDetectBehaviour, + IncludeTests, + ExcludeTests + }; }; + + class TestCaseFilter { + enum WildcardPosition { + NoWildcard = 0, + WildcardAtStart = 1, + WildcardAtEnd = 2, + WildcardAtBothEnds = WildcardAtStart | WildcardAtEnd + }; + + public: + TestCaseFilter( std::string const& testSpec, IfFilterMatches::DoWhat matchBehaviour = IfFilterMatches::AutoDetectBehaviour ); + + IfFilterMatches::DoWhat getFilterType() const; + bool shouldInclude( TestCase const& testCase ) const; + + private: + bool isMatch( TestCase const& testCase ) const; + + std::string m_stringToMatch; + IfFilterMatches::DoWhat m_filterType; + WildcardPosition m_wildcardPosition; + }; + + class TestCaseFilters { + public: + TestCaseFilters( std::string const& name ); + std::string getName() const; + void addFilter( TestCaseFilter const& filter ); + void addTags( std::string const& tagPattern ); + bool shouldInclude( TestCase const& testCase ) const; + + private: + std::vector m_tagExpressions; + std::vector m_inclusionFilters; + std::vector m_exclusionFilters; + std::string m_name; + }; + +} + +// #included from: catch_stream.h +#define TWOBLUECUBES_CATCH_STREAM_H_INCLUDED + +#include + +#ifdef __clang__ +#pragma clang diagnostic ignored "-Wpadded" +#endif + +namespace Catch { + + class Stream { + public: + Stream(); + Stream( std::streambuf* _streamBuf, bool _isOwned ); + void release(); + + std::streambuf* streamBuf; + + private: + bool isOwned; + }; +} + +#include +#include +#include +#include + +#ifndef CATCH_CONFIG_CONSOLE_WIDTH +#define CATCH_CONFIG_CONSOLE_WIDTH 80 +#endif + +namespace Catch { + + struct ConfigData { + + ConfigData() + : listTests( false ), + listTags( false ), + listReporters( false ), + listTestNamesOnly( false ), + showSuccessfulTests( false ), + shouldDebugBreak( false ), + noThrow( false ), + showHelp( false ), + abortAfter( -1 ), + verbosity( Verbosity::Normal ), + warnings( WarnAbout::Nothing ), + showDurations( ShowDurations::DefaultForReporter ) + {} + + bool listTests; + bool listTags; + bool listReporters; + bool listTestNamesOnly; + + bool showSuccessfulTests; + bool shouldDebugBreak; + bool noThrow; + bool showHelp; + + int abortAfter; + + Verbosity::Level verbosity; + WarnAbout::What warnings; + ShowDurations::OrNot showDurations; + + std::string reporterName; + std::string outputFilename; + std::string name; + std::string processName; + + std::vector testsOrTags; + }; + + class Config : public SharedImpl { + private: + Config( Config const& other ); + Config& operator = ( Config const& other ); + virtual void dummy(); + public: + + Config() + : m_os( std::cout.rdbuf() ) + {} + + Config( ConfigData const& data ) + : m_data( data ), + m_os( std::cout.rdbuf() ) + { + if( !data.testsOrTags.empty() ) { + std::string groupName; + for( std::size_t i = 0; i < data.testsOrTags.size(); ++i ) { + if( i != 0 ) + groupName += " "; + groupName += data.testsOrTags[i]; + } + TestCaseFilters filters( groupName ); + for( std::size_t i = 0; i < data.testsOrTags.size(); ++i ) { + std::string filter = data.testsOrTags[i]; + if( startsWith( filter, "[" ) || startsWith( filter, "~[" ) ) + filters.addTags( filter ); + else + filters.addFilter( TestCaseFilter( filter ) ); + } + m_filterSets.push_back( filters ); + } + } + + virtual ~Config() { + m_os.rdbuf( std::cout.rdbuf() ); + m_stream.release(); + } + + void setFilename( std::string const& filename ) { + m_data.outputFilename = filename; + } + + std::string const& getFilename() const { + return m_data.outputFilename ; + } + + bool listTests() const { return m_data.listTests; } + bool listTestNamesOnly() const { return m_data.listTestNamesOnly; } + bool listTags() const { return m_data.listTags; } + bool listReporters() const { return m_data.listReporters; } + + std::string getProcessName() const { + return m_data.processName; + } + + bool shouldDebugBreak() const { + return m_data.shouldDebugBreak; + } + + void setStreamBuf( std::streambuf* buf ) { + m_os.rdbuf( buf ? buf : std::cout.rdbuf() ); + } + + void useStream( std::string const& streamName ) { + Stream stream = createStream( streamName ); + setStreamBuf( stream.streamBuf ); + m_stream.release(); + m_stream = stream; + } + + std::string getReporterName() const { return m_data.reporterName; } + + void addTestSpec( std::string const& testSpec ) { + TestCaseFilters filters( testSpec ); + filters.addFilter( TestCaseFilter( testSpec ) ); + m_filterSets.push_back( filters ); + } + + int abortAfter() const { + return m_data.abortAfter; + } + + std::vector const& filters() const { + return m_filterSets; + } + + bool showHelp() const { return m_data.showHelp; } + + // IConfig interface + virtual bool allowThrows() const { return !m_data.noThrow; } + virtual std::ostream& stream() const { return m_os; } + virtual std::string name() const { return m_data.name.empty() ? m_data.processName : m_data.name; } + virtual bool includeSuccessfulResults() const { return m_data.showSuccessfulTests; } + virtual bool warnAboutMissingAssertions() const { return m_data.warnings & WarnAbout::NoAssertions; } + virtual ShowDurations::OrNot showDurations() const { return m_data.showDurations; } + + private: + ConfigData m_data; + + Stream m_stream; + mutable std::ostream m_os; + std::vector m_filterSets; + }; + +} // end namespace Catch + // #included from: clara.h #define TWOBLUECUBES_CLARA_H_INCLUDED @@ -4591,6 +3755,279 @@ namespace Catch { } // end namespace Catch +// #included from: catch_interfaces_reporter.h +#define TWOBLUECUBES_CATCH_INTERFACES_REPORTER_H_INCLUDED + +// #included from: catch_option.hpp +#define TWOBLUECUBES_CATCH_OPTION_HPP_INCLUDED + +namespace Catch { + + // An optional type + template + class Option { + public: + Option() : nullableValue( NULL ) {} + Option( T const& _value ) + : nullableValue( new( storage ) T( _value ) ) + {} + Option( Option const& _other ) + : nullableValue( _other ? new( storage ) T( *_other ) : NULL ) + {} + + ~Option() { + reset(); + } + + Option& operator= ( Option const& _other ) { + reset(); + if( _other ) + nullableValue = new( storage ) T( *_other ); + return *this; + } + Option& operator = ( T const& _value ) { + reset(); + nullableValue = new( storage ) T( _value ); + return *this; + } + + void reset() { + if( nullableValue ) + nullableValue->~T(); + nullableValue = NULL; + } + + T& operator*() { return *nullableValue; } + T const& operator*() const { return *nullableValue; } + T* operator->() { return nullableValue; } + const T* operator->() const { return nullableValue; } + + T valueOr( T const& defaultValue ) const { + return nullableValue ? *nullableValue : defaultValue; + } + + bool some() const { return nullableValue != NULL; } + bool none() const { return nullableValue == NULL; } + + bool operator !() const { return nullableValue == NULL; } + operator SafeBool::type() const { + return SafeBool::makeSafe( some() ); + } + + private: + T* nullableValue; + char storage[sizeof(T)]; + }; + +} // end namespace Catch + +#include +#include +#include +#include + +namespace Catch +{ + struct ReporterConfig { + explicit ReporterConfig( Ptr const& _fullConfig ) + : m_stream( &_fullConfig->stream() ), m_fullConfig( _fullConfig ) {} + + ReporterConfig( Ptr const& _fullConfig, std::ostream& _stream ) + : m_stream( &_stream ), m_fullConfig( _fullConfig ) {} + + std::ostream& stream() const { return *m_stream; } + Ptr fullConfig() const { return m_fullConfig; } + + private: + std::ostream* m_stream; + Ptr m_fullConfig; + }; + + struct ReporterPreferences { + ReporterPreferences() + : shouldRedirectStdOut( false ) + {} + + bool shouldRedirectStdOut; + }; + + template + struct LazyStat : Option { + LazyStat() : used( false ) {} + LazyStat& operator=( T const& _value ) { + Option::operator=( _value ); + used = false; + return *this; + } + void reset() { + Option::reset(); + used = false; + } + bool used; + }; + + struct TestRunInfo { + TestRunInfo( std::string const& _name ) : name( _name ) {} + std::string name; + }; + struct GroupInfo { + GroupInfo( std::string const& _name, + std::size_t _groupIndex, + std::size_t _groupsCount ) + : name( _name ), + groupIndex( _groupIndex ), + groupsCounts( _groupsCount ) + {} + + std::string name; + std::size_t groupIndex; + std::size_t groupsCounts; + }; + + struct AssertionStats { + AssertionStats( AssertionResult const& _assertionResult, + std::vector const& _infoMessages, + Totals const& _totals ) + : assertionResult( _assertionResult ), + infoMessages( _infoMessages ), + totals( _totals ) + { + if( assertionResult.hasMessage() ) { + // Copy message into messages list. + // !TBD This should have been done earlier, somewhere + MessageBuilder builder( assertionResult.getTestMacroName(), assertionResult.getSourceInfo(), assertionResult.getResultType() ); + builder << assertionResult.getMessage(); + builder.m_info.message = builder.m_stream.str(); + + infoMessages.push_back( builder.m_info ); + } + } + virtual ~AssertionStats(); + + AssertionResult assertionResult; + std::vector infoMessages; + Totals totals; + }; + + struct SectionStats { + SectionStats( SectionInfo const& _sectionInfo, + Counts const& _assertions, + double _durationInSeconds, + bool _missingAssertions ) + : sectionInfo( _sectionInfo ), + assertions( _assertions ), + durationInSeconds( _durationInSeconds ), + missingAssertions( _missingAssertions ) + {} + virtual ~SectionStats(); + + SectionInfo sectionInfo; + Counts assertions; + double durationInSeconds; + bool missingAssertions; + }; + + struct TestCaseStats { + TestCaseStats( TestCaseInfo const& _testInfo, + Totals const& _totals, + std::string const& _stdOut, + std::string const& _stdErr, + bool _aborting ) + : testInfo( _testInfo ), + totals( _totals ), + stdOut( _stdOut ), + stdErr( _stdErr ), + aborting( _aborting ) + {} + virtual ~TestCaseStats(); + + TestCaseInfo testInfo; + Totals totals; + std::string stdOut; + std::string stdErr; + bool aborting; + }; + + struct TestGroupStats { + TestGroupStats( GroupInfo const& _groupInfo, + Totals const& _totals, + bool _aborting ) + : groupInfo( _groupInfo ), + totals( _totals ), + aborting( _aborting ) + {} + TestGroupStats( GroupInfo const& _groupInfo ) + : groupInfo( _groupInfo ), + aborting( false ) + {} + virtual ~TestGroupStats(); + + GroupInfo groupInfo; + Totals totals; + bool aborting; + }; + + struct TestRunStats { + TestRunStats( TestRunInfo const& _runInfo, + Totals const& _totals, + bool _aborting ) + : runInfo( _runInfo ), + totals( _totals ), + aborting( _aborting ) + {} + TestRunStats( TestRunStats const& _other ) + : runInfo( _other.runInfo ), + totals( _other.totals ), + aborting( _other.aborting ) + {} + virtual ~TestRunStats(); + + TestRunInfo runInfo; + Totals totals; + bool aborting; + }; + + struct IStreamingReporter : IShared { + virtual ~IStreamingReporter(); + + // Implementing class must also provide the following static method: + // static std::string getDescription(); + + virtual ReporterPreferences getPreferences() const = 0; + + virtual void noMatchingTestCases( std::string const& spec ) = 0; + + virtual void testRunStarting( TestRunInfo const& testRunInfo ) = 0; + virtual void testGroupStarting( GroupInfo const& groupInfo ) = 0; + + virtual void testCaseStarting( TestCaseInfo const& testInfo ) = 0; + virtual void sectionStarting( SectionInfo const& sectionInfo ) = 0; + + virtual void assertionStarting( AssertionInfo const& assertionInfo ) = 0; + + virtual bool assertionEnded( AssertionStats const& assertionStats ) = 0; + virtual void sectionEnded( SectionStats const& sectionStats ) = 0; + virtual void testCaseEnded( TestCaseStats const& testCaseStats ) = 0; + virtual void testGroupEnded( TestGroupStats const& testGroupStats ) = 0; + virtual void testRunEnded( TestRunStats const& testRunStats ) = 0; + }; + + struct IReporterFactory { + virtual ~IReporterFactory(); + virtual IStreamingReporter* create( ReporterConfig const& config ) const = 0; + virtual std::string getDescription() const = 0; + }; + + struct IReporterRegistry { + typedef std::map FactoryMap; + + virtual ~IReporterRegistry(); + virtual IStreamingReporter* create( std::string const& name, Ptr const& config ) const = 0; + virtual FactoryMap const& getFactories() const = 0; + }; + +} + #include #include @@ -5767,6 +5204,89 @@ namespace Catch { // #included from: catch_context_impl.hpp #define TWOBLUECUBES_CATCH_CONTEXT_IMPL_HPP_INCLUDED +// #included from: catch_stream.hpp +#define TWOBLUECUBES_CATCH_STREAM_HPP_INCLUDED + +// #included from: catch_streambuf.h +#define TWOBLUECUBES_CATCH_STREAMBUF_H_INCLUDED + +#include + +namespace Catch { + + class StreamBufBase : public std::streambuf { + public: + virtual ~StreamBufBase() throw(); + }; +} + +#include +#include + +namespace Catch { + + template + class StreamBufImpl : public StreamBufBase { + char data[bufferSize]; + WriterF m_writer; + + public: + StreamBufImpl() { + setp( data, data + sizeof(data) ); + } + + ~StreamBufImpl() throw() { + sync(); + } + + private: + int overflow( int c ) { + sync(); + + if( c != EOF ) { + if( pbase() == epptr() ) + m_writer( std::string( 1, static_cast( c ) ) ); + else + sputc( static_cast( c ) ); + } + return 0; + } + + int sync() { + if( pbase() != pptr() ) { + m_writer( std::string( pbase(), static_cast( pptr() - pbase() ) ) ); + setp( pbase(), epptr() ); + } + return 0; + } + }; + + /////////////////////////////////////////////////////////////////////////// + + struct OutputDebugWriter { + + void operator()( std::string const&str ) { + writeToDebugConsole( str ); + } + }; + + Stream::Stream() + : streamBuf( NULL ), isOwned( false ) + {} + + Stream::Stream( std::streambuf* _streamBuf, bool _isOwned ) + : streamBuf( _streamBuf ), isOwned( _isOwned ) + {} + + void Stream::release() { + if( isOwned ) { + delete streamBuf; + streamBuf = NULL; + isOwned = false; + } + } +} + namespace Catch { class Context : public IMutableContext { @@ -5973,7 +5493,7 @@ namespace { }; inline bool shouldUseColourForPlatform() { - return isatty( fileno(stdout) ); + return isatty(STDOUT_FILENO); } PosixColourImpl platformColourImpl; @@ -6362,13 +5882,259 @@ namespace Catch { } // end namespace Catch +// #included from: catch_tags.hpp +#define TWOBLUECUBES_CATCH_TAGS_HPP_INCLUDED + +namespace Catch { + TagParser::~TagParser() {} + + void TagParser::parse( std::string const& str ) { + std::size_t pos = 0; + while( pos < str.size() ) { + char c = str[pos]; + if( c == '[' ) { + std::size_t end = str.find_first_of( ']', pos ); + if( end != std::string::npos ) { + acceptTag( str.substr( pos+1, end-pos-1 ) ); + pos = end+1; + } + else { + acceptChar( c ); + pos++; + } + } + else { + acceptChar( c ); + pos++; + } + } + endParse(); + } + + TagExtracter::TagExtracter( std::set& tags ) + : m_tags( tags ) + {} + + TagExtracter::~TagExtracter() {} + + void TagExtracter::parse( std::string& description ) { + TagParser::parse( description ); + description = m_remainder; + } + + void TagExtracter::acceptTag( std::string const& tag ) { + m_tags.insert( toLower( tag ) ); + } + void TagExtracter::acceptChar( char c ) { + m_remainder += c; + } + + Tag::Tag() : m_isNegated( false ) {} + Tag::Tag( std::string const& name, bool isNegated ) + : m_name( name ), + m_isNegated( isNegated ) + {} + + std::string Tag::getName() const { + return m_name; + } + bool Tag::isNegated() const { + return m_isNegated; + } + + bool Tag::operator ! () const { + return m_name.empty(); + } + + void TagSet::add( Tag const& tag ) { + m_tags.insert( std::make_pair( toLower( tag.getName() ), tag ) ); + } + + bool TagSet::empty() const { + return m_tags.empty(); + } + + bool TagSet::matches( std::set const& tags ) const { + for( TagMap::const_iterator + it = m_tags.begin(), itEnd = m_tags.end(); + it != itEnd; + ++it ) { + bool found = tags.find( it->first ) != tags.end(); + if( found == it->second.isNegated() ) + return false; + } + return true; + } + + bool TagExpression::matches( std::set const& tags ) const { + for( std::vector::const_iterator + it = m_tagSets.begin(), itEnd = m_tagSets.end(); + it != itEnd; + ++it ) + if( it->matches( tags ) ) + return true; + return false; + } + + TagExpressionParser::TagExpressionParser( TagExpression& exp ) + : m_isNegated( false ), + m_exp( exp ) + {} + + TagExpressionParser::~TagExpressionParser() {} + + void TagExpressionParser::acceptTag( std::string const& tag ) { + m_currentTagSet.add( Tag( tag, m_isNegated ) ); + m_isNegated = false; + } + + void TagExpressionParser::acceptChar( char c ) { + switch( c ) { + case '~': + m_isNegated = true; + break; + case ',': + m_exp.m_tagSets.push_back( m_currentTagSet ); + m_currentTagSet = TagSet(); + break; + } + } + + void TagExpressionParser::endParse() { + if( !m_currentTagSet.empty() ) + m_exp.m_tagSets.push_back( m_currentTagSet ); + } + +} // end namespace Catch + +// #included from: catch_test_spec.hpp +#define TWOBLUECUBES_CATCH_TEST_SPEC_HPP_INCLUDED + +namespace Catch { + + TestCaseFilter::TestCaseFilter( std::string const& testSpec, IfFilterMatches::DoWhat matchBehaviour ) + : m_stringToMatch( toLower( testSpec ) ), + m_filterType( matchBehaviour ), + m_wildcardPosition( NoWildcard ) + { + if( m_filterType == IfFilterMatches::AutoDetectBehaviour ) { + if( startsWith( m_stringToMatch, "exclude:" ) ) { + m_stringToMatch = m_stringToMatch.substr( 8 ); + m_filterType = IfFilterMatches::ExcludeTests; + } + else if( startsWith( m_stringToMatch, "~" ) ) { + m_stringToMatch = m_stringToMatch.substr( 1 ); + m_filterType = IfFilterMatches::ExcludeTests; + } + else { + m_filterType = IfFilterMatches::IncludeTests; + } + } + + if( startsWith( m_stringToMatch, "*" ) ) { + m_stringToMatch = m_stringToMatch.substr( 1 ); + m_wildcardPosition = (WildcardPosition)( m_wildcardPosition | WildcardAtStart ); + } + if( endsWith( m_stringToMatch, "*" ) ) { + m_stringToMatch = m_stringToMatch.substr( 0, m_stringToMatch.size()-1 ); + m_wildcardPosition = (WildcardPosition)( m_wildcardPosition | WildcardAtEnd ); + } + } + + IfFilterMatches::DoWhat TestCaseFilter::getFilterType() const { + return m_filterType; + } + + bool TestCaseFilter::shouldInclude( TestCase const& testCase ) const { + return isMatch( testCase ) == (m_filterType == IfFilterMatches::IncludeTests); + } + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunreachable-code" +#endif + + bool TestCaseFilter::isMatch( TestCase const& testCase ) const { + std::string name = testCase.getTestCaseInfo().name; + toLowerInPlace( name ); + + switch( m_wildcardPosition ) { + case NoWildcard: + return m_stringToMatch == name; + case WildcardAtStart: + return endsWith( name, m_stringToMatch ); + case WildcardAtEnd: + return startsWith( name, m_stringToMatch ); + case WildcardAtBothEnds: + return contains( name, m_stringToMatch ); + } + throw std::logic_error( "Unhandled wildcard type" ); + } + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + + TestCaseFilters::TestCaseFilters( std::string const& name ) : m_name( name ) {} + + std::string TestCaseFilters::getName() const { + return m_name; + } + + void TestCaseFilters::addFilter( TestCaseFilter const& filter ) { + if( filter.getFilterType() == IfFilterMatches::ExcludeTests ) + m_exclusionFilters.push_back( filter ); + else + m_inclusionFilters.push_back( filter ); + } + + void TestCaseFilters::addTags( std::string const& tagPattern ) { + TagExpression exp; + TagExpressionParser( exp ).parse( tagPattern ); + + m_tagExpressions.push_back( exp ); + } + + bool TestCaseFilters::shouldInclude( TestCase const& testCase ) const { + if( !m_tagExpressions.empty() ) { + std::vector::const_iterator it = m_tagExpressions.begin(); + std::vector::const_iterator itEnd = m_tagExpressions.end(); + for(; it != itEnd; ++it ) + if( it->matches( testCase.getTags() ) ) + break; + if( it == itEnd ) + return false; + } + + if( !m_inclusionFilters.empty() ) { + std::vector::const_iterator it = m_inclusionFilters.begin(); + std::vector::const_iterator itEnd = m_inclusionFilters.end(); + for(; it != itEnd; ++it ) + if( it->shouldInclude( testCase ) ) + break; + if( it == itEnd ) + return false; + } + else if( m_exclusionFilters.empty() && m_tagExpressions.empty() ) { + return !testCase.isHidden(); + } + + std::vector::const_iterator it = m_exclusionFilters.begin(); + std::vector::const_iterator itEnd = m_exclusionFilters.end(); + for(; it != itEnd; ++it ) + if( !it->shouldInclude( testCase ) ) + return false; + return true; + } +} + // #included from: catch_version.hpp #define TWOBLUECUBES_CATCH_VERSION_HPP_INCLUDED namespace Catch { // These numbers are maintained by a script - Version libraryVersion( 1, 0, 14, "master" ); + Version libraryVersion( 1, 0, 15, "master" ); } // #included from: catch_text.hpp @@ -6497,6 +6263,26 @@ namespace Catch { namespace Catch { + // Deprecated + struct IReporter : IShared { + virtual ~IReporter(); + + virtual bool shouldRedirectStdout() const = 0; + + virtual void StartTesting() = 0; + virtual void EndTesting( Totals const& totals ) = 0; + virtual void StartGroup( std::string const& groupName ) = 0; + virtual void EndGroup( std::string const& groupName, Totals const& totals ) = 0; + virtual void StartTestCase( TestCaseInfo const& testInfo ) = 0; + virtual void EndTestCase( TestCaseInfo const& testInfo, Totals const& totals, std::string const& stdOut, std::string const& stdErr ) = 0; + virtual void StartSection( std::string const& sectionName, std::string const& description ) = 0; + virtual void EndSection( std::string const& sectionName, Counts const& assertions ) = 0; + virtual void NoAssertionsInSection( std::string const& sectionName ) = 0; + virtual void NoAssertionsInTestCase( std::string const& testName ) = 0; + virtual void Aborted() = 0; + virtual void Result( AssertionResult const& result ) = 0; + }; + class LegacyReporterAdapter : public SharedImpl { public: @@ -6644,9 +6430,380 @@ namespace Catch { #ifdef __clang__ #pragma clang diagnostic pop #endif +// #included from: catch_common.hpp +#define TWOBLUECUBES_CATCH_COMMON_HPP_INCLUDED + +namespace Catch { + + bool startsWith( std::string const& s, std::string const& prefix ) { + return s.size() >= prefix.size() && s.substr( 0, prefix.size() ) == prefix; + } + bool endsWith( std::string const& s, std::string const& suffix ) { + return s.size() >= suffix.size() && s.substr( s.size()-suffix.size(), suffix.size() ) == suffix; + } + bool contains( std::string const& s, std::string const& infix ) { + return s.find( infix ) != std::string::npos; + } + void toLowerInPlace( std::string& s ) { + std::transform( s.begin(), s.end(), s.begin(), ::tolower ); + } + std::string toLower( std::string const& s ) { + std::string lc = s; + toLowerInPlace( lc ); + return lc; + } + std::string trim( std::string const& str ) { + static char const* whitespaceChars = "\n\r\t "; + std::string::size_type start = str.find_first_not_of( whitespaceChars ); + std::string::size_type end = str.find_last_not_of( whitespaceChars ); + + return start != std::string::npos ? str.substr( start, 1+end-start ) : ""; + } + + pluralise::pluralise( std::size_t count, std::string const& label ) + : m_count( count ), + m_label( label ) + {} + + std::ostream& operator << ( std::ostream& os, pluralise const& pluraliser ) { + os << pluraliser.m_count << " " << pluraliser.m_label; + if( pluraliser.m_count != 1 ) + os << "s"; + return os; + } + + SourceLineInfo::SourceLineInfo() : line( 0 ){} + SourceLineInfo::SourceLineInfo( std::string const& _file, std::size_t _line ) + : file( _file ), + line( _line ) + {} + SourceLineInfo::SourceLineInfo( SourceLineInfo const& other ) + : file( other.file ), + line( other.line ) + {} + bool SourceLineInfo::empty() const { + return file.empty(); + } + bool SourceLineInfo::operator == ( SourceLineInfo const& other ) const { + return line == other.line && file == other.file; + } + + std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info ) { +#ifndef __GNUG__ + os << info.file << "(" << info.line << ")"; +#else + os << info.file << ":" << info.line; +#endif + return os; + } + + void throwLogicError( std::string const& message, SourceLineInfo const& locationInfo ) { + std::ostringstream oss; + oss << locationInfo << ": Internal Catch error: '" << message << "'"; + if( isTrue( true )) + throw std::logic_error( oss.str() ); + } +} + +// #included from: catch_section.hpp +#define TWOBLUECUBES_CATCH_SECTION_HPP_INCLUDED + +namespace Catch { + + Section::Section( SourceLineInfo const& lineInfo, + std::string const& name, + std::string const& description ) + : m_info( name, description, lineInfo ), + m_sectionIncluded( getCurrentContext().getResultCapture().sectionStarted( m_info, m_assertions ) ) + { + m_timer.start(); + } + + Section::~Section() { + if( m_sectionIncluded ) + getCurrentContext().getResultCapture().sectionEnded( m_info, m_assertions, m_timer.getElapsedSeconds() ); + } + + // This indicates whether the section should be executed or not + Section::operator bool() { + return m_sectionIncluded; + } + +} // end namespace Catch + +// #included from: catch_debugger.hpp +#define TWOBLUECUBES_CATCH_DEBUGGER_HPP_INCLUDED + +#include + +#ifdef CATCH_PLATFORM_MAC + + #include + #include + #include + #include + #include + + namespace Catch{ + + // The following function is taken directly from the following technical note: + // http://developer.apple.com/library/mac/#qa/qa2004/qa1361.html + + // Returns true if the current process is being debugged (either + // running under the debugger or has a debugger attached post facto). + bool isDebuggerActive(){ + + int junk; + int mib[4]; + struct kinfo_proc info; + size_t size; + + // Initialize the flags so that, if sysctl fails for some bizarre + // reason, we get a predictable result. + + info.kp_proc.p_flag = 0; + + // Initialize mib, which tells sysctl the info we want, in this case + // we're looking for information about a specific process ID. + + mib[0] = CTL_KERN; + mib[1] = KERN_PROC; + mib[2] = KERN_PROC_PID; + mib[3] = getpid(); + + // Call sysctl. + + size = sizeof(info); + junk = sysctl(mib, sizeof(mib) / sizeof(*mib), &info, &size, NULL, 0); + assert(junk == 0); + + // We're being debugged if the P_TRACED flag is set. + + return ( (info.kp_proc.p_flag & P_TRACED) != 0 ); + } + } // namespace Catch + +#elif defined(_MSC_VER) + extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent(); + namespace Catch { + bool isDebuggerActive() { + return IsDebuggerPresent() != 0; + } + } +#elif defined(__MINGW32__) + extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent(); + namespace Catch { + bool isDebuggerActive() { + return IsDebuggerPresent() != 0; + } + } +#else + namespace Catch { + inline bool isDebuggerActive() { return false; } + } +#endif // Platform + +#ifdef CATCH_PLATFORM_WINDOWS + extern "C" __declspec(dllimport) void __stdcall OutputDebugStringA( const char* ); + namespace Catch { + void writeToDebugConsole( std::string const& text ) { + ::OutputDebugStringA( text.c_str() ); + } + } +#else + namespace Catch { + void writeToDebugConsole( std::string const& text ) { + // !TBD: Need a version for Mac/ XCode and other IDEs + std::cout << text; + } + } +#endif // Platform + // #included from: ../reporters/catch_reporter_xml.hpp #define TWOBLUECUBES_CATCH_REPORTER_XML_HPP_INCLUDED +// #included from: catch_reporter_bases.hpp +#define TWOBLUECUBES_CATCH_REPORTER_BASES_HPP_INCLUDED + +namespace Catch { + + struct StreamingReporterBase : SharedImpl { + + StreamingReporterBase( ReporterConfig const& _config ) + : m_config( _config.fullConfig() ), + stream( _config.stream() ) + {} + + virtual ~StreamingReporterBase(); + + virtual void noMatchingTestCases( std::string const& ) {} + + virtual void testRunStarting( TestRunInfo const& _testRunInfo ) { + currentTestRunInfo = _testRunInfo; + } + virtual void testGroupStarting( GroupInfo const& _groupInfo ) { + currentGroupInfo = _groupInfo; + } + + virtual void testCaseStarting( TestCaseInfo const& _testInfo ) { + currentTestCaseInfo = _testInfo; + } + virtual void sectionStarting( SectionInfo const& _sectionInfo ) { + m_sectionStack.push_back( _sectionInfo ); + } + + virtual void sectionEnded( SectionStats const& /* _sectionStats */ ) { + m_sectionStack.pop_back(); + } + virtual void testCaseEnded( TestCaseStats const& /* _testCaseStats */ ) { + currentTestCaseInfo.reset(); + assert( m_sectionStack.empty() ); + } + virtual void testGroupEnded( TestGroupStats const& /* _testGroupStats */ ) { + currentGroupInfo.reset(); + } + virtual void testRunEnded( TestRunStats const& /* _testRunStats */ ) { + currentTestCaseInfo.reset(); + currentGroupInfo.reset(); + currentTestRunInfo.reset(); + } + + Ptr m_config; + std::ostream& stream; + + LazyStat currentTestRunInfo; + LazyStat currentGroupInfo; + LazyStat currentTestCaseInfo; + + std::vector m_sectionStack; + }; + + struct CumulativeReporterBase : SharedImpl { + template + struct Node : SharedImpl<> { + explicit Node( T const& _value ) : value( _value ) {} + virtual ~Node() {} + + typedef std::vector > ChildNodes; + T value; + ChildNodes children; + }; + struct SectionNode : SharedImpl<> { + explicit SectionNode( SectionStats const& _stats ) : stats( _stats ) {} + virtual ~SectionNode(); + + bool operator == ( SectionNode const& other ) const { + return stats.sectionInfo.lineInfo == other.stats.sectionInfo.lineInfo; + } + bool operator == ( Ptr const& other ) const { + return operator==( *other ); + } + + SectionStats stats; + typedef std::vector > ChildSections; + typedef std::vector Assertions; + ChildSections childSections; + Assertions assertions; + std::string stdOut; + std::string stdErr; + }; + friend bool operator == ( Ptr const& node, SectionInfo const& other ) { + return node->stats.sectionInfo.lineInfo == other.lineInfo; + } + + typedef Node TestCaseNode; + typedef Node TestGroupNode; + typedef Node TestRunNode; + + CumulativeReporterBase( ReporterConfig const& _config ) + : m_config( _config.fullConfig() ), + stream( _config.stream() ) + {} + ~CumulativeReporterBase(); + + virtual void testRunStarting( TestRunInfo const& ) {} + virtual void testGroupStarting( GroupInfo const& ) {} + + virtual void testCaseStarting( TestCaseInfo const& ) {} + + virtual void sectionStarting( SectionInfo const& sectionInfo ) { + SectionStats incompleteStats( sectionInfo, Counts(), 0, false ); + Ptr node; + if( m_sectionStack.empty() ) { + if( !m_rootSection ) + m_rootSection = new SectionNode( incompleteStats ); + node = m_rootSection; + } + else { + SectionNode& parentNode = *m_sectionStack.back(); + SectionNode::ChildSections::const_iterator it = + std::find( parentNode.childSections.begin(), parentNode.childSections.end(), sectionInfo ); + if( it == parentNode.childSections.end() ) { + node = new SectionNode( incompleteStats ); + parentNode.childSections.push_back( node ); + } + else + node = *it; + } + m_sectionStack.push_back( node ); + m_deepestSection = node; + } + + virtual void assertionStarting( AssertionInfo const& ) {} + + virtual bool assertionEnded( AssertionStats const& assertionStats ) { + assert( !m_sectionStack.empty() ); + SectionNode& sectionNode = *m_sectionStack.back(); + sectionNode.assertions.push_back( assertionStats ); + return true; + } + virtual void sectionEnded( SectionStats const& sectionStats ) { + assert( !m_sectionStack.empty() ); + SectionNode& node = *m_sectionStack.back(); + node.stats = sectionStats; + m_sectionStack.pop_back(); + } + virtual void testCaseEnded( TestCaseStats const& testCaseStats ) { + Ptr node = new TestCaseNode( testCaseStats ); + assert( m_sectionStack.size() == 0 ); + node->children.push_back( m_rootSection ); + m_testCases.push_back( node ); + m_rootSection.reset(); + + assert( m_deepestSection ); + m_deepestSection->stdOut = testCaseStats.stdOut; + m_deepestSection->stdErr = testCaseStats.stdErr; + } + virtual void testGroupEnded( TestGroupStats const& testGroupStats ) { + Ptr node = new TestGroupNode( testGroupStats ); + node->children.swap( m_testCases ); + m_testGroups.push_back( node ); + } + virtual void testRunEnded( TestRunStats const& testRunStats ) { + Ptr node = new TestRunNode( testRunStats ); + node->children.swap( m_testGroups ); + m_testRuns.push_back( node ); + testRunEnded(); + } + virtual void testRunEnded() = 0; + + Ptr m_config; + std::ostream& stream; + std::vector m_assertions; + std::vector > > m_sections; + std::vector > m_testCases; + std::vector > m_testGroups; + + std::vector > m_testRuns; + + Ptr m_rootSection; + Ptr m_deepestSection; + std::vector > m_sectionStack; + + }; + +} // end namespace Catch + // #included from: ../internal/catch_reporter_registrars.hpp #define TWOBLUECUBES_CATCH_REPORTER_REGISTRARS_HPP_INCLUDED @@ -7692,9 +7849,6 @@ namespace Catch { FreeFunctionTestCase::~FreeFunctionTestCase() {} IGeneratorInfo::~IGeneratorInfo() {} IGeneratorsForTest::~IGeneratorsForTest() {} - TagParser::~TagParser() {} - TagExtracter::~TagExtracter() {} - TagExpressionParser::~TagExpressionParser() {} Matchers::Impl::StdString::Equals::~Equals() {} Matchers::Impl::StdString::Contains::~Contains() {} @@ -7710,9 +7864,8 @@ namespace Catch { #pragma clang diagnostic pop #endif -#endif +#endif // CATCH_CONFIG_MAIN || CATCH_CONFIG_RUNNER -#ifdef CATCH_CONFIG_MAIN // #included from: internal/catch_default_main.hpp #define TWOBLUECUBES_CATCH_DEFAULT_MAIN_HPP_INCLUDED @@ -7743,7 +7896,7 @@ int main (int argc, char * const argv[]) { #endif // __OBJC__ -#endif +#endif // CATCH_CONFIG_MAIN ////// From 352432129500c1ba9ef810128c8b555a870a8b8b Mon Sep 17 00:00:00 2001 From: Phil Nash Date: Wed, 4 Dec 2013 07:58:21 +0000 Subject: [PATCH 12/15] Removed some cruft --- projects/SelfTest/MiscTests.cpp | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/projects/SelfTest/MiscTests.cpp b/projects/SelfTest/MiscTests.cpp index cb93eb55..33e84bc2 100644 --- a/projects/SelfTest/MiscTests.cpp +++ b/projects/SelfTest/MiscTests.cpp @@ -333,26 +333,3 @@ TEST_CASE("A couple of nested sections followed by a failure", "[failing][.]") FAIL("to infinity and beyond"); } - - -//#include "internal/catch_timer.h" -// -//TEST_CASE( "Timer", "[work-in-progress]" ) -//{ -// Catch::Timer t; -// t.start(); -// -// std::cout << "starting..." << std::endl; -// -// double d = 0; -// for( int i = 0; i < 100000; ++i ) -// for( int j = 0; j < 1000; ++j ) -// d += (double)i*(double)j; -// -// double duration = t.getElapsedSeconds(); -// -// std::cout << "finished in " << duration << std::endl; -// -// SUCCEED("yay"); -// -//} From 47a5ad3038bd9b056d862a4e75699d25904e6811 Mon Sep 17 00:00:00 2001 From: Phil Nash Date: Wed, 4 Dec 2013 07:58:39 +0000 Subject: [PATCH 13/15] =?UTF-8?q?Normalised=20=E2=80=9Chidden=E2=80=9D=20t?= =?UTF-8?q?ags?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/internal/catch_test_case_info.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/internal/catch_test_case_info.hpp b/include/internal/catch_test_case_info.hpp index 3d46320f..75cd9323 100644 --- a/include/internal/catch_test_case_info.hpp +++ b/include/internal/catch_test_case_info.hpp @@ -28,6 +28,10 @@ namespace Catch { if( tags.find( "hide" ) != tags.end() || tags.find( "." ) != tags.end() ) isHidden = true; + if( isHidden ) { + tags.insert( "hide" ); + tags.insert( "." ); + } TestCaseInfo info( _name, _className, desc, tags, isHidden, _lineInfo ); return TestCase( _testCase, info ); } From 87b20e8dab8421c2d85ce72e7ac270267090cd56 Mon Sep 17 00:00:00 2001 From: Phil Nash Date: Wed, 4 Dec 2013 08:12:30 +0000 Subject: [PATCH 14/15] SourceLineInfo takes char*s instead of std::strings --- include/internal/catch_common.h | 2 +- include/internal/catch_common.hpp | 2 +- .../CatchSelfTest/CatchSelfTest.xcodeproj/project.pbxproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/internal/catch_common.h b/include/internal/catch_common.h index 650e1fbe..957ce257 100644 --- a/include/internal/catch_common.h +++ b/include/internal/catch_common.h @@ -86,7 +86,7 @@ namespace Catch { struct SourceLineInfo { SourceLineInfo(); - SourceLineInfo( std::string const& _file, std::size_t _line ); + SourceLineInfo( char const* _file, std::size_t _line ); SourceLineInfo( SourceLineInfo const& other ); bool empty() const; bool operator == ( SourceLineInfo const& other ) const; diff --git a/include/internal/catch_common.hpp b/include/internal/catch_common.hpp index 4fbf1ffc..89ffeab0 100644 --- a/include/internal/catch_common.hpp +++ b/include/internal/catch_common.hpp @@ -50,7 +50,7 @@ namespace Catch { } SourceLineInfo::SourceLineInfo() : line( 0 ){} - SourceLineInfo::SourceLineInfo( std::string const& _file, std::size_t _line ) + SourceLineInfo::SourceLineInfo( char const* _file, std::size_t _line ) : file( _file ), line( _line ) {} diff --git a/projects/XCode4/CatchSelfTest/CatchSelfTest.xcodeproj/project.pbxproj b/projects/XCode4/CatchSelfTest/CatchSelfTest.xcodeproj/project.pbxproj index c6a13fb8..e8848237 100644 --- a/projects/XCode4/CatchSelfTest/CatchSelfTest.xcodeproj/project.pbxproj +++ b/projects/XCode4/CatchSelfTest/CatchSelfTest.xcodeproj/project.pbxproj @@ -323,6 +323,7 @@ 4AC91CB4155B9EBF00DC5117 /* impl */ = { isa = PBXGroup; children = ( + 4A6D0C5F149B3E3D00DB3EAA /* catch_section.hpp */, 261488FA184C81130041FBEB /* catch_test_spec.hpp */, 263FD06017AF8DF200988A20 /* catch_timer.hpp */, 266E9AD117230ACF0061DAB2 /* catch_text.hpp */, @@ -350,7 +351,6 @@ 4A6D0C5C149B3E3D00DB3EAA /* catch_result_type.h */, 4A6D0C5D149B3E3D00DB3EAA /* catch_assertionresult.h */, 4A9D84B315599AC900FBB209 /* catch_expressionresult_builder.h */, - 4A6D0C5F149B3E3D00DB3EAA /* catch_section.hpp */, 261488FE184DC32F0041FBEB /* catch_section.h */, 4A3D7DD01503869D005F9203 /* catch_matchers.hpp */, 4A9D84B11558FC0400FBB209 /* catch_tostring.hpp */, From de49ec4d7c09c18dcb9011a7f53a8ea42c234918 Mon Sep 17 00:00:00 2001 From: Phil Nash Date: Wed, 4 Dec 2013 20:25:14 +0000 Subject: [PATCH 15/15] Fixed broken single header following script change - fixed the script (was missing #ifdefs) - also fixed single include (Xcode) test project - build 16 --- README.md | 2 +- include/internal/catch_version.hpp | 2 +- projects/SelfTest/TestMain.cpp | 7 - .../project.pbxproj | 8 +- scripts/generateSingleHeader.py | 209 +++++++++--------- single_include/catch.hpp | 16 +- 6 files changed, 120 insertions(+), 124 deletions(-) diff --git a/README.md b/README.md index ff20b3ff..5e93e7d2 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![catch logo](catch-logo-small.png) -*v1.0 build 15 (master branch)* +*v1.0 build 16 (master branch)* Build status (on Travis CI) [![Build Status](https://travis-ci.org/philsquared/Catch.png)](https://travis-ci.org/philsquared/Catch) diff --git a/include/internal/catch_version.hpp b/include/internal/catch_version.hpp index 6548fc98..13f1169a 100644 --- a/include/internal/catch_version.hpp +++ b/include/internal/catch_version.hpp @@ -13,7 +13,7 @@ namespace Catch { // These numbers are maintained by a script - Version libraryVersion( 1, 0, 15, "master" ); + Version libraryVersion( 1, 0, 16, "master" ); } #endif // TWOBLUECUBES_CATCH_VERSION_HPP_INCLUDED diff --git a/projects/SelfTest/TestMain.cpp b/projects/SelfTest/TestMain.cpp index 1d7211e5..575a456a 100644 --- a/projects/SelfTest/TestMain.cpp +++ b/projects/SelfTest/TestMain.cpp @@ -14,13 +14,6 @@ #pragma clang diagnostic ignored "-Wweak-vtables" #endif -#include "internal/catch_text.h" -#include "internal/catch_console_colour.hpp" -#include "internal/catch_commandline.hpp" -#include "internal/catch_test_spec.h" - -#include "reporters/catch_reporter_xml.hpp" - template void parseIntoConfig( const char * (&argv)[size], Catch::ConfigData& config ) { Clara::CommandLine parser = Catch::makeCommandLineParser(); diff --git a/projects/XCode4/CatchSelfTest/CatchSelfTestSingle.xcodeproj/project.pbxproj b/projects/XCode4/CatchSelfTest/CatchSelfTestSingle.xcodeproj/project.pbxproj index 440f12ad..209296a4 100644 --- a/projects/XCode4/CatchSelfTest/CatchSelfTestSingle.xcodeproj/project.pbxproj +++ b/projects/XCode4/CatchSelfTest/CatchSelfTestSingle.xcodeproj/project.pbxproj @@ -8,7 +8,6 @@ /* Begin PBXBuildFile section */ 4A2894D615D3956000E20735 /* ApproxTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A2894D515D3956000E20735 /* ApproxTests.cpp */; }; - 4AB735F815D396ED00F9F7C3 /* catch_self_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A2894D815D3957500E20735 /* catch_self_test.cpp */; }; 4AB735FA15D396F400F9F7C3 /* TestMain.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A2894E015D3957500E20735 /* TestMain.cpp */; }; 4AB735FB15D3970C00F9F7C3 /* ClassTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A2894DA15D3957500E20735 /* ClassTests.cpp */; }; 4AB735FC15D3971100F9F7C3 /* ConditionTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A2894DB15D3957500E20735 /* ConditionTests.cpp */; }; @@ -33,8 +32,6 @@ /* Begin PBXFileReference section */ 4A2894D515D3956000E20735 /* ApproxTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ApproxTests.cpp; path = ../../../SelfTest/ApproxTests.cpp; sourceTree = ""; }; - 4A2894D815D3957500E20735 /* catch_self_test.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = catch_self_test.cpp; path = ../../../SelfTest/catch_self_test.cpp; sourceTree = ""; }; - 4A2894D915D3957500E20735 /* catch_self_test.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = catch_self_test.hpp; path = ../../../SelfTest/catch_self_test.hpp; sourceTree = ""; }; 4A2894DA15D3957500E20735 /* ClassTests.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = ClassTests.cpp; path = ../../../SelfTest/ClassTests.cpp; sourceTree = ""; }; 4A2894DB15D3957500E20735 /* ConditionTests.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = ConditionTests.cpp; path = ../../../SelfTest/ConditionTests.cpp; sourceTree = ""; }; 4A2894DC15D3957500E20735 /* ExceptionTests.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = ExceptionTests.cpp; path = ../../../SelfTest/ExceptionTests.cpp; sourceTree = ""; }; @@ -61,8 +58,6 @@ isa = PBXGroup; children = ( 4A2894E015D3957500E20735 /* TestMain.cpp */, - 4A2894D815D3957500E20735 /* catch_self_test.cpp */, - 4A2894D915D3957500E20735 /* catch_self_test.hpp */, ); name = "Self Test"; sourceTree = ""; @@ -159,7 +154,6 @@ buildActionMask = 2147483647; files = ( 4A2894D615D3956000E20735 /* ApproxTests.cpp in Sources */, - 4AB735F815D396ED00F9F7C3 /* catch_self_test.cpp in Sources */, 4AB735FA15D396F400F9F7C3 /* TestMain.cpp in Sources */, 4AB735FB15D3970C00F9F7C3 /* ClassTests.cpp in Sources */, 4AB735FC15D3971100F9F7C3 /* ConditionTests.cpp in Sources */, @@ -224,6 +218,7 @@ 4A90B5E115D2E3E900EF71BC /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_CXX_LIBRARY = "libc++"; HEADER_SEARCH_PATHS = "../../../single_include/**"; PRODUCT_NAME = "$(TARGET_NAME)"; }; @@ -232,6 +227,7 @@ 4A90B5E215D2E3E900EF71BC /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_CXX_LIBRARY = "libc++"; HEADER_SEARCH_PATHS = "../../../single_include/**"; PRODUCT_NAME = "$(TARGET_NAME)"; }; diff --git a/scripts/generateSingleHeader.py b/scripts/generateSingleHeader.py index 0f7aa9ed..839c72cc 100644 --- a/scripts/generateSingleHeader.py +++ b/scripts/generateSingleHeader.py @@ -26,125 +26,126 @@ bumpVersion = True includeImpl = True for arg in sys.argv[1:]: - arg = string.lower(arg) - if arg == "nobump": - bumpVersion = False - print "Not bumping version number" - elif arg == "noimpl": - includeImpl = False - bumpVersion = False - print "Not including impl code (and not bumping version)" - else: - print "\n** Unrecognised argument: " + arg + " **\n" - exit(1) + arg = string.lower(arg) + if arg == "nobump": + bumpVersion = False + print "Not bumping version number" + elif arg == "noimpl": + includeImpl = False + bumpVersion = False + print "Not including impl code (and not bumping version)" + else: + print "\n** Unrecognised argument: " + arg + " **\n" + exit(1) out = open( outputPath, 'w' ) ifdefs = 0 implIfDefs = -1 def write( line ): - if includeImpl or implIfDefs == -1: - out.write( line ) + if includeImpl or implIfDefs == -1: + out.write( line ) def parseFile( path, filename ): - global ifdefs - global implIfDefs + global ifdefs + global implIfDefs - f = open( path + filename, 'r' ) - blanks = 0 - for line in f: - if ifParser.match( line ): - ifdefs = ifdefs + 1 - elif endIfParser.match( line ): - ifdefs = ifdefs - 1 - m = includesParser.match( line ) - if m: - header = m.group(1) - headerPath, sep, headerFile = header.rpartition( "/" ) - if not headerFile in seenHeaders: - seenHeaders.add( headerFile ) - write( "// #included from: {0}\n".format( header ) ) - if( headerPath == "internal" and path.endswith( "internal/" ) ): - headerPath = "" - sep = "" - if os.path.exists( path + headerPath + sep + headerFile ): - parseFile( path + headerPath + sep, headerFile ) - else: - parseFile( rootPath + headerPath + sep, headerFile ) - elif ifImplParser.match(line): - implIfDefs = ifdefs - elif (not guardParser.match( line ) or defineParser.match( line ) ) and not commentParser1.match( line )and not commentParser2.match( line ): - if blankParser.match( line ): - blanks = blanks + 1 - else: - blanks = 0 - if blanks < 2: - write( line.rstrip() + "\n" ) + f = open( path + filename, 'r' ) + blanks = 0 + for line in f: + if ifParser.match( line ): + ifdefs = ifdefs + 1 + elif endIfParser.match( line ): + ifdefs = ifdefs - 1 + m = includesParser.match( line ) + if m: + header = m.group(1) + headerPath, sep, headerFile = header.rpartition( "/" ) + if not headerFile in seenHeaders: + seenHeaders.add( headerFile ) + write( "// #included from: {0}\n".format( header ) ) + if( headerPath == "internal" and path.endswith( "internal/" ) ): + headerPath = "" + sep = "" + if os.path.exists( path + headerPath + sep + headerFile ): + parseFile( path + headerPath + sep, headerFile ) + else: + parseFile( rootPath + headerPath + sep, headerFile ) + else: + if ifImplParser.match(line): + implIfDefs = ifdefs + if (not guardParser.match( line ) or defineParser.match( line ) ) and not commentParser1.match( line )and not commentParser2.match( line ): + if blankParser.match( line ): + blanks = blanks + 1 + else: + blanks = 0 + if blanks < 2: + write( line.rstrip() + "\n" ) class Version: - def __init__(self): - f = open( versionPath, 'r' ) - for line in f: - m = versionParser.match( line ) - if m: - self.variableDecl = m.group(1) - self.majorVersion = int(m.group(2)) - self.minorVersion = int(m.group(3)) - self.buildNumber = int(m.group(4)) - self.branchName = m.group(5) - f.close() + def __init__(self): + f = open( versionPath, 'r' ) + for line in f: + m = versionParser.match( line ) + if m: + self.variableDecl = m.group(1) + self.majorVersion = int(m.group(2)) + self.minorVersion = int(m.group(3)) + self.buildNumber = int(m.group(4)) + self.branchName = m.group(5) + f.close() - def incrementBuildNumber(self): - self.buildNumber = self.buildNumber+1 + def incrementBuildNumber(self): + self.buildNumber = self.buildNumber+1 - def updateVersionFile(self): - f = open( versionPath, 'r' ) - lines = [] - for line in f: - m = versionParser.match( line ) - if m: - lines.append( '{0}( {1}, {2}, {3}, "{4}" );'.format( self.variableDecl, self.majorVersion, self.minorVersion, self.buildNumber, self.branchName ) ) - else: - lines.append( line.rstrip() ) - f.close() - f = open( versionPath, 'w' ) - for line in lines: - f.write( line + "\n" ) + def updateVersionFile(self): + f = open( versionPath, 'r' ) + lines = [] + for line in f: + m = versionParser.match( line ) + if m: + lines.append( '{0}( {1}, {2}, {3}, "{4}" );'.format( self.variableDecl, self.majorVersion, self.minorVersion, self.buildNumber, self.branchName ) ) + else: + lines.append( line.rstrip() ) + f.close() + f = open( versionPath, 'w' ) + for line in lines: + f.write( line + "\n" ) - def updateReadmeFile(self): - f = open( readmePath, 'r' ) - lines = [] - for line in f: - lines.append( line.rstrip() ) - f.close() - f = open( readmePath, 'w' ) - for line in lines: - if line.startswith( "*v" ): - f.write( '*v{0}.{1} build {2} ({3} branch)*\n'.format( self.majorVersion, self.minorVersion, self.buildNumber, self.branchName ) ) - else: - f.write( line + "\n" ) + def updateReadmeFile(self): + f = open( readmePath, 'r' ) + lines = [] + for line in f: + lines.append( line.rstrip() ) + f.close() + f = open( readmePath, 'w' ) + for line in lines: + if line.startswith( "*v" ): + f.write( '*v{0}.{1} build {2} ({3} branch)*\n'.format( self.majorVersion, self.minorVersion, self.buildNumber, self.branchName ) ) + else: + f.write( line + "\n" ) def generateSingleInclude(): - v = Version() - if bumpVersion: - v.incrementBuildNumber() - v.updateVersionFile() - v.updateReadmeFile() - out.write( "/*\n" ) - out.write( " * CATCH v{0}.{1} build {2} ({3} branch)\n".format( v.majorVersion, v.minorVersion, v.buildNumber, v.branchName ) ) - out.write( " * Generated: {0}\n".format( datetime.datetime.now() ) ) - out.write( " * ----------------------------------------------------------\n" ) - out.write( " * This file has been merged from multiple headers. Please don't edit it directly\n" ) - out.write( " * Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.\n" ) - out.write( " *\n" ) - out.write( " * Distributed under the Boost Software License, Version 1.0. (See accompanying\n" ) - out.write( " * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)\n" ) - out.write( " */\n" ) - out.write( "#ifndef TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED\n" ) - out.write( "#define TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED\n" ) - - parseFile( rootPath, 'catch.hpp' ) - - out.write( "#endif // TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED\n\n" ) + v = Version() + if bumpVersion: + v.incrementBuildNumber() + v.updateVersionFile() + v.updateReadmeFile() + out.write( "/*\n" ) + out.write( " * CATCH v{0}.{1} build {2} ({3} branch)\n".format( v.majorVersion, v.minorVersion, v.buildNumber, v.branchName ) ) + out.write( " * Generated: {0}\n".format( datetime.datetime.now() ) ) + out.write( " * ----------------------------------------------------------\n" ) + out.write( " * This file has been merged from multiple headers. Please don't edit it directly\n" ) + out.write( " * Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.\n" ) + out.write( " *\n" ) + out.write( " * Distributed under the Boost Software License, Version 1.0. (See accompanying\n" ) + out.write( " * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)\n" ) + out.write( " */\n" ) + out.write( "#ifndef TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED\n" ) + out.write( "#define TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED\n" ) + + parseFile( rootPath, 'catch.hpp' ) + + out.write( "#endif // TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED\n\n" ) generateSingleInclude() diff --git a/single_include/catch.hpp b/single_include/catch.hpp index 86385c66..f192075d 100644 --- a/single_include/catch.hpp +++ b/single_include/catch.hpp @@ -1,6 +1,6 @@ /* - * CATCH v1.0 build 15 (master branch) - * Generated: 2013-12-03 18:52:51.480072 + * CATCH v1.0 build 16 (master branch) + * Generated: 2013-12-04 20:23:35.145591 * ---------------------------------------------------------- * This file has been merged from multiple headers. Please don't edit it directly * Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved. @@ -178,7 +178,7 @@ namespace Catch { struct SourceLineInfo { SourceLineInfo(); - SourceLineInfo( std::string const& _file, std::size_t _line ); + SourceLineInfo( char const* _file, std::size_t _line ); SourceLineInfo( SourceLineInfo const& other ); bool empty() const; bool operator == ( SourceLineInfo const& other ) const; @@ -2591,6 +2591,7 @@ return @ desc; \ #endif +#if defined( CATCH_CONFIG_MAIN ) || defined( CATCH_CONFIG_RUNNER ) // #included from: internal/catch_impl.hpp #define TWOBLUECUBES_CATCH_IMPL_HPP_INCLUDED @@ -5786,6 +5787,10 @@ namespace Catch { if( tags.find( "hide" ) != tags.end() || tags.find( "." ) != tags.end() ) isHidden = true; + if( isHidden ) { + tags.insert( "hide" ); + tags.insert( "." ); + } TestCaseInfo info( _name, _className, desc, tags, isHidden, _lineInfo ); return TestCase( _testCase, info ); } @@ -6134,7 +6139,7 @@ namespace Catch { namespace Catch { // These numbers are maintained by a script - Version libraryVersion( 1, 0, 15, "master" ); + Version libraryVersion( 1, 0, 16, "master" ); } // #included from: catch_text.hpp @@ -6473,7 +6478,7 @@ namespace Catch { } SourceLineInfo::SourceLineInfo() : line( 0 ){} - SourceLineInfo::SourceLineInfo( std::string const& _file, std::size_t _line ) + SourceLineInfo::SourceLineInfo( char const* _file, std::size_t _line ) : file( _file ), line( _line ) {} @@ -7866,6 +7871,7 @@ namespace Catch { #endif // CATCH_CONFIG_MAIN || CATCH_CONFIG_RUNNER +#ifdef CATCH_CONFIG_MAIN // #included from: internal/catch_default_main.hpp #define TWOBLUECUBES_CATCH_DEFAULT_MAIN_HPP_INCLUDED