endtoend-test-psl/tests/Psl/Str/Byte/SplitTest.php
2020-01-02 00:00:08 +01:00

33 lines
829 B
PHP

<?php
declare(strict_types=1);
namespace Psl\Tests\Str\Byte;
use PHPUnit\Framework\TestCase;
use Psl\Str\Byte;
class SplitTest extends TestCase
{
/**
* @dataProvider provideData
*/
public function testSplit(array $expected, string $string, string $delimiter, ?int $length = null): void
{
self::assertSame($expected, Byte\split($string, $delimiter, $length));
}
public function provideData(): array
{
return [
[[], '', '', 1],
[['H', 'e', 'l', 'l', 'o'], 'Hello', ''],
[['Hello'], 'Hello', '', 1],
[['H', 'ello'], 'Hello', '', 2],
[['Hello, World!'], 'Hello, World!', ' ', 1],
[['Hello,', 'World!'], 'Hello, World!', ' '],
[['Hello,', 'World!'], 'Hello, World!', ' ', 2],
];
}
}