public void ExceptionTest() { int[][] wrongJaggedArray1 = new int[][] { new int[] { 1 }, new int[] { }, new int[] { 5, 2, 2 }, new int[] { 2, 4, 3, 1 }, new int[] { 2, 3, 3, 3 }, new int[] { 6, 9 }, }; int[][] wrongJaggedArray2 = new int[][] { new int[] { 1 }, null, new int[] { 5, 2, 2 }, new int[] { 2, 4, 3, 1 }, new int[] { 2, 3, 3, 3 }, new int[] { 6, 9 }, }; int[][] wrongJaggedArray3 = new int[][] { }; int[][] wrongJaggedArray4 = null; JaggedArraySorter.SortBySumInc(ref jaggedArray); Assert.Throws <ArgumentException>(() => JaggedArraySorter.SortByMaxElemInc(ref wrongJaggedArray1)); Assert.Throws <ArgumentNullException>(() => JaggedArraySorter.SortByMaxElemInc(ref wrongJaggedArray2)); Assert.Throws <ArgumentException>(() => JaggedArraySorter.SortByMaxElemInc(ref wrongJaggedArray3)); Assert.Throws <ArgumentNullException>(() => JaggedArraySorter.SortByMaxElemInc(ref wrongJaggedArray4)); }
public void SortBySum_IncorrectParam_ArgumentNullException() { int[][] array = new int[5][]; array[0] = new int[2] { 1, 2 }; array[1] = new int[] { 9, 7, 4, 6 }; array[2] = new int[3] { 8, 9, 10 }; array[3] = new int[] { 3, 4, 5, 6, 7 }; Assert.Throws <ArgumentNullException>(() => JaggedArraySorter.SortBySumUp(array)); }
public void MinElemIncTest() { int[][] ExpectedJaggedArray = new int[][] { new int[] { 1 }, new int[] { 1, 2, 3 }, new int[] { 2, 4, 3, 1 }, new int[] { 2, 3, 3, 3 }, new int[] { 5, 2, 2 }, new int[] { 6, 9 }, }; JaggedArraySorter.SortByMinElemInc(ref jaggedArray); Assert.AreEqual(ExpectedJaggedArray, jaggedArray); }
public void SortByMaxRowSumTestAscending() { int[][] jaggedArray = new int[3][]; jaggedArray[0] = new int[] { 1, 3, 5, 7, 9 }; jaggedArray[1] = new int[] { 0, 2, 4, 6 }; jaggedArray[2] = new int[] { 11, 22 }; int[][] resultArray = new int[3][]; resultArray[0] = new int[] { 0, 2, 4, 6 }; resultArray[1] = new int[] { 1, 3, 5, 7, 9 }; resultArray[2] = new int[] { 11, 22 }; JaggedArraySorter.SortBySumOfRowAscending(jaggedArray); for (int i = 0; i < 3; i++) { CollectionAssert.AreEqual(resultArray[i], jaggedArray[i]); } }
public void SortByMinValueDescendingTest() { int[][] jaggedArray = new int[3][]; jaggedArray[0] = new int[] { 1, 3, 5, 7, 9 }; jaggedArray[1] = new int[] { 0, 2, 4, 6 }; jaggedArray[2] = new int[] { 11, 22 }; int[][] resultArray = new int[3][]; resultArray[2] = new int[] { 0, 2, 4, 6 }; resultArray[1] = new int[] { 1, 3, 5, 7, 9 }; resultArray[0] = new int[] { 11, 22 }; JaggedArraySorter.SortByMinElemInRowDescending(jaggedArray); for (int i = 0; i < 3; i++) { CollectionAssert.AreEqual(resultArray[i], jaggedArray[i]); } }
public void SortBySumDown_CorrectParam() { int[][] actual = new int[testArray.Length][]; testArray.CopyTo(actual, 0); int[][] expected = new int[5][]; expected[0] = new int[] { 8, 9, 10 }; expected[1] = new int[] { 9, 7, 4, 6 }; expected[2] = new int[] { 3, 4, 5, 6, 7 }; expected[3] = new int[] { 1, 2 }; expected[4] = new int[] { 1 }; JaggedArraySorter.SortBySumDown(actual); CollectionAssert.AreEqual(expected, actual); }
static void Main(string[] args) { Polynomial polynomial1 = new Polynomial(new double[] { 1, 3, 5 }); Polynomial polynomial2 = new Polynomial(new double[] { 1, 1, 1 }); Polynomial smth = polynomial1 - polynomial2; smth = new Polynomial(new double[] { 1, 3, 5 }); string pol = smth.ToString(); pol += "1"; int[][] jaggedArray = new int[3][]; jaggedArray[0] = new int[] { 1, 3, 5, 7, 9 }; jaggedArray[1] = new int[] { 0, 2, 4, 6 }; jaggedArray[2] = new int[] { 11, 22 }; JaggedArraySorter.SortByMaxElemInRowAscending(jaggedArray); int[][] array = new int[2][]; array[0] = null; array[1] = null; JaggedArraySorter.SortBySumOfRowAscending(array); pol = smth.ToString(); }
public void SortByMaxRowSumArgumentEsceptionTest() { int[][] array = new int[1][]; array[0] = null; JaggedArraySorter.SortBySumOfRowAscending(array); }
public void SortByMaxRowSumNullTest() { JaggedArraySorter.SortBySumOfRowAscending(null); }
public void SortBySum_NullAsParam_ArgumentNullExeption(int[][] array) { Assert.Throws <ArgumentNullException>(() => JaggedArraySorter.SortBySumUp(array)); }