Skip to content

Commit 4986e90

Browse files
committed
Tests: Add comments by uses after move.
Because we really do want to test this. We do not explicitly promise that it's safe to use moved-from libsigc++ objects, but we choose to make it safe.
1 parent 3ff8ca0 commit 4986e90

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

tests/test_signal_move.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ main(int argc, char* argv[])
3535

3636
// Test the move constructor:
3737
sigc::signal<int(int)> sig2(std::move(sig));
38-
sig(-2);
38+
sig(-2); // Test that the moved-from slot does nothing.
3939
sig2(2);
4040
util->check_result(result_stream, "foo(int 2)");
4141

4242
// Test the move assignment operator:
4343
sigc::signal<int(int)> sig3;
4444
sig3 = std::move(sig2);
45-
sig2(-3);
45+
sig2(-3); // Test that the moved-from slot does nothing.
4646
sig3(3);
4747
util->check_result(result_stream, "foo(int 3)");
4848

tests/test_slot_move.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ main(int argc, char* argv[])
4343

4444
// test move constructor:
4545
sigc::slot<void(int)> s2(std::move(s1));
46-
s1(-2);
46+
s1(-2); // Test that the moved-from slot does nothing.
4747
s2(2);
4848
util->check_result(result_stream, "foo(int 2)");
4949

5050
// test move assignment:
5151
sigc::slot<void(int)> s3;
5252
s3 = std::move(s2);
53-
s2(-3);
53+
s2(-3); // Test that the moved-from slot does nothing.
5454
s3(3);
5555
util->check_result(result_stream, "foo(int 3)");
5656

tests/test_trackable_move.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ class my_class : public sigc::trackable
2323
src.i = 0;
2424
}
2525

26-
my_class& operator=(my_class&& src)
26+
my_class& operator=(my_class&& src) noexcept
2727
{
2828
sigc::trackable::operator=(std::move(src));
2929
i = std::move(src.i);
30-
src.i = 0;
30+
src.i = 0; // Make the moved-from object zeroed. Undefined behaviour would be acceptable too.
3131
return *this;
3232
}
3333

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy