Skip to content

Commit 5a4fbfa

Browse files
committed
Tests for lsd
1 parent 4dccd24 commit 5a4fbfa

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

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

0 commit comments

Comments
 (0)