@@ -26,14 +26,15 @@ def test_move_and_copy_casts():
26
26
# The type move constructions/assignments below each get incremented: the move assignment comes
27
27
# from the type_caster load; the move construction happens when extracting that via a cast or
28
28
# loading into an argument.
29
- assert m .move_and_copy_casts (3 ) == 18
29
+ assert m .move_and_copy_casts (3 ) == 6 * 3
30
30
assert c_m .copy_assignments + c_m .copy_constructions == 0
31
31
assert c_m .move_assignments == 2
32
32
assert c_m .move_constructions >= 2
33
33
assert c_mc .alive () == 0
34
- assert c_mc .copy_assignments + c_mc .copy_constructions == 0
34
+ assert c_mc .copy_assignments == 0
35
+ assert c_mc .copy_constructions == 2
35
36
assert c_mc .move_assignments == 2
36
- assert c_mc .move_constructions >= 2
37
+ assert c_mc .move_constructions == 0
37
38
assert c_c .alive () == 0
38
39
assert c_c .copy_assignments == 2
39
40
assert c_c .copy_constructions >= 2
@@ -50,21 +51,23 @@ def test_move_and_copy_loads():
50
51
)
51
52
52
53
assert m .move_only (10 ) == 10 # 1 move, c_m
53
- assert m .move_or_copy (11 ) == 11 # 1 move, c_mc
54
+ assert m .move (10 ) == 10 # 0 move (just ref), c_mc
55
+ assert m .copy (11 ) == 11 # 1 copy, c_mc
54
56
assert m .copy_only (12 ) == 12 # 1 copy, c_c
55
- assert m .move_pair ((13 , 14 )) == 27 # 1 c_m move, 1 c_mc move
56
- assert m .move_tuple ((15 , 16 , 17 )) == 48 # 2 c_m moves, 1 c_mc move
57
+ assert m .move_pair ((13 , 14 )) == 27 # 1 c_m move, 1 c_mc copy
58
+ assert m .move_tuple ((15 , 16 , 17 )) == 48 # 2 c_m moves, 1 c_mc copy
57
59
assert m .copy_tuple ((18 , 19 )) == 37 # 2 c_c copies
58
- # Direct constructions: 2 c_m moves, 2 c_mc moves , 1 c_c copy
60
+ # Direct constructions: 2 c_m moves, 2 c_mc copies , 1 c_c copy
59
61
# Extra moves/copies when moving pairs/tuples: 3 c_m, 3 c_mc, 2 c_c
60
62
assert m .move_copy_nested ((1 , ((2 , 3 , (4 ,)), 5 ))) == 15
61
63
62
64
assert c_m .copy_assignments + c_m .copy_constructions == 0
63
65
assert c_m .move_assignments == 6
64
66
assert c_m .move_constructions == 9
65
- assert c_mc .copy_assignments + c_mc .copy_constructions == 0
66
- assert c_mc .move_assignments == 5
67
- assert c_mc .move_constructions == 8
67
+ assert c_mc .copy_assignments == 0
68
+ assert c_mc .copy_constructions == 5
69
+ assert c_mc .move_assignments == 6
70
+ assert c_mc .move_constructions == 3
68
71
assert c_c .copy_assignments == 4
69
72
assert c_c .copy_constructions == 6
70
73
assert c_m .alive () + c_mc .alive () + c_c .alive () == 0
@@ -111,8 +114,9 @@ def test_move_and_copy_load_optional():
111
114
112
115
# The extra move/copy constructions below come from the std::optional move (which has to move
113
116
# its arguments):
114
- assert m .move_optional (10 ) == 10 # c_m: 1 move assign, 2 move construct
115
- assert m .move_or_copy_optional (11 ) == 11 # c_mc: 1 move assign, 2 move construct
117
+ assert m .move_optional (10 ) == 10 # c_m: 1 move assign, +1 move construct
118
+ assert m .mc_move_optional (10 ) == 10 # c_mc: 1 move assign, +0 move construct
119
+ assert m .mc_copy_optional (11 ) == 11 # c_mc: 1 move assign, 1 copy construct
116
120
assert m .copy_optional (12 ) == 12 # c_c: 1 copy assign, 2 copy construct
117
121
# 1 move assign + move construct moves each of c_m, c_mc, 1 c_c copy
118
122
# +1 move/copy construct each from moving the tuple
@@ -122,9 +126,10 @@ def test_move_and_copy_load_optional():
122
126
assert c_m .copy_assignments + c_m .copy_constructions == 0
123
127
assert c_m .move_assignments == 2
124
128
assert c_m .move_constructions == 5
125
- assert c_mc .copy_assignments + c_mc .copy_constructions == 0
126
- assert c_mc .move_assignments == 2
127
- assert c_mc .move_constructions == 5
129
+ assert c_mc .copy_assignments == 0
130
+ assert c_mc .copy_constructions == 2
131
+ assert c_mc .move_assignments == 3
132
+ assert c_mc .move_constructions == 4
128
133
assert c_c .copy_assignments == 2
129
134
assert c_c .copy_constructions == 5
130
135
assert c_m .alive () + c_mc .alive () + c_c .alive () == 0
0 commit comments