File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 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+ } ;
You can’t perform that action at this time.
0 commit comments