Skip to content

Commit

Permalink
Micro optimization: Call _protected_console->Write once instead of tw…
Browse files Browse the repository at this point in the history
…ice in ZenUnit::RunTest
  • Loading branch information
NeilJustice committed Oct 14, 2024
1 parent eda20ab commit b16b789
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions ZenUnitAndMetalMock/ZenUnit.h
Original file line number Diff line number Diff line change
Expand Up @@ -6402,8 +6402,8 @@ Fatal Windows C++ Runtime Assertion
zenUnitArgs.testNameFilters, this, &TestClassRunner::TestNameFilterMatchesTestName, testName);
if (testNameFilterMatchesTestName)
{
_protected_console->Write("|");
_protected_console->Write(testName);
const std::string barTestName = String::ConcatStrings("|", testName);
_protected_console->Write(barTestName);
test->WritePostTestNameMessage(_protected_console.get());
std::vector<TestResult> testResults = test->RunTest();
test->WritePostTestCompletionMessage(_protected_console.get(), testResults[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,16 +408,15 @@ namespace ZenUnit
//
_specificTestClassRunner->RunTest(test, &testClassResultMock);
//
METALMOCK(_protected_consoleMock->WriteMock.CalledNTimes(2));
METALMOCK(_call_ZenUnitTestRunner_GetZenUnitArgsMock.CalledOnce());
METALMOCK(testMock->NameMock.CalledOnce());
if (expectAnyerCall)
{
METALMOCK(_protected_twoArgMemberAnyerMock->TwoArgAnyMock.CalledOnceWith(
zenUnitArgs.testNameFilters, _specificTestClassRunner.get(), &TestClassRunner::TestNameFilterMatchesTestName, testName.c_str()));
}
METALMOCK(_protected_consoleMock->WriteMock.CalledWith("|"));
METALMOCK(_protected_consoleMock->WriteMock.CalledWith(testName));
const string expectedBarTestName = String::ConcatStrings("|", testName);
METALMOCK(_protected_consoleMock->WriteMock.CalledOnceWith(expectedBarTestName));
METALMOCK(testMock->WritePostTestNameMessageMock.CalledOnceWith(_specificTestClassRunner->_protected_console.get()));
METALMOCK(testMock->RunTestMock.CalledOnce());
METALMOCK(testClassResultMock.AddTestResultsMock.CalledOnceWith(TestResults));
Expand Down

0 comments on commit b16b789

Please sign in to comment.