Exemple #1
0
        public void Test()
        {
            object       x = "foo";
            HeapObject **h = Runtime.GetHeapObject(ref x);

            RAssert.HeapObject(ref x, h);

            string         s      = "foo";
            StringObject **strObj = Runtime.GetStringObject(ref s);

            RAssert.StringObject(ref s, strObj);

            int[]         arr    = { 1, 2, 3 };
            ArrayObject **arrObj = Runtime.GetArrayObject(ref arr);

            RAssert.ArrayObject(ref arr, arrObj);

            s += " bar";
            Assert.That(s.Length, Is.EqualTo((**strObj).Length));
        }
Exemple #2
0
        public void Test()
        {
            string           s      = "foo";
            Pointer <string> strPtr = new Pointer <string>(ref s);

            Assert.That(strPtr.Value, Is.EqualTo(s));

            Pointer <string> strPtr2 = new Pointer <string>(ref s);

            Debug.Assert(strPtr == strPtr2);

            string[]         arr     = { "", "foo", "anime" };
            Pointer <string> strPtr3 = Unsafe.AddressOfHeap(ref arr, OffsetType.ArrayData);

            RAssert.Elements(strPtr3, arr);
            strPtr3 -= 3;
            Debug.Assert(strPtr3.Value == arr[0]);
            strPtr3++;
            Debug.Assert(strPtr3.Value == arr[1]);

            RAssert.Pressure(strPtr, ref s);
            RAssert.Pressure(strPtr2, ref s);
        }