Skip to content

Commit 7135131

Browse files
committed
tests: Use = delete instead of private constructors.
To make classes non-copyable.
1 parent eb0139a commit 7135131

File tree

3 files changed

+28
-12
lines changed

3 files changed

+28
-12
lines changed

tests/test_bind.cc

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,20 @@ void egon(std::string& str)
7070
struct book : public sigc::trackable
7171
{
7272
book(const std::string& name) : name_(name) {}
73+
74+
//non-copyable:
75+
book(const book&) = delete;
76+
book& operator=(const book&) = delete;
77+
78+
//non movable:
79+
book(book&&) = delete;
80+
book& operator=(book&&) = delete;
81+
7382
std::string& get_name() { return name_; }
7483
operator std::string& () { return get_name(); }
7584

7685
private:
7786
std::string name_;
78-
79-
//non-copyable:
80-
book(const book&);
81-
book& operator=(const book&);
8287
};
8388

8489
} // end anonymous namespace

tests/test_bind_ref.cc

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,16 @@ class Param : public sigc::trackable
1515
: name_(name)
1616
{}
1717

18-
std::string name_;
18+
//non-copyable,
19+
//so it can only be used with sigc::bind() via sigc::ref()
20+
Param(const Param&) = delete;
21+
Param& operator=(const Param&) = delete;
22+
23+
//non movable:
24+
Param(Param&&) = delete;
25+
Param& operator=(Param&&) = delete;
1926

20-
private:
21-
//non-copyable, so it can only be used with sigc::bind() via sigc::ref()
22-
Param(const Param&);
23-
Param& operator=(const Param&);
27+
std::string name_;
2428
};
2529

2630
void handler(Param& param)

tests/testutilities.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@
2424
class TestUtilities
2525
{
2626
public:
27+
28+
// Non-copyable:
29+
TestUtilities(const TestUtilities&) = delete;
30+
TestUtilities& operator=(const TestUtilities&) = delete;
31+
32+
// Non-movable:
33+
TestUtilities(TestUtilities&&) = delete;
34+
TestUtilities& operator=(TestUtilities&&) = delete;
35+
2736
static TestUtilities* get_instance();
2837
bool check_command_args(int argc, char* argv[]);
2938
void check_result(std::ostringstream& result_stream, const std::string& expected_result);
@@ -35,9 +44,7 @@ class TestUtilities
3544
static bool get_result_and_delete_instance();
3645

3746
private:
38-
// Not copyable. These are not implemented.
39-
TestUtilities(const TestUtilities&);
40-
TestUtilities& operator=(const TestUtilities&);
47+
4148

4249
TestUtilities();
4350

0 commit comments

Comments
 (0)