Test for negative offset passed to ArrayWithOffset
authorJan Kotas <jkotas@microsoft.com>
Sun, 20 Jan 2019 00:50:37 +0000 (16:50 -0800)
committerdanmosemsft <danmose@microsoft.com>
Thu, 24 Jan 2019 04:30:54 +0000 (20:30 -0800)
Fixes dotnet/corefx#34699

Commit migrated from https://github.com/dotnet/corefx/commit/6168758a66ad6bb9584305eccee8b1601299ef03

src/libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/ArrayWithOffsetTests.cs

index 4f1059d..c6d5844 100644 (file)
@@ -12,7 +12,6 @@ namespace System.Runtime.InteropServices.Tests
         public static IEnumerable<object[]> Ctor_Array_Offset_TestData()
         {
             yield return new object[] { null, 0, 0 };
-            yield return new object[] { new int[2], -1, 8 };
             yield return new object[] { new int[2], 2, 8 };
             yield return new object[] { new int[2], 3, 8 };
             yield return new object[] { new byte[4], 1, 4 };
@@ -44,6 +43,8 @@ namespace System.Runtime.InteropServices.Tests
         [InlineData(null, -1)]
         [InlineData(null, 1)]
         [InlineData(new int[] { 1 }, 5)]
+        [InlineData(new int[] { 2 }, -1)]
+        [SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "The fix was made in coreclr that is not in netfx. See https://github.com/dotnet/corefx/issues/34699")]
         public void Ctor_InvalidOffset_ThrowsIndexOutOfRangeException(object array, int offset)
         {
             Assert.Throws<IndexOutOfRangeException>(() => new ArrayWithOffset(array, offset));