Files
PhpSpreadsheet/tests/data/Calculation/TextData/RIGHT.php
kevin9327 d767ea2336 RIGHT: return all of the text when asked for more characters than it has
RIGHT("abc",5) returned "bc" because the start offset went negative and
mb_substr then counted it from the end of the string. Excel returns the
whole text when num_chars is greater than its length, so clamp the offset
at 0.
2026-10-05 12:32:24 +09:00

84 lines
1.3 KiB
PHP

<?php
declare(strict_types=1);
return [
[
'',
null,
1,
],
[
'',
'',
1,
],
[
'#VALUE!',
'QWERTYUIOP',
-1,
],
[
'#VALUE!',
'QWERTYUIOP',
'NaN',
],
'null length defaults to 0' => [
'',
'QWERTYUIOP',
null,
],
'omitted length defaults to 1' => [
'P',
'QWERTYUIOP',
],
[
'GHI',
'ABCDEFGHI',
3,
],
[
'',
'ABCDEFGHI',
0,
],
'length greater than text returns all of text' => [
'ABCDEFGHI',
'ABCDEFGHI',
12,
],
'length one more than text returns all of text' => [
'πέντε',
'πέντε',
6,
],
[
'πέντε',
'Ενα δύο τρία τέσσερα πέντε',
5,
],
[
'τέσσερα πέντε',
'Ενα δύο τρία τέσσερα πέντε',
13,
],
[
'τρία τέσσερα πέντε',
'Ενα δύο τρία τέσσερα πέντε',
18,
],
[
'UE',
true,
2,
],
[
'SE',
false,
2,
],
'string not specified' => [
'exception',
],
];