diff options
author | Neil <nyamatongwe@gmail.com> | 2022-07-29 11:16:28 +1000 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2022-07-29 11:16:28 +1000 |
commit | e030b1d56785405cb35531758d603be88af9b487 (patch) | |
tree | 9a428393f7963d50a0b7557e7c77ac1be37c7bb3 /test/unit/testSplitVector.cxx | |
parent | 6e6641d4733903d3c365fd9348f3656ff7000ddf (diff) | |
download | scintilla-mirror-e030b1d56785405cb35531758d603be88af9b487.tar.gz |
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.
Diffstat (limited to 'test/unit/testSplitVector.cxx')
-rw-r--r-- | test/unit/testSplitVector.cxx | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/test/unit/testSplitVector.cxx b/test/unit/testSplitVector.cxx index aa855f1b1..c836a4ffe 100644 --- a/test/unit/testSplitVector.cxx +++ b/test/unit/testSplitVector.cxx @@ -23,6 +23,53 @@ using namespace Scintilla::Internal; // Test SplitVector. +using UniqueInt = std::unique_ptr<int>; + +// Test SplitVector. + +TEST_CASE("CompileCopying SplitVector") { + + // These are compile-time tests to check that basic copy and move + // operations are defined correctly. + + SECTION("CopyingMoving") { + SplitVector<int> s; + SplitVector<int> s2; + + // Copy constructor fails + SplitVector<int> sa(s); + // Copy assignment fails + SplitVector<int> sb; + sb = s; + + // Move constructor fails + SplitVector<int> sc(std::move(s)); + // Move assignment fails + SplitVector<int> sd; + sd = (std::move(s2)); + } + + SECTION("MoveOnly") { + SplitVector<UniqueInt> s; + +#if defined(SHOW_COPY_BUILD_FAILURES) + // Copy is not defined for std::unique_ptr + // Copy constructor fails + SplitVector<UniqueInt> sa(s); + // Copy assignment fails + SplitVector<UniqueInt> sb; + sb = s; +#endif + + // Move constructor fails + SplitVector<UniqueInt> sc(std::move(s)); + // Move assignment fails + SplitVector<UniqueInt> sd; + sd = (std::move(s)); + } + +} + struct StringSetHolder { SplitVector<std::string> sa; bool Check() const noexcept { |