endtoend-test-psl/tests/Psl/Str/DetectEncodingTest.php
2020-10-15 11:05:30 +02:00

30 lines
583 B
PHP

<?php
declare(strict_types=1);
namespace Psl\Tests\Str;
use PHPUnit\Framework\TestCase;
use Psl\Str;
final class DetectEncodingTest extends TestCase
{
/**
* @dataProvider provideData
*/
public function testDetectEncoding(?string $expected, string $string): void
{
static::assertSame($expected, Str\detect_encoding($string));
}
public function provideData(): array
{
return [
['ASCII', 'hello'],
['UTF-8', 'سيف'],
['UTF-8', '🐘'],
[null, Str\Byte\chr(128)]
];
}
}