Пример #1
0
        public void OnelElement_BinaryGenericSearchTest()
        {
            var arr = new double[] { 10 };

            var result = BinaryGenericSearch.Exec(arr.ToList(), 10);

            Assert.AreEqual(0, result);
        }
Пример #2
0
        public void NormUseInt_BinaryGenericSearchTest()
        {
            var arr = new int[] { 5, 8, 13, 17, 336 };

            var result = BinaryGenericSearch.Exec(arr.ToList(), 13);

            Assert.AreEqual(2, result);
        }
Пример #3
0
        public void NormUseDouble_BinaryGenericSearchTest()
        {
            var arr = new double[] { -5, 6, 7, 9, 15 };

            var result = BinaryGenericSearch.Exec(arr.ToList(), 9);

            Assert.AreEqual(3, result);
        }
Пример #4
0
        public void RepeatElements_BinaryGenericSearchTest()
        {
            var arr = new double[] { 10, 55, 88, 99, 99, 115, 158 };

            var result = BinaryGenericSearch.Exec(arr.ToList(), 99);

            Assert.AreEqual(3, result);
        }
Пример #5
0
        public void NotExisting_BinaryGenericSearchTest()
        {
            var arr = new string[] { "a", "b", "c", "d" };

            var result = BinaryGenericSearch.Exec(arr.ToList(), "e");

            Assert.AreEqual(-1, result);
        }
Пример #6
0
        public void StringValue_BinaryGenericSearchTest()
        {
            //arrange
            var arr = new string[] { "cat", "dog", "bird", "seal" };

            //act
            var result = BinaryGenericSearch.Exec(arr.ToList(), "seal");

            //assert
            Assert.AreEqual(3, result);
        }
Пример #7
0
        public void Boundary_BinaryGenericSearchTest(int searchItem, int expectedResult)
        {
            //arrange
            var arr = new int[] { 2, 3, 7, 9 };

            //act
            var result = BinaryGenericSearch.Exec(arr.ToList(), searchItem);

            //assert
            Assert.AreEqual(expectedResult, result);
        }
Пример #8
0
        public void Empty_BinaryGenericSearchTest()
        {
            var arr = new int[] { };

            Assert.ThrowsException <ArgumentOutOfRangeException>(() => BinaryGenericSearch.Exec(arr.ToList(), 1));
        }
Пример #9
0
        public void Null_BinaryGenericSearchTest()
        {
            int[] arr = null;

            Assert.ThrowsException <ArgumentNullException>(() => BinaryGenericSearch.Exec(arr.ToList(), 1));
        }