|
| 1 | +export const sortedArr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]; |
| 2 | +export const reverseArr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]; |
| 3 | +export const notSortedArr = [15, 8, 5, 12, 10, 1, 16, 9, 11, 7, 20, 3, 2, 6, 17, 18, 4, 13, 14, 19]; |
| 4 | +export const equalArr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]; |
| 5 | +export const negativeArr = [-1, 0, 5, -10, 20, 13, -7, 3, 2, -3]; |
| 6 | +export const negativeArrSorted = [-10, -7, -3, -1, 0, 2, 3, 5, 13, 20]; |
| 7 | + |
| 8 | +export class SortTester { |
| 9 | + static testSort(SortingClass) { |
| 10 | + const sorter = new SortingClass(); |
| 11 | + |
| 12 | + expect(sorter.sort([])).toEqual([]); |
| 13 | + expect(sorter.sort([1])).toEqual([1]); |
| 14 | + expect(sorter.sort([1, 2])).toEqual([1, 2]); |
| 15 | + expect(sorter.sort([2, 1])).toEqual([1, 2]); |
| 16 | + expect(sorter.sort([3, 4, 2, 1, 0, 0, 4, 3, 4, 2])).toEqual([0, 0, 1, 2, 2, 3, 3, 4, 4, 4]); |
| 17 | + expect(sorter.sort(sortedArr)).toEqual(sortedArr); |
| 18 | + expect(sorter.sort(reverseArr)).toEqual(sortedArr); |
| 19 | + expect(sorter.sort(notSortedArr)).toEqual(sortedArr); |
| 20 | + expect(sorter.sort(equalArr)).toEqual(equalArr); |
| 21 | + } |
| 22 | + |
| 23 | + static testNegativeNumbersSort(SortingClass) { |
| 24 | + const sorter = new SortingClass(); |
| 25 | + expect(sorter.sort(negativeArr)).toEqual(negativeArrSorted); |
| 26 | + } |
| 27 | + |
| 28 | +} |
0 commit comments