public void KnuthSequenceTest_2_3_4() { List <int> ret1_2 = SortLevel.KnuthSequence(2); List <int> ret1_3 = SortLevel.KnuthSequence(3); List <int> ret1_4 = SortLevel.KnuthSequence(4); List <int> expectedList_1 = new List <int> { 1 }; int expectedCount = 1; int actualCount2 = ret1_2.Count; int actualCount3 = ret1_3.Count; int actualCount4 = ret1_4.Count; Assert.AreEqual(expectedCount, actualCount2); Assert.AreEqual(expectedCount, actualCount3); Assert.AreEqual(expectedCount, actualCount4); for (int i = 0; i < ret1_2.Count; i++) { Assert.AreEqual(expectedList_1[i], ret1_2[i]); } for (int i = 0; i < ret1_3.Count; i++) { Assert.AreEqual(expectedList_1[i], ret1_3[i]); } for (int i = 0; i < ret1_4.Count; i++) { Assert.AreEqual(expectedList_1[i], ret1_4[i]); } }
public void KnuthSequenceTest_0_1() { List <int> ret_0 = SortLevel.KnuthSequence(0); List <int> ret_1 = SortLevel.KnuthSequence(1); List <int> expectedList_1 = new List <int> { 1 }; int expectedCount = 1; int actualCount_0 = ret_0.Count; int actualCount_1 = ret_1.Count; Assert.AreEqual(expectedCount, actualCount_0); Assert.AreEqual(expectedCount, actualCount_1); for (int i = 0; i < ret_0.Count; i++) { Assert.AreEqual(expectedList_1[i], ret_0[i]); } for (int i = 0; i < ret_1.Count; i++) { Assert.AreEqual(expectedList_1[i], ret_1[i]); } }
public static void TestKnuthSequence() { var result = SortLevel.KnuthSequence(15); var ethalon = new List <int> { 13, 4, 1 }; Assert.AreEqual(ethalon.Count, result.Count); for (int i = 0; i < result.Count; i++) { Assert.AreEqual(ethalon[i], result[i]); } }
public void TestKnuth_3() { int[] array = new int[] { 3, 2, 1, 5, 4, 1, 56, 2, 5, 6, 4, 3, 11, 20, 42 }; int[] expay = new int[] { 13, 4, 1 }; int count = 0; List <int> list = SortLevel.KnuthSequence(array.Length); foreach (Int32 n in list) { Assert.AreEqual(expay[count], n); count++; } }
public void TestKnuth_1() { int[] array = new int[] { 1 }; int[] expay = new int[] { 1 }; int count = 0; List <int> list = SortLevel.KnuthSequence(array.Length); foreach (Int32 n in list) { Assert.AreEqual(expay[count], n); count++; } }
public void TestKnuth_14() { int[] array = new int[45]; for (int i = 0; i < array.Length; i++) { array[i] = i; } int[] expay = new int[] { 40, 13, 4, 1 }; int count = 0; List <int> list = SortLevel.KnuthSequence(array.Length); foreach (Int32 n in list) { Assert.AreEqual(expay[count], n); count++; } }
public void KnuthSequenceTest_13_14_15() { List <int> ret1_1 = SortLevel.KnuthSequence(13); List <int> ret1_2 = SortLevel.KnuthSequence(14); List <int> ret1_3 = SortLevel.KnuthSequence(15); List <int> expectedList = new List <int> { 4, 1 }; List <int> expectedList2 = new List <int> { 13, 4, 1 }; int expectedCount = 2; int expectedCount2 = 3; int actualCount1 = ret1_1.Count; int actualCount2 = ret1_2.Count; int actualCount3 = ret1_3.Count; Assert.AreEqual(expectedCount, actualCount1); Assert.AreEqual(expectedCount2, actualCount2); Assert.AreEqual(expectedCount2, actualCount3); for (int i = 0; i < ret1_1.Count; i++) { Assert.AreEqual(expectedList[i], ret1_1[i]); } for (int i = 0; i < ret1_2.Count; i++) { Assert.AreEqual(expectedList2[i], ret1_2[i]); } for (int i = 0; i < ret1_3.Count; i++) { Assert.AreEqual(expectedList2[i], ret1_3[i]); } }
public void KnuthSequenceTest_from_5_to_12() { List <int> ret_5 = SortLevel.KnuthSequence(5); List <int> ret_6 = SortLevel.KnuthSequence(6); List <int> ret_7 = SortLevel.KnuthSequence(7); List <int> ret_8 = SortLevel.KnuthSequence(8); List <int> ret_9 = SortLevel.KnuthSequence(9); List <int> ret_10 = SortLevel.KnuthSequence(10); List <int> ret_11 = SortLevel.KnuthSequence(11); List <int> ret_12 = SortLevel.KnuthSequence(12); List <int> expectedList = new List <int> { 4, 1 }; int expectedCount = 2; int actualCount_5 = ret_5.Count; int actualCount_6 = ret_6.Count; int actualCount_7 = ret_7.Count; int actualCount_8 = ret_8.Count; int actualCount_9 = ret_9.Count; int actualCount_10 = ret_10.Count; int actualCount_11 = ret_11.Count; int actualCount_12 = ret_12.Count; Assert.AreEqual(expectedCount, actualCount_5); Assert.AreEqual(expectedCount, actualCount_6); Assert.AreEqual(expectedCount, actualCount_7); Assert.AreEqual(expectedCount, actualCount_8); Assert.AreEqual(expectedCount, actualCount_9); Assert.AreEqual(expectedCount, actualCount_10); Assert.AreEqual(expectedCount, actualCount_11); Assert.AreEqual(expectedCount, actualCount_12); for (int i = 0; i < ret_5.Count; i++) { Assert.AreEqual(expectedList[i], ret_5[i]); } for (int i = 0; i < ret_6.Count; i++) { Assert.AreEqual(expectedList[i], ret_6[i]); } for (int i = 0; i < ret_7.Count; i++) { Assert.AreEqual(expectedList[i], ret_7[i]); } for (int i = 0; i < ret_8.Count; i++) { Assert.AreEqual(expectedList[i], ret_8[i]); } for (int i = 0; i < ret_9.Count; i++) { Assert.AreEqual(expectedList[i], ret_9[i]); } for (int i = 0; i < ret_10.Count; i++) { Assert.AreEqual(expectedList[i], ret_10[i]); } for (int i = 0; i < ret_11.Count; i++) { Assert.AreEqual(expectedList[i], ret_11[i]); } for (int i = 0; i < ret_12.Count; i++) { Assert.AreEqual(expectedList[i], ret_12[i]); } }