예제 #1
0
        public void BinarySearch_Test_Match_Found()
        {
            int[] input = Prime.PrimeNumber(1000).ToArray();

            int itemToBeSearched = 911;

            Algorithm.Search.JumpSearch search = new Algorithm.Search.JumpSearch(input);

            int expectedIndex = 155;

            int actualIndex = search.Search(itemToBeSearched);

            Assert.AreEqual(expectedIndex, actualIndex);
        }
예제 #2
0
        public void JumpSearch_Test_No_Match()
        {
            int[] input = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };

            int itemToBeSearched = 11;

            Algorithm.Search.JumpSearch search = new Algorithm.Search.JumpSearch(input);

            int expectedIndex = -1;

            int actualIndex = search.Search(itemToBeSearched);

            Assert.AreEqual(expectedIndex, actualIndex);
        }