-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbucketSort.test.js
More file actions
27 lines (23 loc) · 987 Bytes
/
bucketSort.test.js
File metadata and controls
27 lines (23 loc) · 987 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const { bucketSort } = require("./bucketSort.js");
describe("bucketSort", () => {
it("works", () => {
expect(bucketSort([3, 2, 1, 5, 4, 7, 6, 5])).toEqual([
1, 2, 3, 4, 5, 5, 6, 7,
]);
expect(bucketSort([-1, -3, -4, 2, 1, 3])).toEqual([-4, -3, -1, 1, 2, 3]);
expect(bucketSort([1, 2, 3, 4, 5])).toEqual([1, 2, 3, 4, 5]);
expect(bucketSort([])).toEqual([]);
expect(bucketSort([5, 4, 3, 2, -100])).toEqual([-100, 2, 3, 4, 5]);
expect(bucketSort([1])).toEqual([1]);
});
it("works with fuzzy bucket size specified", () => {
expect(bucketSort([3, 2, 1, 5, 4, 7, 6, 5], 3)).toEqual([
1, 2, 3, 4, 5, 5, 6, 7,
]);
expect(bucketSort([-1, -3, -4, 2, 1, 3], 2)).toEqual([-4, -3, -1, 1, 2, 3]);
expect(bucketSort([1, 2, 3, 4, 5], 0)).toEqual([1, 2, 3, 4, 5]);
expect(bucketSort([], 5)).toEqual([]);
expect(bucketSort([5, 4, 3, 2, -100], 5)).toEqual([-100, 2, 3, 4, 5]);
expect(bucketSort([1], 1)).toEqual([1]);
});
});