diff options
| author | Martin Hořeňovský | 2020-05-25 09:45:24 +0200 |
|---|---|---|
| committer | Martin Hořeňovský | 2020-05-31 15:20:24 +0200 |
| commit | 1d1ccf8f3c0c9e121b16afd4fafb850d14ef9fb0 (patch) | |
| tree | 0a292cf929c75743993d42453312e08888ef7c0a /tests/SelfTest | |
| parent | 41bbaa6d573a598fe0796fd0e391ed57eae62e30 (diff) | |
| download | catch3-1d1ccf8f3c0c9e121b16afd4fafb850d14ef9fb0.tar.gz | |
Replace all uses of std::unique_ptr with Catch::Detail::unique_ptr
Doing some benchmarking with ClangBuildAnalyzer suggests that
compiling Catch2's `SelfTest` spends 10% of the time instantiating
`std::unique_ptr` for some interface types required for registering
and running tests.
The lesser compilation overhead of `Catch::Detail::unique_ptr` should
significantly reduce that time.
The compiled implementation was also changed to use the custom impl,
to avoid having to convert between using `std::unique_ptr` and
`Catch::Detail::unique_ptr`. This will likely also improve the compile
times of the implementation, but that is less important than improving
compilation times of the user's TUs with tests.
Diffstat (limited to 'tests/SelfTest')
| -rw-r--r-- | tests/SelfTest/IntrospectiveTests/GeneratorsImpl.tests.cpp | 2 | ||||
| -rw-r--r-- | tests/SelfTest/IntrospectiveTests/ToString.tests.cpp | 2 | ||||
| -rw-r--r-- | tests/SelfTest/UsageTests/Misc.tests.cpp | 1 |
3 files changed, 3 insertions, 2 deletions
diff --git a/tests/SelfTest/IntrospectiveTests/GeneratorsImpl.tests.cpp b/tests/SelfTest/IntrospectiveTests/GeneratorsImpl.tests.cpp index 81f5a811..169cac82 100644 --- a/tests/SelfTest/IntrospectiveTests/GeneratorsImpl.tests.cpp +++ b/tests/SelfTest/IntrospectiveTests/GeneratorsImpl.tests.cpp @@ -313,7 +313,7 @@ TEST_CASE("GENERATE capture macros", "[generators][internals][approvals]") { non_copyable nc; nc.value = value; // neither `GENERATE_COPY` nor plain `GENERATE` would compile here - auto value2 = GENERATE_REF(Catch::Generators::GeneratorWrapper<int>(std::unique_ptr<Catch::Generators::IGenerator<int>>(new TestGen(nc)))); + auto value2 = GENERATE_REF(Catch::Generators::GeneratorWrapper<int>(Catch::Detail::make_unique<TestGen>(nc))); REQUIRE(value == value2); } diff --git a/tests/SelfTest/IntrospectiveTests/ToString.tests.cpp b/tests/SelfTest/IntrospectiveTests/ToString.tests.cpp index 966bebed..b50a4012 100644 --- a/tests/SelfTest/IntrospectiveTests/ToString.tests.cpp +++ b/tests/SelfTest/IntrospectiveTests/ToString.tests.cpp @@ -34,7 +34,7 @@ TEST_CASE( "parseEnums", "[Strings][enums]" ) { TEST_CASE( "Directly creating an EnumInfo" ) { using namespace Catch::Detail; - std::unique_ptr<EnumInfo> enumInfo = makeEnumInfo( "EnumName", "EnumName::Value1, EnumName::Value2", {0, 1} ); + auto enumInfo = makeEnumInfo( "EnumName", "EnumName::Value1, EnumName::Value2", {0, 1} ); CHECK( enumInfo->lookup(0) == "Value1" ); CHECK( enumInfo->lookup(1) == "Value2" ); diff --git a/tests/SelfTest/UsageTests/Misc.tests.cpp b/tests/SelfTest/UsageTests/Misc.tests.cpp index 8203f730..c3e39161 100644 --- a/tests/SelfTest/UsageTests/Misc.tests.cpp +++ b/tests/SelfTest/UsageTests/Misc.tests.cpp @@ -16,6 +16,7 @@ #include <cerrno> #include <limits> #include <array> +#include <tuple> namespace { namespace MiscTests { |