File tree 1 file changed +19
-0
lines changed
1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,10 @@ struct Object1 {
18
18
char Data[1 ];
19
19
};
20
20
21
+ struct Object8 {
22
+ char Data[8 ];
23
+ };
24
+
21
25
class DecoratedMallocAllocator : public MallocAllocator {
22
26
public:
23
27
int DeallocCount = 0 ;
@@ -43,4 +47,19 @@ TEST(RecyclerTest, RecycleAllocation) {
43
47
EXPECT_EQ (Allocator.DeallocCount , 2 );
44
48
}
45
49
50
+ TEST (RecyclerTest, MoveConstructor) {
51
+ DecoratedMallocAllocator Allocator;
52
+ Recycler<Object8> R;
53
+ Object8 *A1 = R.Allocate (Allocator);
54
+ Object8 *A2 = R.Allocate (Allocator);
55
+ R.Deallocate (Allocator, A1);
56
+ R.Deallocate (Allocator, A2);
57
+ Recycler<Object8> R2 (std::move (R));
58
+ Object8 *A3 = R2.Allocate (Allocator);
59
+ R2.Deallocate (Allocator, A3);
60
+ R.clear (Allocator); // Should not deallocate anything as it was moved from.
61
+ EXPECT_EQ (Allocator.DeallocCount , 0 );
62
+ R2.clear (Allocator);
63
+ EXPECT_EQ (Allocator.DeallocCount , 2 );
64
+ }
46
65
} // end anonymous namespace
You can’t perform that action at this time.
0 commit comments