Esempio n. 1
0
            internal static bool ElementsAreEqual(TestStructs.AlignedFoo[] array, byte[] rawArray, int index)
            {
                fixed(TestStructs.AlignedFoo *pArray = array)
                fixed(byte *pRaw = rawArray)
                {
                    TestStructs.AlignedFoo *pCasted = (TestStructs.AlignedFoo *)pRaw;

                    TestStructs.AlignedFoo val1 = pArray[index];
                    TestStructs.AlignedFoo val2 = pCasted[index];

                    return(val1.Equals(val2));
                }
            }
Esempio n. 2
0
            public void GenericToOwnType_Aligned(int count)
            {
                TestStructs.AlignedFoo[] source = TestStructs.AlignedFoo.CreateArray(count + 2);
                TestStructs.AlignedFoo[] dest   = new TestStructs.AlignedFoo[count + 5];

                var apSource = new Span <TestStructs.AlignedFoo>(source, 1, source.Length - 1);
                var apDest   = new Span <TestStructs.AlignedFoo>(dest, 1, dest.Length - 1);

                apSource.Slice(0, count - 1).CopyTo(apDest);

                AssertNotDefault(source, 1);
                AssertNotDefault(dest, 1);

                Assert.NotEqual(source[0], dest[0]);
                Assert.Equal(source[1], dest[1]);
                Assert.Equal(source[2], dest[2]);
                Assert.Equal(source[count - 1], dest[count - 1]);
                Assert.NotEqual(source[count], dest[count]);
            }