コード例 #1
0
        public void JaggedArrayEnumSorter_Sort_ArgumentNullException_Test()
        {
            var arr = new int[2][] {
                new [] { 12, 9, 6 },
                new [] { 6, -1, -2 },
            };

            Assert.Throws <ArgumentNullException>(() => JaggedArrayEnumSorter.Sort(null, (a, b) => a > b));
            Assert.Throws <ArgumentNullException>(() => JaggedArrayEnumSorter.Sort(arr, null));
        }
コード例 #2
0
        public void JaggedArrayEnumSorter_Sort_ByDescending_Test()
        {
            var arr = new int[4][] {
                new [] { 1, 0, 2, 9, 6, 4, -3, 12 },
                new [] { -1, 20, -2, 7, 6, -4, -3, 22 },
                new [] { 11, 0, -2, 19, 26, -4, 3, 0 },
                new [] { 21, -10, 52, -9, 16, 4, -13, -2 }
            };
            var expectedArr = new int[4][] {
                new [] { 12, 9, 6, 4, 2, 1, 0, -3 },
                new [] { 22, 20, 7, 6, -1, -2, -3, -4 },
                new [] { 26, 19, 11, 3, 0, 0, -2, -4 },
                new [] { 52, 21, 16, 4, -2, -9, -10, -13 }
            };

            JaggedArrayEnumSorter.Sort(arr, (a, b) => a < b);

            Assert.AreEqual(expectedArr, arr);
        }