Skip to content

Commit 4aeddcf

Browse files
committed
Add tests for 3 way string quicksort
1 parent e480819 commit 4aeddcf

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
var quicksort =
2+
require('../../../src/sorting/3-way-string-quicksort/quicksort.js').quicksort;
3+
4+
describe('Most-Significant Digit', function () {
5+
'use strict';
6+
7+
it('should work with empty arrays', function () {
8+
expect(quicksort([]).length).toBe(0);
9+
});
10+
11+
it('should work with arrays with a single element', function () {
12+
var arr = ['a'];
13+
quicksort(arr);
14+
expect(arr.length).toBe(1);
15+
expect(arr[0]).toBe('a');
16+
});
17+
18+
it('should work with arrays with equally length strings', function () {
19+
var arr = ['bb', 'aa', 'cc'];
20+
quicksort(arr);
21+
expect(arr.length).toBe(3);
22+
expect(arr[0]).toBe('aa');
23+
expect(arr[1]).toBe('bb');
24+
expect(arr[2]).toBe('cc');
25+
});
26+
27+
it('should work with arrays with differently length strings', function () {
28+
var arr = ['bb', 'aaa', 'a', 'aa'];
29+
quicksort(arr);
30+
expect(arr.length).toBe(4);
31+
expect(arr[0]).toBe('a');
32+
expect(arr[1]).toBe('aa');
33+
expect(arr[2]).toBe('aaa');
34+
expect(arr[3]).toBe('bb');
35+
});
36+
});

0 commit comments

Comments
 (0)