Do not copy around TestCaseInfo

Now a `TEST_CASE` macro should create a single TestCaseInfo and then
it should never be copied around. This, together with latter changes,
should significantly decrease the number of allocations made before
`main` is even entered.
This commit is contained in:
Martin Hořeňovský committed 2019-11-14 10:52:34 +01:00
1 parent 019b0a0fe0
commit 302e2c0b06
33 files changed
+631 -626

No files matched your search

+6 -6
View File
@@ -12,19 +12,19 @@
namespace Catch {
auto makeTestInvoker( void(*testAsFunction)() ) noexcept -> ITestInvoker* {
return new(std::nothrow) TestInvokerAsFunction( testAsFunction );
std::unique_ptr<ITestInvoker> makeTestInvoker( void(*testAsFunction)() ) {
return std::make_unique<TestInvokerAsFunction>( testAsFunction );
}
AutoReg::AutoReg( ITestInvoker* invoker, SourceLineInfo const& lineInfo, StringRef const& classOrMethod, NameAndTags const& nameAndTags ) noexcept {
AutoReg::AutoReg( std::unique_ptr<ITestInvoker> invoker, SourceLineInfo const& lineInfo, StringRef const& classOrMethod, NameAndTags const& nameAndTags ) noexcept {
CATCH_TRY {
getMutableRegistryHub()
.registerTest(
makeTestCase(
invoker,
makeTestCaseInfo(
extractClassName( classOrMethod ),
nameAndTags,
lineInfo));
lineInfo),
std::move(invoker));
} CATCH_CATCH_ALL {
// Do not throw when constructing global objects, instead register the exception to be processed later
getMutableRegistryHub().registerStartupException();