@@ -294,11 +294,25 @@ public void CopyTest()
294294 {
295295 var stack = new Tests.Struct.StackOfTestStruct(5, &memory);
296296
297+ var testClass2W = new Struct.TestClassWrapper();
297298 stack.Push(new TestStruct(45, 27, new TestClass(123, 5776)));
299+ var testStructW = new Struct.TestStructWrapper(stack.TopPtr(), false);
300+ testStructW.TestClass2 = new IntPtr(testClass2W.Ptr);
301+
298302 stack.Push(new TestStruct(13, 400, new TestClass(22, 5787)));
303+ testStructW.ChangePtr(stack.TopPtr());
304+ testStructW.TestClass2 = new IntPtr(testClass2W.Ptr);
305+
299306 stack.Push(new TestStruct(8, 85, new TestClass(711, 446)));
307+ testStructW.ChangePtr(stack.TopPtr());
308+ testStructW.TestClass2 = new IntPtr(testClass2W.Ptr);
309+
300310 stack.Push(new TestStruct(6, 84, new TestClass(756, 33)));
311+ testStructW.ChangePtr(stack.TopPtr());
312+ testStructW.TestClass2 = new IntPtr(testClass2W.Ptr);
313+
301314 stack.Push(new TestStruct(25, 46, new TestClass(7, 22)));
315+ testStructW.ChangePtr(stack.TopPtr());
302316
303317 var stack2 = new Tests.Struct.StackOfTestStruct(5, &memory2);
304318 stack.Copy(stack2.Start);
@@ -313,35 +327,41 @@ public void CopyTest()
313327 Assert.That(wrap.Int64, Is.EqualTo(wrap2.Int64));
314328 Assert.That(wrap.TestClass.Int32, Is.EqualTo(wrap2.TestClass.Int32));
315329 Assert.That(wrap.TestClass.Int64, Is.EqualTo(wrap2.TestClass.Int64));
330+ Assert.That(wrap.TestClass2, Is.EqualTo(IntPtr.Zero));
316331
317332 wrap.ChangePtr(stack[1]);
318333 wrap2.ChangePtr(stack2[1]);
319334 Assert.That(wrap.Int32, Is.EqualTo(wrap2.Int32));
320335 Assert.That(wrap.Int64, Is.EqualTo(wrap2.Int64));
321336 Assert.That(wrap.TestClass.Int32, Is.EqualTo(wrap2.TestClass.Int32));
322337 Assert.That(wrap.TestClass.Int64, Is.EqualTo(wrap2.TestClass.Int64));
338+ Assert.That(wrap.TestClass2, Is.EqualTo(new IntPtr(testClass2W.Ptr)));
323339
324340 wrap.ChangePtr(stack[2]);
325341 wrap2.ChangePtr(stack2[2]);
326342 Assert.That(wrap.Int32, Is.EqualTo(wrap2.Int32));
327343 Assert.That(wrap.Int64, Is.EqualTo(wrap2.Int64));
328344 Assert.That(wrap.TestClass.Int32, Is.EqualTo(wrap2.TestClass.Int32));
329345 Assert.That(wrap.TestClass.Int64, Is.EqualTo(wrap2.TestClass.Int64));
346+ Assert.That(wrap.TestClass2, Is.EqualTo(new IntPtr(testClass2W.Ptr)));
330347
331348 wrap.ChangePtr(stack[3]);
332349 wrap2.ChangePtr(stack2[3]);
333350 Assert.That(wrap.Int32, Is.EqualTo(wrap2.Int32));
334351 Assert.That(wrap.Int64, Is.EqualTo(wrap2.Int64));
335352 Assert.That(wrap.TestClass.Int32, Is.EqualTo(wrap2.TestClass.Int32));
336353 Assert.That(wrap.TestClass.Int64, Is.EqualTo(wrap2.TestClass.Int64));
354+ Assert.That(wrap.TestClass2, Is.EqualTo(new IntPtr(testClass2W.Ptr)));
337355
338356 wrap.ChangePtr(stack[4]);
339357 wrap2.ChangePtr(stack2[4]);
340358 Assert.That(wrap.Int32, Is.EqualTo(wrap2.Int32));
341359 Assert.That(wrap.Int64, Is.EqualTo(wrap2.Int64));
342360 Assert.That(wrap.TestClass.Int32, Is.EqualTo(wrap2.TestClass.Int32));
343361 Assert.That(wrap.TestClass.Int64, Is.EqualTo(wrap2.TestClass.Int64));
362+ Assert.That(wrap.TestClass2, Is.EqualTo(new IntPtr(testClass2W.Ptr)));
344363
364+ testClass2W.Dispose();
345365 }
346366 }
347367 }
@@ -544,20 +564,23 @@ public void IndexTest()
544564 Assert.That(wrap.Int64, Is.EqualTo(21));
545565 Assert.That(wrap.TestClass.Int32, Is.EqualTo(6));
546566 Assert.That(wrap.TestClass.Int64, Is.EqualTo(543));
567+ Assert.That(wrap.TestClass2, Is.EqualTo(IntPtr.Zero));
547568
548569 Assert.That(new IntPtr(stack[1]), Is.EqualTo(new IntPtr((byte*)memory.Start + TestStructHelper.SizeOf)));
549570 wrap.ChangePtr(stack[1]);
550571 Assert.That(wrap.Int32, Is.EqualTo(26));
551572 Assert.That(wrap.Int64, Is.EqualTo(28));
552573 Assert.That(wrap.TestClass.Int32, Is.EqualTo(5));
553574 Assert.That(wrap.TestClass.Int64, Is.EqualTo(5));
575+ Assert.That(wrap.TestClass2, Is.EqualTo(IntPtr.Zero));
554576
555577 Assert.That(new IntPtr(stack[2]), Is.EqualTo(new IntPtr((byte*)memory.Start)));
556578 wrap.ChangePtr(stack[2]);
557579 Assert.That(wrap.Int32, Is.EqualTo(78));
558580 Assert.That(wrap.Int64, Is.EqualTo(11));
559581 Assert.That(wrap.TestClass.Int32, Is.EqualTo(1));
560582 Assert.That(wrap.TestClass.Int64, Is.EqualTo(5776));
583+ Assert.That(wrap.TestClass2, Is.EqualTo(IntPtr.Zero));
561584
562585 Assert.That(() => stack[3],
563586 Throws.Exception.TypeOf(typeof(Exception))
@@ -698,7 +721,7 @@ public void TopOutTest()
698721
699722 [Test]
700723 [SkipLocalsInit]
701- public void TopRefPtrTest ()
724+ public void TopInPtrTest ()
702725 {
703726 unsafe
704727 {
@@ -760,21 +783,35 @@ public void TopRefValueTest()
760783 .And.Message.EqualTo("There are no elements on the stack")
761784 );
762785
786+ var wrapTestClass0 = new Struct.TestClassWrapper();
787+ wrapTestClass0.Int32 = 88;
788+ wrapTestClass0.Int64 = 112;
763789 stack.Push(new TestStruct(15, 10, new TestClass(8, 5)));
790+ var wrap0 = new Struct.TestStructWrapper(stack.TopPtr(), false);
791+ wrap0.TestClass2 = new IntPtr(wrapTestClass0.Ptr);
764792 var item0 = new TestStruct();
765793 stack.Top(ref item0);
766794 Assert.That(item0.Int32, Is.EqualTo(15));
767795 Assert.That(item0.Int64, Is.EqualTo(10));
768796 Assert.That(item0.TestClass.Int32, Is.EqualTo(8));
769797 Assert.That(item0.TestClass.Int64, Is.EqualTo(5));
798+ Assert.That(item0.TestClass2.Int32, Is.EqualTo(88));
799+ Assert.That(item0.TestClass2.Int64, Is.EqualTo(112));
800+ wrapTestClass0.Dispose();
770801
771802 stack.Push(new TestStruct(2, 1, new TestClass(1, 7)));
803+ wrapTestClass0.Int32 = 14;
804+ wrapTestClass0.Int64 = 45;
805+ var wrap1 = new Struct.TestStructWrapper(stack.TopPtr(), false);
806+ wrap1.TestClass2 = new IntPtr(wrapTestClass0.Ptr);
772807 var item1 = new TestStruct();
773808 stack.Top(ref item1);
774809 Assert.That(item1.Int32, Is.EqualTo(2));
775810 Assert.That(item1.Int64, Is.EqualTo(1));
776811 Assert.That(item1.TestClass.Int32, Is.EqualTo(1));
777812 Assert.That(item1.TestClass.Int64, Is.EqualTo(7));
813+ Assert.That(item1.TestClass2.Int32, Is.EqualTo(14));
814+ Assert.That(item1.TestClass2.Int64, Is.EqualTo(45));
778815 }
779816 }
780817 }
0 commit comments