|
| 1 | +import { simplifiedWiggleSort } from '../SimplifiedWiggleSort.js' |
| 2 | + |
| 3 | +describe('simplified wiggle sort', () => { |
| 4 | + test('simplified wiggle sort for chars', () => { |
| 5 | + const src = ['a', 'b', 'c'] |
| 6 | + expect(simplifiedWiggleSort(src)).toEqual(['a', 'c', 'b']) |
| 7 | + }) |
| 8 | + |
| 9 | + test('wiggle sort with duplicates, even array', () => { |
| 10 | + const src = [2, 2, 1, 3] |
| 11 | + expect(simplifiedWiggleSort(src)).toEqual([1, 3, 2, 2]) |
| 12 | + }) |
| 13 | + |
| 14 | + test('wiggle sort with duplicates, odd array', () => { |
| 15 | + const src = [1, 1, 1, 2, 4] |
| 16 | + expect(simplifiedWiggleSort(src)).toEqual([1, 4, 1, 2, 1]) |
| 17 | + }) |
| 18 | + |
| 19 | + test('simplified wiggle sort which leads to equal values next to ' + |
| 20 | + 'each other', () => { |
| 21 | + const src = [3, 3, 5, 1] |
| 22 | + expect(simplifiedWiggleSort(src)).toEqual([1, 5, 3, 3]) |
| 23 | + }) |
| 24 | +}) |
0 commit comments