Exemple #1
0
 public void TestSortZeroCount()
 {
     int[] arr1 = new int[0];
     int[] arr2 = new int[0];
     MyQuickSort.QuickSort <int>(arr1, 0, arr1.Length - 1);
     CollectionAssert.AreEqual(arr2, arr1);
 }
Exemple #2
0
        public void TestSortString()
        {
            string[] sarr = { "zero", "batman", "69", "sponge bob", "squere paints", "iron maiden" };
            MyQuickSort.QuickSort <string>(sarr, 0, sarr.Length - 1);
            string s1 = MakeString <string>(sarr);

            Assert.AreEqual("69 batman iron maiden sponge bob squere paints zero ", s1, null, "Sort failed");
        }
Exemple #3
0
        public void TestSortReversed()
        {
            int[] arr = { 10, 9, 8, 7, 6 };
            MyQuickSort.QuickSort <int>(arr, 0, arr.Length - 1);
            string s1 = MakeString(arr);

            Assert.AreEqual("6 7 8 9 10 ", s1, null, "Sort failed");
        }
Exemple #4
0
        public void TestSortEqual()
        {
            int[] arr = { 1, 1, 1, 1, 1 };
            MyQuickSort.QuickSort <int>(arr, 0, arr.Length - 1);
            string s1 = MakeString(arr);

            Assert.AreEqual("1 1 1 1 1 ", s1, null, "Sort failed");
        }
Exemple #5
0
        public void Does_Quick_Sort_Work_Again()
        {
            //arrange
            int[] test     = new int[] { 8, 5, 43, 78, 29, 101, 56, 91 };
            int[] expected = new int[] { 5, 8, 29, 43, 56, 78, 91, 101 };

            //act
            int[] actual = MyQuickSort.QuickSort(test);

            //assert
            Assert.Equal(expected, actual);
        }
        public void TestMethod1()
        {
            int[] myArray = { 3, 7, 8, 5, 2, 1, 9, 4, 6 };

            MyQuickSort.QuickSort(myArray, 0, myArray.Length - 1);

            Assert.AreEqual(1, myArray[0]);
            Assert.AreEqual(2, myArray[1]);
            Assert.AreEqual(3, myArray[2]);
            Assert.AreEqual(4, myArray[3]);
            Assert.AreEqual(5, myArray[4]);
            Assert.AreEqual(6, myArray[5]);
            Assert.AreEqual(7, myArray[6]);
            Assert.AreEqual(8, myArray[7]);
            Assert.AreEqual(9, myArray[8]);
        }
Exemple #7
0
        public void TestSort()
        {
            int count = 10;

            int[]  arr1 = new int[count];
            int[]  arr2 = new int[count];
            Random rand = new Random();

            for (int i = 0; i < count; i++)
            {
                arr1[i] = rand.Next(100);
                arr2[i] = arr1[i];
            }
            MyQuickSort.QuickSort <int>(arr1, 0, arr1.Length - 1);
            Array.Sort <int>(arr2);

            /*string s1 = MakeString(arr1);
             * string s2 = MakeString(arr2);
             * Assert.AreEqual(s2, s1, null, "Sort failed");*/
            CollectionAssert.AreEqual(arr2, arr1);
        }
Exemple #8
0
    public static void Main()
    {
        MyQuickSort <int> iSort = new MyQuickSort <int>(new int[] { 2, 1, 3 });

        iSort.Sort();
    }
Exemple #9
0
 public void TestSortNull()
 {
     int[] arr1 = null;
     MyQuickSort.QuickSort <int>(arr1, 0, 0);
     Assert.IsNull(arr1);
 }