endtoend-test-psl/tests/Psl/Str/LevenshteinTest.php
2019-12-27 05:42:24 +01:00

37 lines
720 B
PHP

<?php
declare(strict_types=1);
namespace Psl\Tests\Str;
use PHPUnit\Framework\TestCase;
use Psl\Str;
class LevenshteinTest extends TestCase
{
/**
* @dataProvider provideData
*/
public function testLevenshtein(
int $expected,
string $a,
string $b,
?int $coi = null,
?int $cor = null,
?int $cod = null
): void {
self::assertSame($expected, Str\levenshtein($a, $b, $coi, $cor, $cod));
}
public function provideData(): array
{
return [
[0, 'o', 'o'],
[1, 'foo', 'oo'],
[1, 'oo', 'foo'],
[6, 'saif', 'azjezz'],
[48, 'saif', 'azjezz', 9, 8, 5]
];
}
}