endtoend-test-psl/tests/Psl/Str/DetectEncodingTest.php
Amit Dudhat d991adbc73
[Str] add encoding function (#72)
Co-authored-by: azjezz <azjezz@protonmail.com>
2020-10-04 20:24:36 +01:00

30 lines
581 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
{
self::assertSame($expected, Str\detect_encoding($string));
}
public function provideData(): array
{
return [
['ASCII', 'hello'],
['UTF-8', 'سيف'],
['UTF-8', '🐘'],
[null, Str\Byte\chr(128)]
];
}
}