public override void nComparacionesVectoresIntDescendente() { QuickSortInt = new QuickSort(Orden.Descendente); datosInt10.insertaAleatorio(); QuickSortInt.Ordenar((int[])datosInt10.Vector); int numComparaciones10 = QuickSortInt.NComparaciones; datosInt1000.insertaAleatorio(); QuickSortInt.Ordenar((int[])datosInt1000.Vector); int numComparaciones1000 = QuickSortInt.NComparaciones; Assert.True(numComparaciones1000 > numComparaciones10); }
public override void TestOrdenaInversoDescToAscInt() { QuickSortInt = new QuickSort(Orden.Descendente); datosIntDescendente.insertaAleatorio(); QuickSortInt.Ordenar((int[])datosIntDescendente.Vector); QuickSortInt.Orden = Orden.Ascendente; QuickSortInt.Ordenar((int[])datosIntDescendente.Vector); for (int i = 1; i < datosIntDescendente.Vector.Length; i++) { Assert.True((int)datosIntDescendente.Vector.GetValue(i) >= (int)datosIntDescendente.Vector.GetValue(i - 1)); } }
public void QuickSortTest() { int[][] testArrs = { new int[0], new int[] { 1, 2, 3, 4, 5 }, new int[] { 5, 4, 3, 2, 1 }, new int[] { 1, 1,1 }, new int[] { 3, 7, 1, 9,20, -4 } }; foreach (int[] arr in testArrs) { int[] expected = new int[arr.Length]; Array.Copy(arr, expected, arr.Length); Array.Sort(expected); QuickSort.Sort(arr); Assert.AreEqual(expected, arr); } }
public void SortTestArgumentNull() { Assert.Throws(typeof(ArgumentNullException), () => { MergeSort.Sort(null); }); Assert.Throws(typeof(ArgumentNullException), () => { QuickSort.Sort(null); }); }