public void TestArrayChunk_5()
        {
            int[] array = new int[] { 7, 4, 9, 1, 6, 10 };
            int[] expay = new int[] { 1, 4, 9, 7, 6, 10 };
            Assert.AreEqual(0, SortLevel.ArrayChunk(array));

            for (int i = 0; i < array.Length; i++)
            {
                Assert.AreEqual(expay[i], array[i]);
            }
        }
        public void TestArrayChunk_6()
        {
            int[] array = new int[] { 1, 3, 4, 6, 5, 2, 8 };
            int[] expay = new int[] { 1, 3, 4, 2, 5, 6, 8 };
            Assert.AreEqual(5, SortLevel.ArrayChunk(array));

            for (int i = 0; i < array.Length; i++)
            {
                Assert.AreEqual(expay[i], array[i]);
            }
        }
        public void TestArrayChunk_2()
        {
            int[] array = new int[] { 4, 3, 9, 1, 2 };
            int[] expay = new int[] { 4, 3, 2, 1, 9 };
            Assert.AreEqual(4, SortLevel.ArrayChunk(array));

            for (int i = 0; i < array.Length; i++)
            {
                Assert.AreEqual(expay[i], array[i]);
            }
        }
        public void TestArrayChunk_4()
        {
            int[] array = new int[] { 9, 6, 8, 7, 5, 4, 1, 2 };
            int[] expay = new int[] { 2, 1, 4, 5, 6, 7, 8, 9 };
            Assert.AreEqual(4, SortLevel.ArrayChunk(array));

            for (int i = 0; i < array.Length; i++)
            {
                Assert.AreEqual(expay[i], array[i]);
            }
        }
        public void TestArrayChunk_1()
        {
            int[] array = new int[] { 7, 5, 6, 4, 3, 1, 2 };
            int[] expay = new int[] { 2, 1, 3, 4, 6, 5, 7 };
            Assert.AreEqual(3, SortLevel.ArrayChunk(array));

            for (int i = 0; i < array.Length; i++)
            {
                Assert.AreEqual(expay[i], array[i]);
            }
        }
        public void ArrayChunkTest_2()
        {
            int[] array = { 8, 6, 7, 5, 4 };

            int expectedIndex = 2;

            int[] expectedArray = { 4, 5, 6, 7, 8 };

            int actualIndex = SortLevel.ArrayChunk(array);

            int[] actualArray = array;

            Assert.AreEqual(expectedIndex, actualIndex);

            Array.ForEach(actualArray, (item) => Console.Write(item + " "));
            Console.WriteLine();

            for (int i = 0; i < array.Length; i++)
            {
                Assert.AreEqual(expectedArray[i], array[i]);
            }
        }
        public void ArrayChunkTest_1()
        {
            int[] array = { 7, 5, 6, 4, 3, 1, 2 };

            int expectedIndex = 3;

            int[] expectedArray = { 2, 1, 3, 4, 6, 5, 7 };

            int actualIndex = SortLevel.ArrayChunk(array);

            int[] actualArray = array;

            Assert.AreEqual(expectedIndex, actualIndex);

            for (int i = 0; i < array.Length; i++)
            {
                Assert.AreEqual(expectedArray[i], array[i]);
            }

            Array.ForEach(actualArray, (item) => Console.Write(item + " "));
            Console.WriteLine();
        }
예제 #8
0
        public void ArrayChunkTest()
        {
            var opt = new int[] { 7, 5, 6, 4, 3, 1, 2 };

            var opt1  = new int[] { 1 };
            var opt2  = new int[] { 1, 2 };
            var opt3  = new int[] { 9, 5, 8 };
            var opt31 = new int[] { 1, 5, 8 };
            var opt4  = new int[] { 4, 6, 8, 1 };
            var opt5  = new int[] { 7, 5, 6, 4, 3, 1, 2 };

            int iii   = SortLevel.ArrayChunk(opt);
            int iii1  = SortLevel.ArrayChunk(opt1);
            int iii2  = SortLevel.ArrayChunk(opt2);
            int iii21 = SortLevel.ArrayChunk(opt31);
            int iii3  = SortLevel.ArrayChunk(opt3);
            int iii4  = SortLevel.ArrayChunk(opt4);
            int iii5  = SortLevel.ArrayChunk(opt5);

            if (iii != 3)
            {
                Assert.Fail();
            }
        }
예제 #9
0
        public static void TestArrayChunkLeftRight()
        {
            var array = new int[] { 7, 5, 6, 4, 3, 1, 2 };
            var referenceValueIndex = SortLevel.ArrayChunk(array, 0, 6);

            Assert.AreEqual(3, referenceValueIndex);
            var ethalon = new int[] { 2, 1, 3, 4, 6, 5, 7 };

            Assert.AreEqual(ethalon.Length, array.Length);
            for (int i = 0; i < array.Length; i++)
            {
                Assert.AreEqual(ethalon[i], array[i]);
            }

            var array2 = new int[] { 4, 5, 6, 7, 3, 1, 2 };
            var referenceValueIndex2 = SortLevel.ArrayChunk(array2, 0, 6);

            Assert.AreEqual(6, referenceValueIndex2);
            var ethalon2 = new int[] { 4, 5, 6, 2, 3, 1, 7 };

            Assert.AreEqual(ethalon2.Length, array2.Length);
            for (int i = 0; i < array2.Length; i++)
            {
                Assert.AreEqual(ethalon2[i], array2[i]);
            }

            var array3 = new int[] { 4, 5, 6, 3, 1, 2 };
            var referenceValueIndex3 = SortLevel.ArrayChunk(array3, 0, 5);

            Assert.AreEqual(5, referenceValueIndex3);
            var ethalon3 = new int[] { 2, 1, 3, 4, 5, 6 };

            Assert.AreEqual(ethalon3.Length, array3.Length);
            for (int i = 0; i < array3.Length; i++)
            {
                Assert.AreEqual(ethalon3[i], array3[i]);
            }

            var array4 = new int[] { 1, 3, 4, 6, 5, 2, 8 };
            var referenceValueIndex4 = SortLevel.ArrayChunk(array4, 0, 6);

            Assert.AreEqual(5, referenceValueIndex4);
            var ethalon4 = new int[] { 1, 3, 4, 2, 5, 6, 8 };

            Assert.AreEqual(ethalon4.Length, array4.Length);
            for (int i = 0; i < array4.Length; i++)
            {
                Assert.AreEqual(ethalon4[i], array4[i]);
            }

            var array5 = new int[] { 1, 2, 7, 4, 5 };
            var referenceValueIndex5 = SortLevel.ArrayChunk(array5, 0, 4);

            Assert.AreEqual(4, referenceValueIndex5);
            var ethalon5 = new int[] { 1, 2, 5, 4, 7 };

            Assert.AreEqual(ethalon5.Length, array5.Length);
            for (int i = 0; i < array5.Length; i++)
            {
                Assert.AreEqual(ethalon5[i], array5[i]);
            }

            var array6 = new int[] { 1, 2, 7, 4, 5 };
            var referenceValueIndex6 = SortLevel.ArrayChunk(array6, 1, 3);

            Assert.AreEqual(2, referenceValueIndex6);
            var ethalon6 = new int[] { 1, 2, 4, 7, 5 };

            Assert.AreEqual(ethalon6.Length, array6.Length);
            for (int i = 0; i < array6.Length; i++)
            {
                Assert.AreEqual(ethalon6[i], array6[i]);
            }
        }