Beispiel #1
0
        public void BinarySearch_ArgumentExceptionExpected_UninitializedComparer()
        {
            int[]           array    = { 4, 8, 12 };
            IComparer <int> comparer = null;

            Assert.Throws <ArgumentNullException>(() => BinarySearch.BinarySearchAlgorithm <int>(array, 8, comparer));
        }
Beispiel #2
0
        public void BinarySearch_ArgumentExceptionExpected_EmptryArray()
        {
            int[]           array    = { };
            IComparer <int> comparer = new CompareIntegers();

            Assert.Throws <ArgumentException>(() => BinarySearch.BinarySearchAlgorithm <int>(array, 3, comparer));
        }
Beispiel #3
0
        public void BinarySearch_ArgumentNullExceptionExpected_UninitializedArray()
        {
            int[]           array    = null;
            IComparer <int> comparer = new CompareIntegers();

            Assert.Throws <ArgumentNullException>(() => BinarySearch.BinarySearchAlgorithm <int>(array, 3, comparer));
        }
Beispiel #4
0
        public void BinarySearch_ExceptionExpected_ElementNotFound()
        {
            int[] array = { 4, 8, 12, 16, 89, 213, 562, 4599 };

            int targetValue = 200;

            IComparer <int> comparer = new CompareIntegers();

            Assert.Throws <Exception>(() => BinarySearch.BinarySearchAlgorithm <int>(array, targetValue, comparer));
        }
Beispiel #5
0
        public int BinarySearch_StringBinarySearch(string[] array, string targetValue)
        {
            IComparer <string> compare = new CompareStrings();

            return(BinarySearch.BinarySearchAlgorithm <string>(array, targetValue, compare));
        }
Beispiel #6
0
        public int BinarySearch_IntBinarySearch(int[] array, int targetValue)
        {
            IComparer <int> compare = new CompareIntegers();

            return(BinarySearch.BinarySearchAlgorithm <int>(array, targetValue, compare));
        }