37 lines
No EOL
1.1 KiB
Raku
37 lines
No EOL
1.1 KiB
Raku
use Test2::V0;
|
|
use Test2::Plugin::ExitSummary;
|
|
|
|
use FindBin qw($Bin);
|
|
use lib "$Bin/../lib";
|
|
use CyclicRotation;
|
|
|
|
my @array1 = qw(1 2 3 4 5 6 7);
|
|
my $shift_int1 = '3';
|
|
|
|
my $array2 = [0, 0, 0];
|
|
my $shift_int2 = '1';
|
|
|
|
my $array3 = [1, 2, 3, 4];
|
|
my $shift_int3 = '4';
|
|
|
|
# my $array4 = [3, 8, 9, 7, 6];
|
|
# my $shift_int4 = '3';
|
|
|
|
my $expected_rotated_arr1 = [4, 5, 6, 7, 1, 2, 3];
|
|
my $expected_rotated_arr2 = [0, 0, 0];
|
|
my $expected_rotated_arr3 = [1, 2, 3, 4];
|
|
# my $expected_rotated_arr4 = [4,5,6,7,1,2,3];
|
|
|
|
plan(3);
|
|
|
|
my $rotated_arr1 = CyclicRotation::solution(\@array1,$shift_int1);
|
|
is($rotated_arr1, $expected_rotated_arr1, "Rotated array 1 is correct");
|
|
|
|
my $rotated_arr2 = CyclicRotation::solution($array2,$shift_int2);
|
|
is($rotated_arr2, $expected_rotated_arr2, "Rotated array 2 is correct");
|
|
|
|
my $rotated_arr3 = CyclicRotation::solution($array3, $shift_int3);
|
|
is($rotated_arr3, $expected_rotated_arr3, "Rotated array 3 is correct");
|
|
|
|
# my $rotated_arr4 = CyclicRotation::solution(\$array4,$shift_int4);
|
|
# is($rotated_arr4, $expected_rotated_arr4, "Rotated array 4 is correct"); |