From 1b68d1205885e79c37d228279ba8be1d6266b5f7 Mon Sep 17 00:00:00 2001 From: Georgiy Date: Mon, 25 Apr 2022 21:26:46 +0500 Subject: [PATCH] Fixes #41234 (#41376) *Added tests for sorting arrays *Separated tests for integer from string *Added comments for integers and strings --- .../System.Runtime/tests/System/ArrayTests.cs | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/libraries/System.Runtime/tests/System/ArrayTests.cs b/src/libraries/System.Runtime/tests/System/ArrayTests.cs index 372a4b3416388..5f436c6da3c5a 100644 --- a/src/libraries/System.Runtime/tests/System/ArrayTests.cs +++ b/src/libraries/System.Runtime/tests/System/ArrayTests.cs @@ -3331,34 +3331,44 @@ public static IEnumerable Sort_Array_TestData() public static IEnumerable Sort_SZArray_TestData() { + // Int yield return new object[] { new int[0], 0, 0, new IntegerComparer(), new int[0] }; yield return new object[] { new int[] { 5 }, 0, 1, new IntegerComparer(), new int[] { 5 } }; yield return new object[] { new int[] { 5, 2 }, 0, 2, new IntegerComparer(), new int[] { 2, 5 } }; yield return new object[] { new int[] { 5, 2, 9, 8, 4, 3, 2, 4, 6 }, 0, 9, new IntegerComparer(), new int[] { 2, 2, 3, 4, 4, 5, 6, 8, 9 } }; yield return new object[] { new int[] { 5, 2, 9, 8, 4, 3, 2, 4, 6 }, 3, 4, new IntegerComparer(), new int[] { 5, 2, 9, 2, 3, 4, 8, 4, 6 } }; yield return new object[] { new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 }, 0, 9, new IntegerComparer(), new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 } }; - yield return new object[] { new int[] { 5, 2, 9, 8, 4, 3, 2, 4, 6 }, 0, 9, null, new int[] { 2, 2, 3, 4, 4, 5, 6, 8, 9 } }; yield return new object[] { new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 }, 0, 9, null, new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 } }; - yield return new object[] { new int[] { 5, 2, 9, 8, 4, 3, 2, 4, 6 }, 0, 0, null, new int[] { 5, 2, 9, 8, 4, 3, 2, 4, 6 } }; yield return new object[] { new int[] { 5, 2, 9, 8, 4, 3, 2, 4, 6 }, 9, 0, null, new int[] { 5, 2, 9, 8, 4, 3, 2, 4, 6 } }; + yield return new object[] { new int[] { 1, 2, 3, 4 }, 0, 4, null, new int[] { 1, 2, 3, 4 } }; + yield return new object[] { new int[] { 4, 3, 2, 1 }, 0, 4, null, new int[] { 1, 2, 3, 4 } }; + yield return new object[] { new int[] { 4, 3, 2, 1 }, 1, 2, null, new int[] { 4, 2, 3, 1 } }; + yield return new object[] { new int[] { 4, 3, 2 }, 0, 3, new IntegerComparer(), new int[] { 2, 3, 4 } }; + yield return new object[] { new int[] { 4, 3, 2 }, 0, 3, null, new int[] { 2, 3, 4 } }; + // String yield return new object[] { new string[0], 0, 0, null, new string[0] }; yield return new object[] { new string[0], 0, 0, new StringComparer(), new string[0] }; yield return new object[] { new string[] { "5" }, 0, 1, null, new string[] { "5" } }; yield return new object[] { new string[] { "5" }, 0, 1, new StringComparer(), new string[] { "5" } }; yield return new object[] { new string[] { "5", "2" }, 0, 2, null, new string[] { "2", "5" } }; yield return new object[] { new string[] { "5", "2" }, 0, 2, new StringComparer(), new string[] { "2", "5" } }; + yield return new object[] { new string[] { "5", "2", "3" }, 0, 3, null, new string[] { "2", "3", "5" } }; + yield return new object[] { new string[] { "5", "2", "3"}, 0, 3, new StringComparer(), new string[] { "2", "3", "5" } }; + yield return new object[] { new string[] { "5", "2", null }, 0, 3, null, new string[] {null, "2", "5" } }; + yield return new object[] { new string[] { "5", "2", null}, 0, 3, new StringComparer(), new string[] { null, "2", "5" } }; yield return new object[] { new string[] { "5", "2", "9", "8", "4", "3", "2", "4", "6" }, 0, 9, new StringComparer(), new string[] { "2", "2", "3", "4", "4", "5", "6", "8", "9" } }; yield return new object[] { new string[] { "5", null, "2", "9", "8", "4", "3", "2", "4", "6" }, 0, 10, new StringComparer(), new string[] { null, "2", "2", "3", "4", "4", "5", "6", "8", "9" } }; yield return new object[] { new string[] { "5", null, "2", "9", "8", "4", "3", "2", "4", "6" }, 3, 4, new StringComparer(), new string[] { "5", null, "2", "3", "4", "8", "9", "2", "4", "6" } }; yield return new object[] { new string[] { null, null, null, null, null, "foo", null, null, null, null, null, "bar", null, null, null, null, null }, 0, 17, null, new string[] { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, "bar", "foo" } }; - yield return new object[] { new int[] { 1, 2, 3, 4 }, 0, 4, null, new int[] { 1, 2, 3, 4 } }; - yield return new object[] { new int[] { 4, 3, 2, 1 }, 0, 4, null, new int[] { 1, 2, 3, 4 } }; - yield return new object[] { new int[] { 4, 3, 2, 1 }, 1, 2, null, new int[] { 4, 2, 3, 1 } }; - yield return new object[] { new int[] { 4, 3, 2 }, 0, 3, new IntegerComparer(), new int[] { 2, 3, 4 } }; - yield return new object[] { new int[] { 4, 3, 2 }, 0, 3, null, new int[] { 2, 3, 4 } }; + yield return new object[] { new string[] { null, null, null, null, null, "foo", null, null, "test", null, null, "bar", null, null, null, null, null }, 0, 17, null, new string[] { null, null, null, null, null, null, null, null, null, null, null, null, null, null, "bar", "foo", "test" } }; + yield return new object[] { new string[] { null, null, null, null, null, "foo", null, null, "test", null, null, "bar", null, null, null, null, null }, 0, 17, new StringComparer(), new string[] { null, null, null, null, null, null, null, null, null, null, null, null, null, null, "bar", "foo", "test" } }; + yield return new object[] { new string[] { null, "bns", "ici", "fvk", "xki", null, "eig", "asb", "tal", "ixn", null, "ema", "tsw", "vjg", "wjz", null, "she" }, 0, 17, null, new string[] { null, null, null, null, "asb", "bns", "eig", "ema", "fvk", "ici", "ixn", "she", "tal", "tsw", "vjg", "wjz", "xki" } }; + yield return new object[] { new string[] { null, "bns", "ici", "fvk", "xki", null, "eig", "asb", "tal", "ixn", null, "ema", "tsw", "vjg", "wjz", null, "she" }, 0, 17, new StringComparer(), new string[] { null, null, null, null, "asb", "bns", "eig", "ema", "fvk", "ici", "ixn", "she", "tal", "tsw", "vjg", "wjz", "xki" } }; + yield return new object[] { new string[] { "mpb", "jfr", "pfp", "jgi", "opx", "rzi", "cfg", "hpg", "jta", "yku", "zpo", "atd", "hhv", "vtx", "apn", "ini", "jcc" }, 0, 17, null, new string[] { "apn", "atd", "cfg", "hhv", "hpg", "ini", "jcc", "jfr", "jgi", "jta", "mpb", "opx", "pfp", "rzi", "vtx", "yku", "zpo" } }; + yield return new object[] { new string[] { "mpb", "jfr", "pfp", "jgi", "opx", "rzi", "cfg", "hpg", "jta", "yku", "zpo", "atd", "hhv", "vtx", "apn", "ini", "jcc" }, 0, 17, new StringComparer(), new string[] { "apn", "atd", "cfg", "hhv", "hpg", "ini", "jcc", "jfr", "jgi", "jta", "mpb", "opx", "pfp", "rzi", "vtx", "yku", "zpo" } }; // Byte yield return new object[] { new byte[] { 3, 5, 6, 6 }, 0, 4, null, new byte[] { 3, 5, 6, 6 } };