|
| 1 | +import { findMaxRecursion } from '../FindMaxRecursion' |
| 2 | + |
| 3 | +describe('Test findMaxRecursion function', () => { |
| 4 | + const positiveAndNegativeArray = [1, 2, 4, 5, -1, -2, -4, -5] |
| 5 | + const positiveAndNegativeArray1 = [10, 40, 100, 20, -10, -40, -100, -20] |
| 6 | + |
| 7 | + const positiveArray = [1, 2, 4, 5] |
| 8 | + const positiveArray1 = [10, 40, 100, 20] |
| 9 | + |
| 10 | + const negativeArray = [-1, -2, -4, -5] |
| 11 | + const negativeArray1 = [-10, -40, -100, -20] |
| 12 | + |
| 13 | + const zeroArray = [0, 0, 0, 0] |
| 14 | + const emptyArray = [] |
| 15 | + |
| 16 | + it('Testing with positive arrays', () => { |
| 17 | + expect(findMaxRecursion(positiveArray, 0, positiveArray.length - 1)).toBe(5) |
| 18 | + expect(findMaxRecursion(positiveArray1, 0, positiveArray1.length - 1)).toBe( |
| 19 | + 100 |
| 20 | + ) |
| 21 | + }) |
| 22 | + |
| 23 | + it('Testing with negative arrays', () => { |
| 24 | + expect(findMaxRecursion(negativeArray, 0, negativeArray.length - 1)).toBe( |
| 25 | + -1 |
| 26 | + ) |
| 27 | + expect(findMaxRecursion(negativeArray1, 0, negativeArray1.length - 1)).toBe( |
| 28 | + -10 |
| 29 | + ) |
| 30 | + }) |
| 31 | + |
| 32 | + it('Testing with positive and negative arrays', () => { |
| 33 | + expect( |
| 34 | + findMaxRecursion( |
| 35 | + positiveAndNegativeArray, |
| 36 | + 0, |
| 37 | + positiveAndNegativeArray.length - 1 |
| 38 | + ) |
| 39 | + ).toBe(5) |
| 40 | + expect( |
| 41 | + findMaxRecursion( |
| 42 | + positiveAndNegativeArray1, |
| 43 | + 0, |
| 44 | + positiveAndNegativeArray1.length - 1 |
| 45 | + ) |
| 46 | + ).toBe(100) |
| 47 | + }) |
| 48 | + |
| 49 | + it('Testing with zero arrays', () => { |
| 50 | + expect(findMaxRecursion(zeroArray, 0, zeroArray.length - 1)).toBe(0) |
| 51 | + }) |
| 52 | + |
| 53 | + it('Testing with empty arrays', () => { |
| 54 | + expect(findMaxRecursion(emptyArray, 0, emptyArray.length - 1)).toBe( |
| 55 | + undefined |
| 56 | + ) |
| 57 | + }) |
| 58 | +}) |
0 commit comments