Ejemplo n.º 1
0
        public void SecondSearch_Test_valueExists_and_its_first_index()
        {
            //arrange
            int[] exampleArray = { 6, 9, 52, -20, 100 };

            int thirdValueToFind = -20;
            //act

            int returnedIndex3 = SortAndSearch.SecondSearch(exampleArray, thirdValueToFind);

            //assert

            Assert.AreEqual(returnedIndex3, 0, "Index algorithm = " + returnedIndex3);
        }
Ejemplo n.º 2
0
        public void SecondSearch_Test_valueNotExists()
        {
            //arrange
            int[] exampleArray = { 6, 9, 52, -20, 100 };
            int   ValueToFind  = 0;

            //act

            int returnedIndex = SortAndSearch.SecondSearch(exampleArray, ValueToFind);

            //assert

            Assert.AreEqual(returnedIndex, -1);
        }
Ejemplo n.º 3
0
        public void FirstSearch_Test_whenValueExist()
        {
            //arrange

            int[] exampleArray = { 6, 9, 52, -20, 100 };
            int   ValueToFind  = -20;

            //act

            int returnedIndex = SortAndSearch.FirstSearch(exampleArray, ValueToFind);

            //assert

            Assert.AreEqual(returnedIndex, 0);
        }
Ejemplo n.º 4
0
        public void ThirdSearch_Test_array_with_same_values()
        {
            //arrange
            int[] exampleArray = { 100, 100, 100, 100, 100, 100, 100, 100, 100 };

            int ValueToFind = 100;       // not exists
            //act


            int returnedIndex = SortAndSearch.ThirdSearch(exampleArray, ValueToFind);

            //assert

            Assert.AreEqual(returnedIndex, 0);
        }
Ejemplo n.º 5
0
        public void ThirdSearch_Test_valueNotExists()
        {
            //arrange
            int[] exampleArray = { 9, 8, 55, 3, -13, 56, 101, 2, 0, 1000 };

            int ValueToFind = 88;       // not exists
            //act


            int returnedIndex = SortAndSearch.ThirdSearch(exampleArray, ValueToFind);

            //assert

            Assert.AreEqual(returnedIndex, -1);
        }
Ejemplo n.º 6
0
        public void FirstSearch_Test_valueExists_array_of_same_values()
        {
            //arrange

            int[] exampleArray = { 100, 100, 100, 100, 100 };

            int ValueToFind = 100;
            //act

            int returnedIndex = SortAndSearch.FirstSearch(exampleArray, ValueToFind);

            //assert


            Assert.AreEqual(returnedIndex, 2);
        }
Ejemplo n.º 7
0
        public void FirstSearch_Test_valueExists_another_boundary()
        {
            //arrange

            int[] exampleArray = { 6, 9, 52, -20, 100 };

            int ValueToFind = 100;
            //act

            int returnedIndex = SortAndSearch.FirstSearch(exampleArray, ValueToFind);

            //assert


            Assert.AreEqual(returnedIndex, 4);
        }
Ejemplo n.º 8
0
        public void helpingSearch_Test_valueNotExists()
        {
            //arrange
            int[] exampleArray = { 1, 2, 3, 4, 5 };

            int searchValue = 0;
            int left        = 0;
            int right       = exampleArray.Length;
            //act

            int returnedIndex = SortAndSearch.helpingSearch(exampleArray, searchValue, left, right);

            //assert

            Assert.AreEqual(returnedIndex, -1);
        }
Ejemplo n.º 9
0
 public void TestMethod8()
 {
     string        a      = "aaabbvvtrtgfdhfdfhhhh";
     SortAndSearch ss     = new SortAndSearch();
     var           istrue = ss.FrequencySort(a);
 }