endtoend-test-psl/tests/Psl/Str/LevenshteinTest.php

37 lines
720 B
PHP
Raw Normal View History

2019-12-24 01:52:07 +01:00
<?php
declare(strict_types=1);
namespace Psl\Tests\Str;
use PHPUnit\Framework\TestCase;
2019-12-26 23:10:57 +01:00
use Psl\Str;
2019-12-24 01:52:07 +01:00
class LevenshteinTest extends TestCase
{
2019-12-26 23:10:57 +01:00
/**
* @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]
];
}
2019-12-24 01:52:07 +01:00
}