Skip to content

Commit

Permalink
write test for Fuzzy Search
Browse files Browse the repository at this point in the history
  • Loading branch information
Divyeshhhh committed Apr 9, 2024
1 parent 69a8e56 commit 257a5dd
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/FuzzyTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

use PHPUnit\Framework\TestCase;
use Steamy\Core\Utility;

class FuzzyTest extends TestCase
{
public function testFuzzySearch(): void
{
$strings = ['Espresso', 'Cappuccino', 'Latte', 'Americano', 'Mocha'];
$searchTerm = 'Espreso';
$threshold = 1;

$result = Utility::fuzzySearch($searchTerm, $strings, $threshold);

$this->assertContains('Espresso', $result);
$this->assertNotContains('Mocha', $result);
}

public function testLevenshteinDistance(): void
{
$str1 = 'Almond';
$str2 = 'Coconut';

$result = Utility::levenshteinDistance($str1, $str2);

$this->assertEquals(5, $result);
}
}

0 comments on commit 257a5dd

Please sign in to comment.