|
| 1 | +import { Timsort } from '../TimSort' |
| 2 | + |
| 3 | +test('The Timsort of the array [5, 4, 3, 2, 1] is [1, 2, 3, 4, 5]', () => { |
| 4 | + const arr = [5, 4, 3, 2, 1] |
| 5 | + const res = Timsort(arr) |
| 6 | + expect(res).toEqual([1, 2, 3, 4, 5]) |
| 7 | +}) |
| 8 | + |
| 9 | +test('The Timsort of the array [] is []', () => { |
| 10 | + const arr = [] |
| 11 | + const res = Timsort(arr) |
| 12 | + expect(res).toEqual([]) |
| 13 | +}) |
| 14 | + |
| 15 | +test('The Timsort of the array [-5, -4, -3, -2, -1] is [-5, -4, -3, -2, -1]', () => { |
| 16 | + const arr = [-5, -4, -3, -2, -1] |
| 17 | + const res = Timsort(arr) |
| 18 | + expect(res).toEqual([-5, -4, -3, -2, -1]) |
| 19 | +}) |
| 20 | + |
| 21 | +test('The Timsort of the array [9, 0, -5, -11, 3] is [-11, -5, 0, 3, 9]', () => { |
| 22 | + const arr = [9, 0, -5, -11, 3] |
| 23 | + const res = Timsort(arr) |
| 24 | + expect(res).toEqual([-11, -5, 0, 3, 9]) |
| 25 | +}) |
0 commit comments