File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
test/sorting/3-way-string-quicksort Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change 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+ } ) ;
You can’t perform that action at this time.
0 commit comments