From: Stephen Toub Date: Wed, 6 May 2020 11:54:17 +0000 (-0400) Subject: Remove duplicate tests from System.Linq.Tests (#35840) X-Git-Tag: submit/tizen/20210909.063632~8160 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ee2355c801d892f2894b0f7b14a20e6cc50e0e54;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Remove duplicate tests from System.Linq.Tests (#35840) --- diff --git a/src/libraries/System.Linq/tests/ToArrayTests.cs b/src/libraries/System.Linq/tests/ToArrayTests.cs index c6489ea..07acb51 100644 --- a/src/libraries/System.Linq/tests/ToArrayTests.cs +++ b/src/libraries/System.Linq/tests/ToArrayTests.cs @@ -332,9 +332,7 @@ namespace System.Linq.Tests } [Theory] - [MemberData(nameof(JustBelowPowersOfTwoLengths))] - [MemberData(nameof(PowersOfTwoLengths))] - [MemberData(nameof(JustAbovePowersOfTwoLengths))] + [MemberData(nameof(ToArrayShouldWorkWithSpecialLengthLazyEnumerables_MemberData))] public void ToArrayShouldWorkWithSpecialLengthLazyEnumerables(int length) { Debug.Assert(length >= 0); @@ -371,34 +369,17 @@ namespace System.Linq.Tests Assert.Equal(new[] { Enum1.First, Enum1.Second, Enum1.Third }, castArray); } - public static IEnumerable JustBelowPowersOfTwoLengths() + public static IEnumerable ToArrayShouldWorkWithSpecialLengthLazyEnumerables_MemberData() { - return SmallPowersOfTwo.Select(p => new object[] { p - 1 }); - } - - public static IEnumerable PowersOfTwoLengths() - { - return SmallPowersOfTwo.Select(p => new object[] { p }); - } - - public static IEnumerable JustAbovePowersOfTwoLengths() - { - return SmallPowersOfTwo.Select(p => new object[] { p + 1 }); - } - - private static IEnumerable SmallPowersOfTwo - { - get + // Return array sizes that should be small enough not to OOM + const int MaxPower = 18; + yield return new object[] { 1 }; + yield return new object[] { 2 }; + for (int i = 2; i <= MaxPower; i++) { - // By N being "small" we mean that allocating an array of - // size N doesn't come close to the risk of causing an OOME - - const int MaxPower = 18; - - for (int i = 0; i <= MaxPower; i++) - { - yield return 1 << i; // equivalent to pow(2, i) - } + yield return new object[] { (i << i) - 1 }; + yield return new object[] { (i << i) }; + yield return new object[] { (i << i) + 1 }; } } }