From ca2455e6e6436d18b4d62dddd0595444cceeb3ad Mon Sep 17 00:00:00 2001 From: Phil Nash Date: Fri, 26 Jan 2018 16:52:28 +0000 Subject: [PATCH] Fixed NoAssertions warning --- include/internal/catch_run_context.cpp | 5 +- .../Baselines/compact.sw.approved.txt | 2 +- .../Baselines/console.sw.approved.txt | 82 ++++++++++++++++++- .../SelfTest/Baselines/junit.sw.approved.txt | 2 +- .../SelfTest/Baselines/xml.sw.approved.txt | 28 +++---- 5 files changed, 99 insertions(+), 20 deletions(-) diff --git a/include/internal/catch_run_context.cpp b/include/internal/catch_run_context.cpp index 2f07a6a0..ca78bfb4 100644 --- a/include/internal/catch_run_context.cpp +++ b/include/internal/catch_run_context.cpp @@ -321,12 +321,13 @@ namespace Catch { handleUnexpectedInflightException( m_lastAssertionInfo, translateActiveException(), dummyReaction ); } } + Counts assertions = m_totals.assertions - prevAssertions; + bool missingAssertions = testForMissingAssertions(assertions); + m_testCaseTracker->close(); handleUnfinishedSections(); m_messages.clear(); - Counts assertions = m_totals.assertions - prevAssertions; - bool missingAssertions = testForMissingAssertions(assertions); SectionStats testCaseSectionStats(testCaseSection, assertions, duration, missingAssertions); m_reporter->sectionEnded(testCaseSectionStats); } diff --git a/projects/SelfTest/Baselines/compact.sw.approved.txt b/projects/SelfTest/Baselines/compact.sw.approved.txt index 68c9e5cf..25e183bb 100644 --- a/projects/SelfTest/Baselines/compact.sw.approved.txt +++ b/projects/SelfTest/Baselines/compact.sw.approved.txt @@ -1058,5 +1058,5 @@ Misc.tests.cpp:: passed: v.size() == 5 for: 5 == 5 Misc.tests.cpp:: passed: v.capacity() >= 5 for: 5 >= 5 Misc.tests.cpp:: passed: Misc.tests.cpp:: passed: -Failed 49 test cases, failed 108 assertions. +Failed 61 test cases, failed 120 assertions. diff --git a/projects/SelfTest/Baselines/console.sw.approved.txt b/projects/SelfTest/Baselines/console.sw.approved.txt index 11b89a33..eaf2cb41 100644 --- a/projects/SelfTest/Baselines/console.sw.approved.txt +++ b/projects/SelfTest/Baselines/console.sw.approved.txt @@ -574,6 +574,15 @@ PASSED: with expansion: 100.3 == Approx( 100.0 ) +------------------------------------------------------------------------------- +An empty test with no assertions +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + + +No assertions in test case 'An empty test with no assertions' + ------------------------------------------------------------------------------- An expression with side-effects should only be evaluated once ------------------------------------------------------------------------------- @@ -2118,6 +2127,9 @@ warning: this is a message this is a warning + +No assertions in test case 'INFO and WARN do not abort tests' + ------------------------------------------------------------------------------- INFO gets logged on failure ------------------------------------------------------------------------------- @@ -2530,6 +2542,9 @@ Misc.tests.cpp:: warning: This one ran + +No assertions in test case 'Nice descriptive name' + ------------------------------------------------------------------------------- Non-std exceptions can be translated ------------------------------------------------------------------------------- @@ -4662,6 +4677,15 @@ with expansion: A string sent directly to stdout A string sent directly to stderr A string sent to stderr via clog +------------------------------------------------------------------------------- +Sends stuff to stdout and stderr +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + + +No assertions in test case 'Sends stuff to stdout and stderr' + ------------------------------------------------------------------------------- Some simple comparisons between doubles ------------------------------------------------------------------------------- @@ -5390,6 +5414,9 @@ Message.tests.cpp:: FAILED - but was ok: CHECK_NOFAIL( 1 == 2 ) + +No assertions in test case 'The NO_FAIL macro reports a failure but does not fail the test' + ------------------------------------------------------------------------------- This test 'should' fail but doesn't ------------------------------------------------------------------------------- @@ -6755,6 +6782,15 @@ Exception.tests.cpp:: FAILED: due to unexpected exception with message: unexpected exception +------------------------------------------------------------------------------- +When unchecked exceptions are thrown, but caught, they do not affect the test +------------------------------------------------------------------------------- +Exception.tests.cpp: +............................................................................... + + +No assertions in test case 'When unchecked exceptions are thrown, but caught, they do not affect the test' + ------------------------------------------------------------------------------- Where the LHS is not a simple value ------------------------------------------------------------------------------- @@ -6766,6 +6802,9 @@ warning: Uncomment the code in this test to check that it gives a sensible compiler error + +No assertions in test case 'Where the LHS is not a simple value' + ------------------------------------------------------------------------------- Where there is more to the expression after the RHS ------------------------------------------------------------------------------- @@ -6777,6 +6816,9 @@ warning: Uncomment the code in this test to check that it gives a sensible compiler error + +No assertions in test case 'Where there is more to the expression after the RHS' + ------------------------------------------------------------------------------- X/level/0/a ------------------------------------------------------------------------------- @@ -7143,7 +7185,25 @@ Misc.tests.cpp: Misc.tests.cpp:: PASSED: +------------------------------------------------------------------------------- +first tag +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + + +No assertions in test case 'first tag' + loose text artifact +------------------------------------------------------------------------------- +has printf +------------------------------------------------------------------------------- +Tricky.tests.cpp: +............................................................................... + + +No assertions in test case 'has printf' + ------------------------------------------------------------------------------- just failure ------------------------------------------------------------------------------- @@ -7154,6 +7214,15 @@ Message.tests.cpp:: FAILED: explicitly with message: Previous info should not be seen +------------------------------------------------------------------------------- +just info +------------------------------------------------------------------------------- +Message.tests.cpp: +............................................................................... + + +No assertions in test case 'just info' + ------------------------------------------------------------------------------- long long ------------------------------------------------------------------------------- @@ -7572,6 +7641,15 @@ PASSED: with expansion: "didn|'t" == "didn|'t" +------------------------------------------------------------------------------- +second tag +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + + +No assertions in test case 'second tag' + ------------------------------------------------------------------------------- send a single char to INFO ------------------------------------------------------------------------------- @@ -8329,6 +8407,6 @@ Misc.tests.cpp:: PASSED: =============================================================================== -test cases: 197 | 144 passed | 49 failed | 4 failed as expected -assertions: 991 | 862 passed | 108 failed | 21 failed as expected +test cases: 197 | 132 passed | 61 failed | 4 failed as expected +assertions: 1003 | 862 passed | 120 failed | 21 failed as expected diff --git a/projects/SelfTest/Baselines/junit.sw.approved.txt b/projects/SelfTest/Baselines/junit.sw.approved.txt index 79d8e6d9..4bd6458c 100644 --- a/projects/SelfTest/Baselines/junit.sw.approved.txt +++ b/projects/SelfTest/Baselines/junit.sw.approved.txt @@ -1,7 +1,7 @@ - + diff --git a/projects/SelfTest/Baselines/xml.sw.approved.txt b/projects/SelfTest/Baselines/xml.sw.approved.txt index 86557362..a95f74f1 100644 --- a/projects/SelfTest/Baselines/xml.sw.approved.txt +++ b/projects/SelfTest/Baselines/xml.sw.approved.txt @@ -600,7 +600,7 @@ - + @@ -2447,7 +2447,7 @@ this is a warning - + @@ -2957,7 +2957,7 @@ This one ran - + @@ -5375,7 +5375,7 @@ - + A string sent directly to stdout @@ -6183,7 +6183,7 @@ Message from section two 1 == 2 - + @@ -7699,19 +7699,19 @@ Message from section two - + 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 - + @@ -8052,11 +8052,11 @@ Message from section two - + loose text artifact - + @@ -8065,7 +8065,7 @@ loose text artifact - + @@ -8512,7 +8512,7 @@ loose text artifact - + @@ -9257,7 +9257,7 @@ loose text artifact - + - +