File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed
src/hackerrank/interview_preparation_kit/arrays Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -5,20 +5,27 @@ import arrayLeftRotation from './ctci_array_left_rotation';
5
5
6
6
import ROT_LEFT_TEST_CASES from './ctci_array_left_rotation.testcases.json' ;
7
7
8
+ interface RotLeftTestCase {
9
+ title : string ;
10
+ input : number [ ] ;
11
+ d_rotations : number ;
12
+ expected : number [ ] ;
13
+ }
14
+
15
+ const TEST_CASES : RotLeftTestCase [ ] = ROT_LEFT_TEST_CASES as RotLeftTestCase [ ] ;
16
+
8
17
describe ( 'ctci_array_left_rotation' , ( ) => {
9
18
it ( 'rotLeft Test cases' , ( ) => {
10
19
expect . assertions ( 8 ) ;
11
20
12
- ROT_LEFT_TEST_CASES . forEach ( ( test ) => {
13
- const numbers = test . input ;
14
-
21
+ TEST_CASES . forEach ( ( test : RotLeftTestCase ) => {
15
22
const answer = arrayLeftRotation . rotLeft (
16
- numbers ,
23
+ test . input ,
17
24
Number ( test . d_rotations )
18
25
) ;
19
26
20
27
console . debug (
21
- `rotLeft(${ numbers . toString ( ) } ) solution found: ${ test . expected . toString ( ) } `
28
+ `rotLeft(${ test . input . toString ( ) } ) solution found: ${ test . expected . toString ( ) } `
22
29
) ;
23
30
24
31
expect ( answer ) . toStrictEqual ( test . expected ) ;
You can’t perform that action at this time.
0 commit comments