Skip to content

Commit d6a327a

Browse files
authored
merge: Add test case and fix the OddEvenSort Algorithm (#955)
1 parent 47c1c51 commit d6a327a

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

Sorts/OddEvenSort.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,5 @@ export function oddEvenSort (arr) {
3030
}
3131
}
3232
}
33+
return arr
3334
}

Sorts/test/OddEvenSort.test.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { oddEvenSort } from '../OddEvenSort'
2+
3+
test('The OddEvenSort 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 = oddEvenSort(arr)
6+
expect(res).toEqual([1, 2, 3, 4, 5])
7+
})
8+
9+
test('The OddEvenSort of the array [] is []', () => {
10+
const arr = []
11+
const res = oddEvenSort(arr)
12+
expect(res).toEqual([])
13+
})
14+
15+
test('The OddEvenSort of the array [10, 14, 12, 20] is [10, 12, 14, 20]', () => {
16+
const arr = [10, 14, 12, 20]
17+
const res = oddEvenSort(arr)
18+
expect(res).toEqual([10, 12, 14, 20])
19+
})
20+
21+
test('The OddEvenSort of the array [166, 169, 144] is [144, 166, 169]', () => {
22+
const arr = [166, 169, 144]
23+
const res = oddEvenSort(arr)
24+
expect(res).toEqual([144, 166, 169])
25+
})

0 commit comments

Comments
 (0)