public void CombinationCombinationTest() { var warriors = new Warrior[] { new Warrior(1), new Warrior(4), new Warrior(5), new Warrior(3), new Warrior(2), }; var listCombination = PermutationAndCombination <Warrior> .GetPermutation(warriors); foreach (var combination in listCombination) { try { //Console.WriteLine(string.Join("-", combination.Select(c => c.m_internal.ToString()))); Warrior.ResetCompareCount(); var result = WarriorSelectMedian.SelectMedian(combination); //Console.WriteLine(Warrior.CompareCount); Assert.AreSame(warriors[3], result); Assert.AreEqual(true, Warrior.CompareCount <= 6); } catch (Exception ex) { Console.WriteLine(ex.Message + string.Join("-", combination.Select(c => c.m_internal.ToString()))); //Assert.Fail(ex.Message); } } }
public void SimpleTest() { //try //{ var input = new Warrior[] { new Warrior(1), new Warrior(2), new Warrior(3), new Warrior(4), new Warrior(5), }; Warrior.ResetCompareCount(); Assert.AreSame(input[3], WarriorSelectMedian.SelectMedian(input)); Assert.AreEqual(true, Warrior.CompareCount <= 6); //} //catch (Exception ex) //{ // Assert.Fail(ex.Message); //} }