From 46258b4ba784b2c44611da0d4081ddfa88e8b42a Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Mon, 9 Dec 2024 20:47:01 +0100 Subject: [PATCH 1/3] don't test for large inputs twice --- .../tests/ArraySinglePrimitiveRecordTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Formats.Nrbf/tests/ArraySinglePrimitiveRecordTests.cs b/src/libraries/System.Formats.Nrbf/tests/ArraySinglePrimitiveRecordTests.cs index 7ef801808e4e95..db32a9a4c6e094 100644 --- a/src/libraries/System.Formats.Nrbf/tests/ArraySinglePrimitiveRecordTests.cs +++ b/src/libraries/System.Formats.Nrbf/tests/ArraySinglePrimitiveRecordTests.cs @@ -20,7 +20,7 @@ public NonSeekableStream(byte[] buffer) : base(buffer) { } public static IEnumerable GetCanReadArrayOfAnySizeArgs() { - foreach (int size in new[] { 1, 127, 128, 512_001, 512_001 }) + foreach (int size in new[] { 1, 127, 128, 512_001 }) { yield return new object[] { size, true }; yield return new object[] { size, false }; From bc259f6c04cf0a88746a1f3e7dc0b8db3c12e2a8 Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Mon, 9 Dec 2024 21:18:08 +0100 Subject: [PATCH 2/3] skip the most time-consuming test case for non-Release builds --- .../tests/ArraySinglePrimitiveRecordTests.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/libraries/System.Formats.Nrbf/tests/ArraySinglePrimitiveRecordTests.cs b/src/libraries/System.Formats.Nrbf/tests/ArraySinglePrimitiveRecordTests.cs index db32a9a4c6e094..b3ccfb4fe8d181 100644 --- a/src/libraries/System.Formats.Nrbf/tests/ArraySinglePrimitiveRecordTests.cs +++ b/src/libraries/System.Formats.Nrbf/tests/ArraySinglePrimitiveRecordTests.cs @@ -23,7 +23,12 @@ public static IEnumerable GetCanReadArrayOfAnySizeArgs() foreach (int size in new[] { 1, 127, 128, 512_001 }) { yield return new object[] { size, true }; - yield return new object[] { size, false }; + + // It's the most time-consuming test case, skip it for the non-Release builds. + if (size != 512_001 || PlatformDetection.IsReleaseRuntime) + { + yield return new object[] { size, false }; + } } } From 45c6a6aeacd80f85e11b8f4302962c5299a60e19 Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Wed, 11 Dec 2024 17:15:39 +0100 Subject: [PATCH 3/3] apply suggestion from the code review --- .../tests/ArraySinglePrimitiveRecordTests.cs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/libraries/System.Formats.Nrbf/tests/ArraySinglePrimitiveRecordTests.cs b/src/libraries/System.Formats.Nrbf/tests/ArraySinglePrimitiveRecordTests.cs index b3ccfb4fe8d181..9f714c9dddac15 100644 --- a/src/libraries/System.Formats.Nrbf/tests/ArraySinglePrimitiveRecordTests.cs +++ b/src/libraries/System.Formats.Nrbf/tests/ArraySinglePrimitiveRecordTests.cs @@ -20,15 +20,10 @@ public NonSeekableStream(byte[] buffer) : base(buffer) { } public static IEnumerable GetCanReadArrayOfAnySizeArgs() { - foreach (int size in new[] { 1, 127, 128, 512_001 }) + foreach (int size in new[] { 1, 127, 128, 20_001 }) { yield return new object[] { size, true }; - - // It's the most time-consuming test case, skip it for the non-Release builds. - if (size != 512_001 || PlatformDetection.IsReleaseRuntime) - { - yield return new object[] { size, false }; - } + yield return new object[] { size, false }; } }