Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/include/internal
diff options
context:
space:
mode:
authorPhil Nash2017-11-17 18:55:47 +0000
committerPhil Nash2017-11-20 16:33:06 +0000
commitfcba30569cee61e577af8ae43379d54eee635283 (patch)
tree4b8c4f013b20a9d1bdc3d8ef20e32f58e612e3ce /include/internal
parent4353614df70350ca4eb67caa1c920e221891b212 (diff)
downloadcatch3-fcba30569cee61e577af8ae43379d54eee635283.tar.gz
Refactored to resetAssertionInfo()
Diffstat (limited to 'include/internal')
-rw-r--r--include/internal/catch_run_context.cpp22
-rw-r--r--include/internal/catch_run_context.h2
2 files changed, 14 insertions, 10 deletions
diff --git a/include/internal/catch_run_context.cpp b/include/internal/catch_run_context.cpp
index 6748d3e0..98cc655a 100644
--- a/include/internal/catch_run_context.cpp
+++ b/include/internal/catch_run_context.cpp
@@ -8,8 +8,6 @@
#include <algorithm>
#include <sstream>
-static auto const& defaultExpression = "{Unknown expression after the reported line}";
-
namespace Catch {
StreamRedirect::StreamRedirect(std::ostream& stream, std::string& targetString)
@@ -129,9 +127,13 @@ namespace Catch {
static_cast<void>(m_reporter->assertionEnded(AssertionStats(result, m_messages, m_totals)));
// Reset working state
- m_lastAssertionInfo = { "", m_lastAssertionInfo.lineInfo, "{Unknown expression after the reported line}", m_lastAssertionInfo.resultDisposition };
+ resetAssertionInfo();
m_lastResult = result;
}
+ void RunContext::resetAssertionInfo() {
+ m_lastAssertionInfo.macroName = StringRef();
+ m_lastAssertionInfo.capturedExpression = "{Unknown expression after the reported line}";
+ }
bool RunContext::sectionStarted(SectionInfo const & sectionInfo, Counts & assertions) {
ITracker& sectionTracker = SectionTracker::acquire(m_trackerContext, TestCaseTracking::NameAndLocation(sectionInfo.name, sectionInfo.lineInfo));
@@ -255,8 +257,7 @@ namespace Catch {
void RunContext::assertionPassed() {
++m_totals.assertions.passed;
- m_lastAssertionInfo.capturedExpression = StringRef(defaultExpression, sizeof(defaultExpression) - 1);
- m_lastAssertionInfo.macroName = StringRef("", 0);
+ resetAssertionInfo();
}
void RunContext::assertionRun() {
@@ -274,18 +275,19 @@ namespace Catch {
Counts prevAssertions = m_totals.assertions;
double duration = 0;
m_shouldReportUnexpected = true;
- try {
- m_lastAssertionInfo = { "TEST_CASE", testCaseInfo.lineInfo, "", ResultDisposition::Normal };
+ m_lastAssertionInfo = { "TEST_CASE", testCaseInfo.lineInfo, "", ResultDisposition::Normal };
- seedRng(*m_config);
+ seedRng(*m_config);
- Timer timer;
- timer.start();
+ Timer timer;
+ try {
if (m_reporter->getPreferences().shouldRedirectStdOut) {
StreamRedirect coutRedir(cout(), redirectedCout);
StdErrRedirect errRedir(redirectedCerr);
+ timer.start();
invokeActiveTestCase();
} else {
+ timer.start();
invokeActiveTestCase();
}
duration = timer.getElapsedSeconds();
diff --git a/include/internal/catch_run_context.h b/include/internal/catch_run_context.h
index 0d10a19b..22c4d76a 100644
--- a/include/internal/catch_run_context.h
+++ b/include/internal/catch_run_context.h
@@ -116,6 +116,8 @@ namespace Catch {
void runCurrentTest(std::string& redirectedCout, std::string& redirectedCerr);
void invokeActiveTestCase();
+ void resetAssertionInfo();
+
private:
void handleUnfinishedSections();