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/testRunStyles.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/testRunStyles.cxx')
-rw-r--r-- | test/unit/testRunStyles.cxx | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/test/unit/testRunStyles.cxx b/test/unit/testRunStyles.cxx index 92e6b9ae8..74be54dc7 100644 --- a/test/unit/testRunStyles.cxx +++ b/test/unit/testRunStyles.cxx @@ -25,6 +25,52 @@ using namespace Scintilla::Internal; // Test RunStyles. +using UniqueInt = std::unique_ptr<int>; + +TEST_CASE("CompileCopying RunStyles") { + + // These are compile-time tests to check that basic copy and move + // operations are defined correctly. + + SECTION("CopyingMoving") { + RunStyles<int, int> s; + RunStyles<int, int> s2; + + // Copy constructor + RunStyles<int, int> sa(s); + // Copy assignment fails + RunStyles<int, int> sb; + sb = s; + + // Move constructor + RunStyles<int, int> sc(std::move(s)); + // Move assignment + RunStyles<int, int> sd; + sd = (std::move(s2)); + } + +#if defined(SHOW_COPY_BUILD_FAILURES) + // It should be reasonable to instantiate RunStyles where STYLE is move-only but fails + SECTION("MoveOnly") { + RunStyles<int, UniqueInt> s; + + // Copy is not defined for std::unique_ptr + // Copy constructor fails + RunStyles<int, UniqueInt> sa(s); + // Copy assignment fails + RunStyles<int, UniqueInt> sb; + sb = s; + + // Move constructor fails + RunStyles<int, UniqueInt> sc(std::move(s)); + // Move assignment fails + RunStyles<int, UniqueInt> sd; + sd = (std::move(s)); + } +#endif + +} + namespace Scintilla::Internal { // Xcode clang 9.0 doesn't like this when in the unnamed namespace bool operator==(const FillResult<int> &fra, const FillResult<int> &frb) { return fra.changed == frb.changed && |