diff options
author | Murray Cumming <murrayc@murrayc.com> | 2016-01-14 09:20:35 +0100 |
---|---|---|
committer | Murray Cumming <murrayc@murrayc.com> | 2016-01-14 09:27:00 +0100 |
commit | 5ee84d9e6bc80cf9f9c818c216ed369652d16310 (patch) | |
tree | f12e1f56a46a2b78ef57c82cb555fd3705214fc5 | |
parent | c950bf5fb64c4903f404f6795abd919176410986 (diff) | |
download | sigc++-5ee84d9e6bc80cf9f9c818c216ed369652d16310.tar.gz |
tests: Use = delete instead of private constructors.
To make classes non-copyable.
-rw-r--r-- | tests/test_bind.cc | 13 | ||||
-rw-r--r-- | tests/test_bind_ref.cc | 14 | ||||
-rw-r--r-- | tests/testutilities.h | 13 |
3 files changed, 28 insertions, 12 deletions
diff --git a/tests/test_bind.cc b/tests/test_bind.cc index 10840a0..3ab7cf6 100644 --- a/tests/test_bind.cc +++ b/tests/test_bind.cc @@ -71,15 +71,20 @@ void egon(std::string& str) struct book : public sigc::trackable { book(const std::string& name) : name_(name) {} + + //non-copyable: + book(const book&) = delete; + book& operator=(const book&) = delete; + + //non movable: + book(book&&) = delete; + book& operator=(book&&) = delete; + std::string& get_name() { return name_; } operator std::string& () { return get_name(); } private: std::string name_; - - //non-copyable: - book(const book&); - book& operator=(const book&); }; } // end anonymous namespace diff --git a/tests/test_bind_ref.cc b/tests/test_bind_ref.cc index c30239e..d8ea53b 100644 --- a/tests/test_bind_ref.cc +++ b/tests/test_bind_ref.cc @@ -16,12 +16,16 @@ public: : name_(name) {} - std::string name_; + //non-copyable, + //so it can only be used with sigc::bind() via sigc::ref() + Param(const Param&) = delete; + Param& operator=(const Param&) = delete; + + //non movable: + Param(Param&&) = delete; + Param& operator=(Param&&) = delete; -private: - //non-copyable, so it can only be used with sigc::bind() via std::ref() - Param(const Param&); - Param& operator=(const Param&); + std::string name_; }; void handler(Param& param) diff --git a/tests/testutilities.h b/tests/testutilities.h index bb7a9a7..f06d6d9 100644 --- a/tests/testutilities.h +++ b/tests/testutilities.h @@ -24,6 +24,15 @@ class TestUtilities { public: + + // Non-copyable: + TestUtilities(const TestUtilities&) = delete; + TestUtilities& operator=(const TestUtilities&) = delete; + + // Non-movable: + TestUtilities(TestUtilities&&) = delete; + TestUtilities& operator=(TestUtilities&&) = delete; + static TestUtilities* get_instance(); bool check_command_args(int argc, char* argv[]); void check_result(std::ostringstream& result_stream, const std::string& expected_result); @@ -35,9 +44,7 @@ public: static bool get_result_and_delete_instance(); private: - // Not copyable. These are not implemented. - TestUtilities(const TestUtilities&); - TestUtilities& operator=(const TestUtilities&); + TestUtilities(); |