endtoend-test-psl/tests/Psl/Str/TrimRightTest.php

61 lines
1.4 KiB
PHP
Raw Normal View History

2019-12-24 01:52:07 +01:00
<?php
declare(strict_types=1);
namespace Psl\Tests\Str;
use PHPUnit\Framework\TestCase;
2019-12-26 23:10:57 +01:00
use Psl\Str;
2019-12-24 01:52:07 +01:00
class TrimRightTest extends TestCase
{
2019-12-26 23:10:57 +01:00
/**
* @dataProvider provideData
*/
public function testTrimRight(string $expected, string $string, ?string $chars = null): void
{
self::assertSame($expected, Str\trim_right($string, $chars));
}
public function provideData(): array
{
return [
[
" Hello World\t!!!",
" Hello World\t!!!\n",
null,
],
[
" Hello World\t!!!\n",
" Hello World\t!!!\n",
' ',
],
[
" Hello World\t!!!",
" Hello World\t!!!\n",
"\n",
],
[
" Hello World\t",
" Hello World\t!!!\n",
"\n!",
],
[
' Hello World',
" Hello World\t!!!\n",
"\n!\t",
],
[
" Hello World\t",
" Hello World\t!!!\n",
" \n!",
],
[
" Hello World\t!!! \n",
" Hello World\t!!! \n",
' ',
],
];
}
2019-12-24 01:52:07 +01:00
}