public void TestIsLocalMax1() { bool localMax = CheckIfElementIsLocalMax.IsLocalMax(new int[] { 1, 5, 7, 6, 9, 90, 234, -346 }, 6); bool expectedAnswer = true; Assert.AreEqual(expectedAnswer, localMax); }
public void TestIsLocalMax4() { bool localMax = CheckIfElementIsLocalMax.IsLocalMax(new int[] { 1, 5 }, 0); bool expectedAnswer = false; Assert.AreEqual(expectedAnswer, localMax); }
public static int GetIndexOfFirstLocalMax <T>(T[] array) where T : IComparable <T> { if (array == null || array.Length == 0) { throw new ArgumentException("The array is null or empty."); } int n = array.Length; for (int i = 0; i < n; i++) { if (CheckIfElementIsLocalMax.IsLocalMax(array, i)) { return(i); } } return(-1); }
public void TestIsLocalMax6_ThrowsException() { bool localMax = CheckIfElementIsLocalMax.IsLocalMax((int[])null, 1); Assert.Fail(); }
public void TestIsLocalMax5_ThrowsException() { bool localMax = CheckIfElementIsLocalMax.IsLocalMax(new int[0], 25); Assert.Fail(); }
public void TestIsLocalMax3_ThrowsException() { bool localMax = CheckIfElementIsLocalMax.IsLocalMax(new int[] { 1, 5 }, 10); Assert.Fail(); }