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

summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMartin Hořeňovský2020-05-24 23:41:02 +0200
committerMartin Hořeňovský2020-05-31 15:08:47 +0200
commit41bbaa6d573a598fe0796fd0e391ed57eae62e30 (patch)
treeb43f9559ac989599f2d38e9237b304d77c7162da
parent66ab942903aaaaf3b6606a8125e55d0d844d7478 (diff)
downloadcatch3-41bbaa6d573a598fe0796fd0e391ed57eae62e30.tar.gz
Implement a simplified variant of std::unique_ptr<T>
This simplified variant supports only a subset of the functionality in `std::unique_ptr<T>`. `Catch::Detail::unique_ptr<T>` only supports single element pointer (no array support) with default deleter. By removing the support for custom deleters, we also avoid requiring significant machinery to support EBO, speeding up instantiations of `unique_ptr<T>` significantly. Catch2 also currently does not need to support `unique_ptr<T[]>`, so that is not supported either.
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/catch2/catch_all.hpp1
-rw-r--r--src/catch2/internal/catch_unique_ptr.hpp110
-rw-r--r--tests/CMakeLists.txt1
-rw-r--r--tests/SelfTest/Baselines/automake.sw.approved.txt3
-rw-r--r--tests/SelfTest/Baselines/compact.sw.approved.txt28
-rw-r--r--tests/SelfTest/Baselines/console.std.approved.txt4
-rw-r--r--tests/SelfTest/Baselines/console.sw.approved.txt244
-rw-r--r--tests/SelfTest/Baselines/junit.sw.approved.txt15
-rw-r--r--tests/SelfTest/Baselines/sonarqube.sw.approved.txt15
-rw-r--r--tests/SelfTest/Baselines/tap.sw.approved.txt58
-rw-r--r--tests/SelfTest/Baselines/teamcity.sw.approved.txt6
-rw-r--r--tests/SelfTest/Baselines/xml.sw.approved.txt279
-rw-r--r--tests/SelfTest/IntrospectiveTests/UniquePtr.tests.cpp133
14 files changed, 890 insertions, 8 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 4f81c000..1be01da7 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -125,6 +125,7 @@ set(INTERNAL_HEADERS
${SOURCES_DIR}/catch_totals.hpp
${SOURCES_DIR}/catch_translate_exception.hpp
${SOURCES_DIR}/internal/catch_uncaught_exceptions.hpp
+ ${SOURCES_DIR}/internal/catch_unique_ptr.hpp
${SOURCES_DIR}/catch_version.hpp
${SOURCES_DIR}/catch_version_macros.hpp
${SOURCES_DIR}/internal/catch_wildcard_pattern.hpp
diff --git a/src/catch2/catch_all.hpp b/src/catch2/catch_all.hpp
index b0f31196..fab323bd 100644
--- a/src/catch2/catch_all.hpp
+++ b/src/catch2/catch_all.hpp
@@ -85,6 +85,7 @@
#include <catch2/internal/catch_text.hpp>
#include <catch2/internal/catch_to_string.hpp>
#include <catch2/internal/catch_uncaught_exceptions.hpp>
+#include <catch2/internal/catch_unique_ptr.hpp>
#include <catch2/internal/catch_wildcard_pattern.hpp>
#include <catch2/internal/catch_windows_h_proxy.hpp>
#include <catch2/internal/catch_xmlwriter.hpp>
diff --git a/src/catch2/internal/catch_unique_ptr.hpp b/src/catch2/internal/catch_unique_ptr.hpp
new file mode 100644
index 00000000..f963e9d6
--- /dev/null
+++ b/src/catch2/internal/catch_unique_ptr.hpp
@@ -0,0 +1,110 @@
+#ifndef CATCH_UNIQUE_PTR_HPP_INCLUDED
+#define CATCH_UNIQUE_PTR_HPP_INCLUDED
+
+#include <cassert>
+#include <type_traits>
+
+namespace Catch {
+namespace Detail {
+ // reimplementation of unique_ptr for improved compilation times
+ // Does not support custom deleters (and thus does not require EBO)
+ // Does not support arrays
+ template <typename T>
+ class unique_ptr {
+ T* m_ptr;
+ public:
+ constexpr unique_ptr(std::nullptr_t = nullptr):
+ m_ptr{}
+ {}
+ explicit constexpr unique_ptr(T* ptr):
+ m_ptr(ptr)
+ {}
+
+ template <typename U, typename = std::enable_if_t<std::is_base_of<T, U>::value>>
+ unique_ptr(unique_ptr<U>&& from):
+ m_ptr(from.release())
+ {}
+
+ template <typename U, typename = std::enable_if_t<std::is_base_of<T, U>::value>>
+ unique_ptr& operator=(unique_ptr<U>&& from) {
+ reset(from.release());
+
+ return *this;
+ }
+
+ unique_ptr(unique_ptr const&) = delete;
+ unique_ptr& operator=(unique_ptr const&) = delete;
+
+ unique_ptr(unique_ptr&& rhs) noexcept:
+ m_ptr(rhs.m_ptr) {
+ rhs.m_ptr = nullptr;
+ }
+ unique_ptr& operator=(unique_ptr&& rhs) noexcept {
+ reset(rhs.release());
+
+ return *this;
+ }
+
+ ~unique_ptr() {
+ delete m_ptr;
+ }
+
+ T& operator*() {
+ assert(m_ptr);
+ return *m_ptr;
+ }
+ T const& operator*() const {
+ assert(m_ptr);
+ return *m_ptr;
+ }
+ T* operator->() const noexcept {
+ assert(m_ptr);
+ return m_ptr;
+ }
+
+ T* get() { return m_ptr; }
+ T const* get() const { return m_ptr; }
+
+ void reset(T* ptr = nullptr) {
+ delete m_ptr;
+ m_ptr = ptr;
+ }
+
+ T* release() {
+ auto temp = m_ptr;
+ m_ptr = nullptr;
+ return temp;
+ }
+
+ explicit operator bool() const {
+ return m_ptr;
+ }
+
+ friend void swap(unique_ptr& lhs, unique_ptr& rhs) {
+ auto temp = lhs.m_ptr;
+ lhs.m_ptr = rhs.m_ptr;
+ rhs.m_ptr = temp;
+ }
+ };
+
+ // Purposefully doesn't exist
+ // We could also rely on compiler warning + werror for calling plain delete
+ // on a T[], but this seems better.
+ // Maybe add definition and a static assert?
+ template <typename T>
+ class unique_ptr<T[]>;
+
+ template <typename T, typename... Args>
+ unique_ptr<T> make_unique(Args&&... args) {
+ // static_cast<Args&&> does the same thing as std::forward in
+ // this case, but does not require including big header (<utility>)
+ // and compiles faster thanks to not requiring template instantiation
+ // and overload resolution
+ return unique_ptr<T>(new T(static_cast<Args&&>(args)...));
+ }
+
+
+} // end namespace Detail
+} // end namespace Catch
+
+#endif // CATCH_UNIQUE_PTR_HPP_INCLUDED
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 8b3c9092..a5fdf802 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -27,6 +27,7 @@ set(TEST_SOURCES
${SELF_TEST_DIR}/IntrospectiveTests/StringManip.tests.cpp
${SELF_TEST_DIR}/IntrospectiveTests/Xml.tests.cpp
${SELF_TEST_DIR}/IntrospectiveTests/ToString.tests.cpp
+ ${SELF_TEST_DIR}/IntrospectiveTests/UniquePtr.tests.cpp
${SELF_TEST_DIR}/UsageTests/Approx.tests.cpp
${SELF_TEST_DIR}/UsageTests/BDD.tests.cpp
${SELF_TEST_DIR}/UsageTests/Benchmark.tests.cpp
diff --git a/tests/SelfTest/Baselines/automake.sw.approved.txt b/tests/SelfTest/Baselines/automake.sw.approved.txt
index 88a43ede..ffde555a 100644
--- a/tests/SelfTest/Baselines/automake.sw.approved.txt
+++ b/tests/SelfTest/Baselines/automake.sw.approved.txt
@@ -222,6 +222,7 @@ Message from section two
:test-result: PASS Tracker
:test-result: PASS Trim strings
:test-result: FAIL Unexpected exceptions can be translated
+:test-result: PASS Upcasting special member functions
:test-result: PASS Usage of the SizeIs range matcher
:test-result: PASS Use a custom approx
:test-result: PASS Variadic macros
@@ -268,6 +269,7 @@ loose text artifact
:test-result: PASS long long
:test-result: FAIL looped SECTION tests
:test-result: FAIL looped tests
+:test-result: PASS make_unique reimplementation
:test-result: PASS mean
:test-result: PASS measure
:test-result: FAIL mix info, unscoped info and warning
@@ -331,6 +333,7 @@ loose text artifact
:test-result: PASS tuple<string,string>
:test-result: PASS tuple<tuple<int>,tuple<>,float>
:test-result: PASS uniform samples
+:test-result: PASS unique_ptr reimplementation: basic functionality
:test-result: PASS vec<vec<string,alloc>> -> toString
:test-result: PASS vector<bool> -> toString
:test-result: PASS vector<int,allocator> -> toString
diff --git a/tests/SelfTest/Baselines/compact.sw.approved.txt b/tests/SelfTest/Baselines/compact.sw.approved.txt
index 4d2fcbe2..d7a756f4 100644
--- a/tests/SelfTest/Baselines/compact.sw.approved.txt
+++ b/tests/SelfTest/Baselines/compact.sw.approved.txt
@@ -1587,6 +1587,8 @@ StringManip.tests.cpp:<line number>: passed: trim(StringRef(whitespace_at_both_e
==
There is no extra whitespace here
Exception.tests.cpp:<line number>: failed: unexpected exception with message: '3.14'
+UniquePtr.tests.cpp:<line number>: passed: bptr->i == 3 for: 3 == 3
+UniquePtr.tests.cpp:<line number>: passed: bptr->i == 3 for: 3 == 3
MatchersRanges.tests.cpp:<line number>: passed: empty_vec, SizeIs(0) for: { } has size == 0
MatchersRanges.tests.cpp:<line number>: passed: empty_vec, !SizeIs(2) for: { } not has size == 2
MatchersRanges.tests.cpp:<line number>: passed: empty_vec, SizeIs(Lt(2)) for: { } size matches is less than 2
@@ -1794,6 +1796,9 @@ Misc.tests.cpp:<line number>: failed: ( fib[i] % 2 ) == 0 for: 1 == 0 with 1 mes
Misc.tests.cpp:<line number>: passed: ( fib[i] % 2 ) == 0 for: 0 == 0 with 1 message: 'Testing if fib[5] (8) is even'
Misc.tests.cpp:<line number>: failed: ( fib[i] % 2 ) == 0 for: 1 == 0 with 1 message: 'Testing if fib[6] (13) is even'
Misc.tests.cpp:<line number>: failed: ( fib[i] % 2 ) == 0 for: 1 == 0 with 1 message: 'Testing if fib[7] (21) is even'
+UniquePtr.tests.cpp:<line number>: passed: !(lval.has_moved) for: !false
+UniquePtr.tests.cpp:<line number>: passed: rval.has_moved for: true
+UniquePtr.tests.cpp:<line number>: passed: *ptr == std::tuple<int, double, int>{1, 2., 3} for: {?} == {?}
InternalBenchmark.tests.cpp:<line number>: passed: m == 19. for: 19.0 == 19.0
InternalBenchmark.tests.cpp:<line number>: passed: x == 17 for: 17 == 17
InternalBenchmark.tests.cpp:<line number>: passed: x == 23 for: 23 == 23
@@ -1990,6 +1995,29 @@ InternalBenchmark.tests.cpp:<line number>: passed: e.point == 23 for: 23.0 == 23
InternalBenchmark.tests.cpp:<line number>: passed: e.upper_bound == 23 for: 23.0 == 23
InternalBenchmark.tests.cpp:<line number>: passed: e.lower_bound == 23 for: 23.0 == 23
InternalBenchmark.tests.cpp:<line number>: passed: e.confidence_interval == 0.95 for: 0.95 == 0.95
+UniquePtr.tests.cpp:<line number>: passed: !(ptr) for: !{?}
+UniquePtr.tests.cpp:<line number>: passed: ptr.get() == 0 for: 0 == 0
+UniquePtr.tests.cpp:<line number>: passed: ptr for: {?}
+UniquePtr.tests.cpp:<line number>: passed: *ptr == 0 for: 0 == 0
+UniquePtr.tests.cpp:<line number>: passed: ptr.get() == naked_ptr for: 0x<hex digits> == 0x<hex digits>
+UniquePtr.tests.cpp:<line number>: passed: !(ptr) for: !{?}
+UniquePtr.tests.cpp:<line number>: passed: ptr.get() == 0 for: 0 == 0
+UniquePtr.tests.cpp:<line number>: passed: ptr for: {?}
+UniquePtr.tests.cpp:<line number>: passed: *ptr == 0 for: 0 == 0
+UniquePtr.tests.cpp:<line number>: passed: ptr.get() == naked_ptr for: 0x<hex digits> == 0x<hex digits>
+UniquePtr.tests.cpp:<line number>: passed: ptr for: {?}
+UniquePtr.tests.cpp:<line number>: passed: ptr.get() != 0 for: 0x<hex digits> != 0
+UniquePtr.tests.cpp:<line number>: passed: *ptr == 2 for: 2 == 2
+UniquePtr.tests.cpp:<line number>: passed: !(ptr) for: !{?}
+UniquePtr.tests.cpp:<line number>: passed: ptr.get() == 0 for: 0 == 0
+UniquePtr.tests.cpp:<line number>: passed: !(ptr1) for: !{?}
+UniquePtr.tests.cpp:<line number>: passed: ptr2 for: {?}
+UniquePtr.tests.cpp:<line number>: passed: *ptr2 == 1 for: 1 == 1
+UniquePtr.tests.cpp:<line number>: passed: !(ptr2) for: !{?}
+UniquePtr.tests.cpp:<line number>: passed: ptr1 for: {?}
+UniquePtr.tests.cpp:<line number>: passed: *ptr1 == 2 for: 2 == 2
+UniquePtr.tests.cpp:<line number>: passed: *ptr1 == 2 for: 2 == 2
+UniquePtr.tests.cpp:<line number>: passed: *ptr2 == 1 for: 1 == 1
ToStringVector.tests.cpp:<line number>: passed: ::Catch::Detail::stringify(v) == "{ }" for: "{ }" == "{ }"
ToStringVector.tests.cpp:<line number>: passed: ::Catch::Detail::stringify(v) == "{ { \"hello\" }, { \"world\" } }" for: "{ { "hello" }, { "world" } }"
==
diff --git a/tests/SelfTest/Baselines/console.std.approved.txt b/tests/SelfTest/Baselines/console.std.approved.txt
index f92173e5..ee6710d3 100644
--- a/tests/SelfTest/Baselines/console.std.approved.txt
+++ b/tests/SelfTest/Baselines/console.std.approved.txt
@@ -1380,6 +1380,6 @@ due to unexpected exception with message:
Why would you throw a std::string?
===============================================================================
-test cases: 334 | 260 passed | 70 failed | 4 failed as expected
-assertions: 1896 | 1744 passed | 131 failed | 21 failed as expected
+test cases: 337 | 263 passed | 70 failed | 4 failed as expected
+assertions: 1924 | 1772 passed | 131 failed | 21 failed as expected
diff --git a/tests/SelfTest/Baselines/console.sw.approved.txt b/tests/SelfTest/Baselines/console.sw.approved.txt
index 4123232c..450d8025 100644
--- a/tests/SelfTest/Baselines/console.sw.approved.txt
+++ b/tests/SelfTest/Baselines/console.sw.approved.txt
@@ -11548,6 +11548,30 @@ due to unexpected exception with message:
3.14
-------------------------------------------------------------------------------
+Upcasting special member functions
+ Move constructor
+-------------------------------------------------------------------------------
+UniquePtr.tests.cpp:<line number>
+...............................................................................
+
+UniquePtr.tests.cpp:<line number>: PASSED:
+ REQUIRE( bptr->i == 3 )
+with expansion:
+ 3 == 3
+
+-------------------------------------------------------------------------------
+Upcasting special member functions
+ move assignment
+-------------------------------------------------------------------------------
+UniquePtr.tests.cpp:<line number>
+...............................................................................
+
+UniquePtr.tests.cpp:<line number>: PASSED:
+ REQUIRE( bptr->i == 3 )
+with expansion:
+ 3 == 3
+
+-------------------------------------------------------------------------------
Usage of the SizeIs range matcher
Some with stdlib containers
-------------------------------------------------------------------------------
@@ -13097,6 +13121,42 @@ with message:
Testing if fib[7] (21) is even
-------------------------------------------------------------------------------
+make_unique reimplementation
+ From lvalue copies
+-------------------------------------------------------------------------------
+UniquePtr.tests.cpp:<line number>
+...............................................................................
+
+UniquePtr.tests.cpp:<line number>: PASSED:
+ REQUIRE_FALSE( lval.has_moved )
+with expansion:
+ !false
+
+-------------------------------------------------------------------------------
+make_unique reimplementation
+ From rvalue moves
+-------------------------------------------------------------------------------
+UniquePtr.tests.cpp:<line number>
+...............................................................................
+
+UniquePtr.tests.cpp:<line number>: PASSED:
+ REQUIRE( rval.has_moved )
+with expansion:
+ true
+
+-------------------------------------------------------------------------------
+make_unique reimplementation
+ Variadic constructor
+-------------------------------------------------------------------------------
+UniquePtr.tests.cpp:<line number>
+...............................................................................
+
+UniquePtr.tests.cpp:<line number>: PASSED:
+ REQUIRE( *ptr == std::tuple<int, double, int>{1, 2., 3} )
+with expansion:
+ {?} == {?}
+
+-------------------------------------------------------------------------------
mean
-------------------------------------------------------------------------------
InternalBenchmark.tests.cpp:<line number>
@@ -14486,6 +14546,186 @@ with expansion:
0.95 == 0.95
-------------------------------------------------------------------------------
+unique_ptr reimplementation: basic functionality
+ Default constructed unique_ptr is empty
+-------------------------------------------------------------------------------
+UniquePtr.tests.cpp:<line number>
+...............................................................................
+
+UniquePtr.tests.cpp:<line number>: PASSED:
+ REQUIRE_FALSE( ptr )
+with expansion:
+ !{?}
+
+UniquePtr.tests.cpp:<line number>: PASSED:
+ REQUIRE( ptr.get() == 0 )
+with expansion:
+ 0 == 0
+
+-------------------------------------------------------------------------------
+unique_ptr reimplementation: basic functionality
+ Take ownership of allocation
+-------------------------------------------------------------------------------
+UniquePtr.tests.cpp:<line number>
+...............................................................................
+
+UniquePtr.tests.cpp:<line number>: PASSED:
+ REQUIRE( ptr )
+with expansion:
+ {?}
+
+UniquePtr.tests.cpp:<line number>: PASSED:
+ REQUIRE( *ptr == 0 )
+with expansion:
+ 0 == 0
+
+UniquePtr.tests.cpp:<line number>: PASSED:
+ REQUIRE( ptr.get() == naked_ptr )
+with expansion:
+ 0x<hex digits> == 0x<hex digits>
+
+-------------------------------------------------------------------------------
+unique_ptr reimplementation: basic functionality
+ Take ownership of allocation
+ Plain reset deallocates
+-------------------------------------------------------------------------------
+UniquePtr.tests.cpp:<line number>
+...............................................................................
+
+UniquePtr.tests.cpp:<line number>: PASSED:
+ REQUIRE_FALSE( ptr )
+with expansion:
+ !{?}
+
+UniquePtr.tests.cpp:<line number>: PASSED:
+ REQUIRE( ptr.get() == 0 )
+with expansion:
+ 0 == 0
+
+-------------------------------------------------------------------------------
+unique_ptr reimplementation: basic functionality
+ Take ownership of allocation
+-------------------------------------------------------------------------------
+UniquePtr.tests.cpp:<line number>
+...............................................................................
+
+UniquePtr.tests.cpp:<line number>: PASSED:
+ REQUIRE( ptr )
+with expansion:
+ {?}
+
+UniquePtr.tests.cpp:<line number>: PASSED:
+ REQUIRE( *ptr == 0 )
+with expansion:
+ 0 == 0
+
+UniquePtr.tests.cpp:<line number>: PASSED:
+ REQUIRE( ptr.get() == naked_ptr )
+with expansion:
+ 0x<hex digits> == 0x<hex digits>
+
+-------------------------------------------------------------------------------
+unique_ptr reimplementation: basic functionality
+ Take ownership of allocation
+ Reset replaces ownership
+-------------------------------------------------------------------------------
+UniquePtr.tests.cpp:<line number>
+...............................................................................
+
+UniquePtr.tests.cpp:<line number>: PASSED:
+ REQUIRE( ptr )
+with expansion:
+ {?}
+
+UniquePtr.tests.cpp:<line number>: PASSED:
+ REQUIRE( ptr.get() != 0 )
+with expansion:
+ 0x<hex digits> != 0
+
+UniquePtr.tests.cpp:<line number>: PASSED:
+ REQUIRE( *ptr == 2 )
+with expansion:
+ 2 == 2
+
+-------------------------------------------------------------------------------
+unique_ptr reimplementation: basic functionality
+ Release releases ownership
+-------------------------------------------------------------------------------
+UniquePtr.tests.cpp:<line number>
+...............................................................................
+
+UniquePtr.tests.cpp:<line number>: PASSED:
+ CHECK_FALSE( ptr )
+with expansion:
+ !{?}
+
+UniquePtr.tests.cpp:<line number>: PASSED:
+ CHECK( ptr.get() == 0 )
+with expansion:
+ 0 == 0
+
+-------------------------------------------------------------------------------
+unique_ptr reimplementation: basic functionality
+ Move constructor
+-------------------------------------------------------------------------------
+UniquePtr.tests.cpp:<line number>
+...............................................................................
+
+UniquePtr.tests.cpp:<line number>: PASSED:
+ REQUIRE_FALSE( ptr1 )
+with expansion:
+ !{?}
+
+UniquePtr.tests.cpp:<line number>: PASSED:
+ REQUIRE( ptr2 )
+with expansion:
+ {?}
+
+UniquePtr.tests.cpp:<line number>: PASSED:
+ REQUIRE( *ptr2 == 1 )
+with expansion:
+ 1 == 1
+
+-------------------------------------------------------------------------------
+unique_ptr reimplementation: basic functionality
+ Move assignment
+-------------------------------------------------------------------------------
+UniquePtr.tests.cpp:<line number>
+...............................................................................
+
+UniquePtr.tests.cpp:<line number>: PASSED:
+ REQUIRE_FALSE( ptr2 )
+with expansion:
+ !{?}
+
+UniquePtr.tests.cpp:<line number>: PASSED:
+ REQUIRE( ptr1 )
+with expansion:
+ {?}
+
+UniquePtr.tests.cpp:<line number>: PASSED:
+ REQUIRE( *ptr1 == 2 )
+with expansion:
+ 2 == 2
+
+-------------------------------------------------------------------------------
+unique_ptr reimplementation: basic functionality
+ free swap
+-------------------------------------------------------------------------------
+UniquePtr.tests.cpp:<line number>
+...............................................................................
+
+UniquePtr.tests.cpp:<line number>: PASSED:
+ REQUIRE( *ptr1 == 2 )
+with expansion:
+ 2 == 2
+
+UniquePtr.tests.cpp:<line number>: PASSED:
+ REQUIRE( *ptr2 == 1 )
+with expansion:
+ 1 == 1
+
+-------------------------------------------------------------------------------
vec<vec<string,alloc>> -> toString
-------------------------------------------------------------------------------
ToStringVector.tests.cpp:<line number>
@@ -14792,6 +15032,6 @@ Misc.tests.cpp:<line number>
Misc.tests.cpp:<line number>: PASSED:
===============================================================================
-test cases: 334 | 244 passed | 86 failed | 4 failed as expected
-assertions: 1913 | 1744 passed | 148 failed | 21 failed as expected
+test cases: 337 | 247 passed | 86 failed | 4 failed as expected
+assertions: 1941 | 1772 passed | 148 failed | 21 failed as expected
diff --git a/tests/SelfTest/Baselines/junit.sw.approved.txt b/tests/SelfTest/Baselines/junit.sw.approved.txt
index 9c4dd7cb..839cf6e6 100644
--- a/tests/SelfTest/Baselines/junit.sw.approved.txt
+++ b/tests/SelfTest/Baselines/junit.sw.approved.txt
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuitesloose text artifact
>
- <testsuite name="<exe-name>" errors="17" failures="132" tests="1914" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
+ <testsuite name="<exe-name>" errors="17" failures="132" tests="1942" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
<properties>
<property name="filters" value="~[!nonportable]~[!benchmark]~[approvals] *"/>
<property name="random-seed" value="1"/>
@@ -1256,6 +1256,8 @@ FAILED:
Exception.tests.cpp:<line number>
</error>
</testcase>
+ <testcase classname="<exe-name>.global" name="Upcasting special member functions/Move constructor" time="{duration}"/>
+ <testcase classname="<exe-name>.global" name="Upcasting special member functions/move assignment" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Usage of the SizeIs range matcher/Some with stdlib containers" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Usage of the SizeIs range matcher/Type requires ADL found size free function" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Usage of the SizeIs range matcher/Type has size member" time="{duration}"/>
@@ -1577,6 +1579,9 @@ Testing if fib[7] (21) is even
Misc.tests.cpp:<line number>
</failure>
</testcase>
+ <testcase classname="<exe-name>.global" name="make_unique reimplementation/From lvalue copies" time="{duration}"/>
+ <testcase classname="<exe-name>.global" name="make_unique reimplementation/From rvalue moves" time="{duration}"/>
+ <testcase classname="<exe-name>.global" name="make_unique reimplementation/Variadic constructor" time="{duration}"/>
<testcase classname="<exe-name>.global" name="mean" time="{duration}"/>
<testcase classname="<exe-name>.global" name="measure" time="{duration}"/>
<testcase classname="<exe-name>.global" name="mix info, unscoped info and warning" time="{duration}"/>
@@ -1733,6 +1738,14 @@ Exception.tests.cpp:<line number>
<testcase classname="<exe-name>.global" name="tuple&lt;string,string>" time="{duration}"/>
<testcase classname="<exe-name>.global" name="tuple&lt;tuple&lt;int>,tuple&lt;>,float>" time="{duration}"/>
<testcase classname="<exe-name>.global" name="uniform samples" time="{duration}"/>
+ <testcase classname="<exe-name>.global" name="unique_ptr reimplementation: basic functionality/Default constructed unique_ptr is empty" time="{duration}"/>
+ <testcase classname="<exe-name>.global" name="unique_ptr reimplementation: basic functionality/Take ownership of allocation" time="{duration}"/>
+ <testcase classname="<exe-name>.global" name="unique_ptr reimplementation: basic functionality/Take ownership of allocation/Plain reset deallocates" time="{duration}"/>
+ <testcase classname="<exe-name>.global" name="unique_ptr reimplementation: basic functionality/Take ownership of allocation/Reset replaces ownership" time="{duration}"/>
+ <testcase classname="<exe-name>.global" name="unique_ptr reimplementation: basic functionality/Release releases ownership" time="{duration}"/>
+ <testcase classname="<exe-name>.global" name="unique_ptr reimplementation: basic functionality/Move constructor" time="{duration}"/>
+ <testcase classname="<exe-name>.global" name="unique_ptr reimplementation: basic functionality/Move assignment" time="{duration}"/>
+ <testcase classname="<exe-name>.global" name="unique_ptr reimplementation: basic functionality/free swap" time="{duration}"/>
<testcase classname="<exe-name>.global" name="vec&lt;vec&lt;string,alloc>> -> toString" time="{duration}"/>
<testcase classname="<exe-name>.global" name="vector&lt;bool> -> toString" time="{duration}"/>
<testcase classname="<exe-name>.global" name="vector&lt;int,allocator> -> toString" time="{duration}"/>
diff --git a/tests/SelfTest/Baselines/sonarqube.sw.approved.txt b/tests/SelfTest/Baselines/sonarqube.sw.approved.txt
index 42422727..2809f95b 100644
--- a/tests/SelfTest/Baselines/sonarqube.sw.approved.txt
+++ b/tests/SelfTest/Baselines/sonarqube.sw.approved.txt
@@ -180,6 +180,21 @@
<testCase name="parseEnums/One enum value" duration="{duration}"/>
<testCase name="parseEnums/Multiple enum values" duration="{duration}"/>
</file>
+ <file path="tests/<exe-name>/IntrospectiveTests/UniquePtr.tests.cpp">
+ <testCase name="Upcasting special member functions/Move constructor" duration="{duration}"/>
+ <testCase name="Upcasting special member functions/move assignment" duration="{duration}"/>
+ <testCase name="make_unique reimplementation/From lvalue copies" duration="{duration}"/>
+ <testCase name="make_unique reimplementation/From rvalue moves" duration="{duration}"/>
+ <testCase name="make_unique reimplementation/Variadic constructor" duration="{duration}"/>
+ <testCase name="unique_ptr reimplementation: basic functionality/Default constructed unique_ptr is empty" duration="{duration}"/>
+ <testCase name="unique_ptr reimplementation: basic functionality/Take ownership of allocation" duration="{duration}"/>
+ <testCase name="unique_ptr reimplementation: basic functionality/Take ownership of allocation/Plain reset deallocates" duration="{duration}"/>
+ <testCase name="unique_ptr reimplementation: basic functionality/Take ownership of allocation/Reset replaces ownership" duration="{duration}"/>
+ <testCase name="unique_ptr reimplementation: basic functionality/Release releases ownership" duration="{duration}"/>
+ <testCase name="unique_ptr reimplementation: basic functionality/Move constructor" duration="{duration}"/>
+ <testCase name="unique_ptr reimplementation: basic functionality/Move assignment" duration="{duration}"/>
+ <testCase name="unique_ptr reimplementation: basic functionality/free swap" duration="{duration}"/>
+ </file>
<file path="tests/<exe-name>/IntrospectiveTests/Xml.tests.cpp">
<testCase name="XmlEncode/normal string" duration="{duration}"/>
<testCase name="XmlEncode/empty string" duration="{duration}"/>
diff --git a/tests/SelfTest/Baselines/tap.sw.approved.txt b/tests/SelfTest/Baselines/tap.sw.approved.txt
index b28c70d4..d03b250e 100644
--- a/tests/SelfTest/Baselines/tap.sw.approved.txt
+++ b/tests/SelfTest/Baselines/tap.sw.approved.txt
@@ -3021,6 +3021,10 @@ ok {test-number} - trim(StringRef(trailing_whitespace)) == StringRef(no_whitespa
ok {test-number} - trim(StringRef(whitespace_at_both_ends)) == StringRef(no_whitespace) for: There is no extra whitespace here == There is no extra whitespace here
# Unexpected exceptions can be translated
not ok {test-number} - unexpected exception with message: '3.14'
+# Upcasting special member functions
+ok {test-number} - bptr->i == 3 for: 3 == 3
+# Upcasting special member functions
+ok {test-number} - bptr->i == 3 for: 3 == 3
# Usage of the SizeIs range matcher
ok {test-number} - empty_vec, SizeIs(0) for: { } has size == 0
# Usage of the SizeIs range matcher
@@ -3418,6 +3422,12 @@ ok {test-number} - ( fib[i] % 2 ) == 0 for: 0 == 0 with 1 message: 'Testing if f
not ok {test-number} - ( fib[i] % 2 ) == 0 for: 1 == 0 with 1 message: 'Testing if fib[6] (13) is even'
# looped tests
not ok {test-number} - ( fib[i] % 2 ) == 0 for: 1 == 0 with 1 message: 'Testing if fib[7] (21) is even'
+# make_unique reimplementation
+ok {test-number} - !(lval.has_moved) for: !false
+# make_unique reimplementation
+ok {test-number} - rval.has_moved for: true
+# make_unique reimplementation
+ok {test-number} - *ptr == std::tuple<int, double, int>{1, 2., 3} for: {?} == {?}
# mean
ok {test-number} - m == 19. for: 19.0 == 19.0
# measure
@@ -3742,6 +3752,52 @@ ok {test-number} - e.upper_bound == 23 for: 23.0 == 23
ok {test-number} - e.lower_bound == 23 for: 23.0 == 23
# uniform samples
ok {test-number} - e.confidence_interval == 0.95 for: 0.95 == 0.95
+# unique_ptr reimplementation: basic functionality
+ok {test-number} - !(ptr) for: !{?}
+# unique_ptr reimplementation: basic functionality
+ok {test-number} - ptr.get() == 0 for: 0 == 0
+# unique_ptr reimplementation: basic functionality
+ok {test-number} - ptr for: {?}
+# unique_ptr reimplementation: basic functionality
+ok {test-number} - *ptr == 0 for: 0 == 0
+# unique_ptr reimplementation: basic functionality
+ok {test-number} - ptr.get() == naked_ptr for: 0x<hex digits> == 0x<hex digits>
+# unique_ptr reimplementation: basic functionality
+ok {test-number} - !(ptr) for: !{?}
+# unique_ptr reimplementation: basic functionality
+ok {test-number} - ptr.get() == 0 for: 0 == 0
+# unique_ptr reimplementation: basic functionality
+ok {test-number} - ptr for: {?}
+# unique_ptr reimplementation: basic functionality
+ok {test-number} - *ptr == 0 for: 0 == 0
+# unique_ptr reimplementation: basic functionality
+ok {test-number} - ptr.get() == naked_ptr for: 0x<hex digits> == 0x<hex digits>
+# unique_ptr reimplementation: basic functionality
+ok {test-number} - ptr for: {?}
+# unique_ptr reimplementation: basic functionality
+ok {test-number} - ptr.get() != 0 for: 0x<hex digits> != 0
+# unique_ptr reimplementation: basic functionality
+ok {test-number} - *ptr == 2 for: 2 == 2
+# unique_ptr reimplementation: basic functionality
+ok {test-number} - !(ptr) for: !{?}
+# unique_ptr reimplementation: basic functionality
+ok {test-number} - ptr.get() == 0 for: 0 == 0
+# unique_ptr reimplementation: basic functionality
+ok {test-number} - !(ptr1) for: !{?}
+# unique_ptr reimplementation: basic functionality
+ok {test-number} - ptr2 for: {?}
+# uniq