@@ -7,6 +7,12 @@ import {
7
7
SortTester ,
8
8
} from '../../SortTester' ;
9
9
10
+ // Complexity constants.
11
+ const SORTED_ARRAY_VISITING_COUNT = 209 ;
12
+ const NOT_SORTED_ARRAY_VISITING_COUNT = 209 ;
13
+ const REVERSE_SORTED_ARRAY_VISITING_COUNT = 209 ;
14
+ const EQUAL_ARRAY_VISITING_COUNT = 209 ;
15
+
10
16
describe ( 'SelectionSort' , ( ) => {
11
17
it ( 'should sort array' , ( ) => {
12
18
SortTester . testSort ( SelectionSort ) ;
@@ -17,42 +23,34 @@ describe('SelectionSort', () => {
17
23
} ) ;
18
24
19
25
it ( 'should visit EQUAL array element specified number of times' , ( ) => {
20
- const expectedNumberOfVisits = 209 ;
21
-
22
26
SortTester . testAlgorithmTimeComplexity (
23
27
SelectionSort ,
24
28
equalArr ,
25
- expectedNumberOfVisits ,
29
+ EQUAL_ARRAY_VISITING_COUNT ,
26
30
) ;
27
31
} ) ;
28
32
29
33
it ( 'should visit SORTED array element specified number of times' , ( ) => {
30
- const expectedNumberOfVisits = 209 ;
31
-
32
34
SortTester . testAlgorithmTimeComplexity (
33
35
SelectionSort ,
34
36
sortedArr ,
35
- expectedNumberOfVisits ,
37
+ SORTED_ARRAY_VISITING_COUNT ,
36
38
) ;
37
39
} ) ;
38
40
39
41
it ( 'should visit NOT SORTED array element specified number of times' , ( ) => {
40
- const expectedNumberOfVisits = 209 ;
41
-
42
42
SortTester . testAlgorithmTimeComplexity (
43
43
SelectionSort ,
44
44
notSortedArr ,
45
- expectedNumberOfVisits ,
45
+ NOT_SORTED_ARRAY_VISITING_COUNT ,
46
46
) ;
47
47
} ) ;
48
48
49
49
it ( 'should visit REVERSE SORTED array element specified number of times' , ( ) => {
50
- const expectedNumberOfVisits = 209 ;
51
-
52
50
SortTester . testAlgorithmTimeComplexity (
53
51
SelectionSort ,
54
52
reverseArr ,
55
- expectedNumberOfVisits ,
53
+ REVERSE_SORTED_ARRAY_VISITING_COUNT ,
56
54
) ;
57
55
} ) ;
58
56
} ) ;
0 commit comments