mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-30 01:03:30 +01:00
Refactored to resetAssertionInfo()
This commit is contained in:
parent
4353614df7
commit
fcba30569c
@ -8,8 +8,6 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
static auto const& defaultExpression = "{Unknown expression after the reported line}";
|
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
StreamRedirect::StreamRedirect(std::ostream& stream, std::string& targetString)
|
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)));
|
static_cast<void>(m_reporter->assertionEnded(AssertionStats(result, m_messages, m_totals)));
|
||||||
|
|
||||||
// Reset working state
|
// Reset working state
|
||||||
m_lastAssertionInfo = { "", m_lastAssertionInfo.lineInfo, "{Unknown expression after the reported line}", m_lastAssertionInfo.resultDisposition };
|
resetAssertionInfo();
|
||||||
m_lastResult = result;
|
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) {
|
bool RunContext::sectionStarted(SectionInfo const & sectionInfo, Counts & assertions) {
|
||||||
ITracker& sectionTracker = SectionTracker::acquire(m_trackerContext, TestCaseTracking::NameAndLocation(sectionInfo.name, sectionInfo.lineInfo));
|
ITracker& sectionTracker = SectionTracker::acquire(m_trackerContext, TestCaseTracking::NameAndLocation(sectionInfo.name, sectionInfo.lineInfo));
|
||||||
@ -255,8 +257,7 @@ namespace Catch {
|
|||||||
|
|
||||||
void RunContext::assertionPassed() {
|
void RunContext::assertionPassed() {
|
||||||
++m_totals.assertions.passed;
|
++m_totals.assertions.passed;
|
||||||
m_lastAssertionInfo.capturedExpression = StringRef(defaultExpression, sizeof(defaultExpression) - 1);
|
resetAssertionInfo();
|
||||||
m_lastAssertionInfo.macroName = StringRef("", 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RunContext::assertionRun() {
|
void RunContext::assertionRun() {
|
||||||
@ -274,18 +275,19 @@ namespace Catch {
|
|||||||
Counts prevAssertions = m_totals.assertions;
|
Counts prevAssertions = m_totals.assertions;
|
||||||
double duration = 0;
|
double duration = 0;
|
||||||
m_shouldReportUnexpected = true;
|
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 timer;
|
||||||
timer.start();
|
try {
|
||||||
if (m_reporter->getPreferences().shouldRedirectStdOut) {
|
if (m_reporter->getPreferences().shouldRedirectStdOut) {
|
||||||
StreamRedirect coutRedir(cout(), redirectedCout);
|
StreamRedirect coutRedir(cout(), redirectedCout);
|
||||||
StdErrRedirect errRedir(redirectedCerr);
|
StdErrRedirect errRedir(redirectedCerr);
|
||||||
|
timer.start();
|
||||||
invokeActiveTestCase();
|
invokeActiveTestCase();
|
||||||
} else {
|
} else {
|
||||||
|
timer.start();
|
||||||
invokeActiveTestCase();
|
invokeActiveTestCase();
|
||||||
}
|
}
|
||||||
duration = timer.getElapsedSeconds();
|
duration = timer.getElapsedSeconds();
|
||||||
|
@ -116,6 +116,8 @@ namespace Catch {
|
|||||||
void runCurrentTest(std::string& redirectedCout, std::string& redirectedCerr);
|
void runCurrentTest(std::string& redirectedCout, std::string& redirectedCerr);
|
||||||
void invokeActiveTestCase();
|
void invokeActiveTestCase();
|
||||||
|
|
||||||
|
void resetAssertionInfo();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void handleUnfinishedSections();
|
void handleUnfinishedSections();
|
||||||
|
Loading…
Reference in New Issue
Block a user