@@ -7,6 +7,12 @@ import {
77 SortTester ,
88} from '../../SortTester' ;
99
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+
1016describe ( 'SelectionSort' , ( ) => {
1117 it ( 'should sort array' , ( ) => {
1218 SortTester . testSort ( SelectionSort ) ;
@@ -17,42 +23,34 @@ describe('SelectionSort', () => {
1723 } ) ;
1824
1925 it ( 'should visit EQUAL array element specified number of times' , ( ) => {
20- const expectedNumberOfVisits = 209 ;
21-
2226 SortTester . testAlgorithmTimeComplexity (
2327 SelectionSort ,
2428 equalArr ,
25- expectedNumberOfVisits ,
29+ EQUAL_ARRAY_VISITING_COUNT ,
2630 ) ;
2731 } ) ;
2832
2933 it ( 'should visit SORTED array element specified number of times' , ( ) => {
30- const expectedNumberOfVisits = 209 ;
31-
3234 SortTester . testAlgorithmTimeComplexity (
3335 SelectionSort ,
3436 sortedArr ,
35- expectedNumberOfVisits ,
37+ SORTED_ARRAY_VISITING_COUNT ,
3638 ) ;
3739 } ) ;
3840
3941 it ( 'should visit NOT SORTED array element specified number of times' , ( ) => {
40- const expectedNumberOfVisits = 209 ;
41-
4242 SortTester . testAlgorithmTimeComplexity (
4343 SelectionSort ,
4444 notSortedArr ,
45- expectedNumberOfVisits ,
45+ NOT_SORTED_ARRAY_VISITING_COUNT ,
4646 ) ;
4747 } ) ;
4848
4949 it ( 'should visit REVERSE SORTED array element specified number of times' , ( ) => {
50- const expectedNumberOfVisits = 209 ;
51-
5250 SortTester . testAlgorithmTimeComplexity (
5351 SelectionSort ,
5452 reverseArr ,
55- expectedNumberOfVisits ,
53+ REVERSE_SORTED_ARRAY_VISITING_COUNT ,
5654 ) ;
5755 } ) ;
5856} ) ;
0 commit comments