endtoend-test-psl/tests/Psl/Str/Byte/ChunkTest.php

31 lines
753 B
PHP
Raw Normal View History

2019-12-24 01:52:07 +01:00
<?php
declare(strict_types=1);
namespace Psl\Tests\Str\Byte;
use PHPUnit\Framework\TestCase;
2019-12-26 23:10:57 +01:00
use Psl\Str\Byte;
2019-12-24 01:52:07 +01:00
final class ChunkTest extends TestCase
2019-12-24 01:52:07 +01:00
{
2019-12-26 23:10:57 +01:00
/**
* @dataProvider provideData
*/
public function testCapitalize(array $expected, string $value, int $chunk_size = 1): void
{
static::assertSame($expected, Byte\chunk($value, $chunk_size));
2019-12-26 23:10:57 +01:00
}
public function provideData(): array
{
return [
[['h', 'e', 'l', 'l', 'o'], 'hello', ],
[['h', 'e', 'l', 'l', 'o', ',', ' ', 'w', 'o', 'r', 'l', 'd'], 'hello, world', ],
[['Al', 'ph', 'a ', ' '], 'Alpha ', 2, ],
[['م', 'ر', 'ح', 'ب', 'ا'], 'مرحبا', 2],
[[], ''],
];
}
2019-12-24 01:52:07 +01:00
}