Skip to content

Commit 8459246

Browse files
author
Gonzalo Diaz
committed
[REFACTOR] [Hacker Rank] Interview Preparation Kit: Arrays: Left Rotation. New JSON data typed.
1 parent ff81b52 commit 8459246

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/hackerrank/interview_preparation_kit/arrays/ctci_array_left_rotation.test.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,27 @@ import arrayLeftRotation from './ctci_array_left_rotation';
55

66
import ROT_LEFT_TEST_CASES from './ctci_array_left_rotation.testcases.json';
77

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+
817
describe('ctci_array_left_rotation', () => {
918
it('rotLeft Test cases', () => {
1019
expect.assertions(8);
1120

12-
ROT_LEFT_TEST_CASES.forEach((test) => {
13-
const numbers = test.input;
14-
21+
TEST_CASES.forEach((test: RotLeftTestCase) => {
1522
const answer = arrayLeftRotation.rotLeft(
16-
numbers,
23+
test.input,
1724
Number(test.d_rotations)
1825
);
1926

2027
console.debug(
21-
`rotLeft(${numbers.toString()}) solution found: ${test.expected.toString()}`
28+
`rotLeft(${test.input.toString()}) solution found: ${test.expected.toString()}`
2229
);
2330

2431
expect(answer).toStrictEqual(test.expected);

0 commit comments

Comments
 (0)