File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,10 @@ struct Object1 {
1818 char Data[1 ];
1919};
2020
21+ struct Object8 {
22+ char Data[8 ];
23+ };
24+
2125class DecoratedMallocAllocator : public MallocAllocator {
2226public:
2327 int DeallocCount = 0 ;
@@ -43,4 +47,19 @@ TEST(RecyclerTest, RecycleAllocation) {
4347 EXPECT_EQ (Allocator.DeallocCount , 2 );
4448}
4549
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+ }
4665} // end anonymous namespace
You can’t perform that action at this time.
0 commit comments