From e030b1d56785405cb35531758d603be88af9b487 Mon Sep 17 00:00:00 2001 From: Neil Date: Fri, 29 Jul 2022 11:16:28 +1000 Subject: Apply rule-of-zero to delete standard methods where possible as handled by contained types. This allows flexibility as most lower-level data types can be moved and SplitVector and Partitioning of non-move-only types may be copied. CellBuffer still needs destructor due to incomplete type so retains all standard operations. --- test/unit/testSparseVector.cxx | 45 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'test/unit/testSparseVector.cxx') diff --git a/test/unit/testSparseVector.cxx b/test/unit/testSparseVector.cxx index 763fa027c..3a784d4c2 100644 --- a/test/unit/testSparseVector.cxx +++ b/test/unit/testSparseVector.cxx @@ -27,6 +27,51 @@ using namespace Scintilla::Internal; // Test SparseVector. +using UniqueInt = std::unique_ptr; + +TEST_CASE("CompileCopying SparseVector") { + + // These are compile-time tests to check that basic copy and move + // operations are defined correctly. + + SECTION("CopyingMoving") { + SparseVector s; + SparseVector s2; + + // Copy constructor + SparseVector sa(s); + // Copy assignment + SparseVector sb; + sb = s; + + // Move constructor + SparseVector sc(std::move(s)); + // Move assignment + SparseVector sd; + sd = (std::move(s2)); + } + + SECTION("MoveOnly") { + SparseVector s; + +#if defined(SHOW_COPY_BUILD_FAILURES) + // Copy is not defined for std::unique_ptr + // Copy constructor fails + SparseVector sa(s); + // Copy assignment fails + SparseVector sb; + sb = s; +#endif + + // Move constructor + SparseVector sc(std::move(s)); + // Move assignment + SparseVector sd; + sd = (std::move(s)); + } + +} + // Helper to produce a string representation of a SparseVector // to simplify checks. static std::string Representation(const SparseVector &st) { -- cgit v1.2.3