Skip to content

Commit bfd9465

Browse files
committed
Add unit tests
1 parent fecad31 commit bfd9465

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

src/functions/ReverseArray.spec.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/* eslint-disable @typescript-eslint/no-non-null-assertion */
2+
/* eslint-disable @typescript-eslint/consistent-type-assertions */
3+
/// <reference types="@rbxts/testez/globals" />
4+
5+
import { reverseArray } from "./ReverseArray";
6+
7+
export = () => {
8+
it("should return an empty array for an empty array input", () => {
9+
const inputArray = new Array<defined>();
10+
const result = reverseArray(inputArray);
11+
expect(result.size()).to.equal(0);
12+
});
13+
14+
it("should return an array of the same one item for a single element array input", () => {
15+
const inputArray = [1];
16+
const result = reverseArray(inputArray);
17+
expect(result.size()).to.equal(1);
18+
expect(result[0]).to.equal(inputArray[0]);
19+
});
20+
21+
it("should return a reversed array for an array of length > 1", () => {
22+
const inputArray = [0];
23+
for (let i = 1; i <= 25; i++) {
24+
inputArray.push(i);
25+
26+
const result = reverseArray(inputArray);
27+
expect(result.size()).to.equal(inputArray.size());
28+
29+
for (let j = i; j >= 0; j--) {
30+
expect(result[i - j]).to.equal(inputArray[j]);
31+
}
32+
}
33+
});
34+
};

0 commit comments

Comments
 (0)