Skip to content

Commit

Permalink
adjusted test expectations. refs #4
Browse files Browse the repository at this point in the history
  • Loading branch information
shrink0r committed Oct 13, 2016
1 parent e76d4b2 commit f7497ef
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/Builder/SuffixTreeBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,9 @@ private function transferChildren(
$new_node = new Internal(
$child_node->start,
$child_node->end,
$grand_children,
$smin,
$smax,
$grand_children,
$suffix_node
);
if ($suffix_node === null && $child_node->suffix_link !== null) {
Expand Down
4 changes: 2 additions & 2 deletions src/InternalNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ final class InternalNode implements NodeInterface
/**
* @param int $start
* @param int $end
* @param array $children
* @param int $smin
* @param int $smax
* @param array $children
* @param NodeInterface $suffix_link
*/
public function __construct(int $start, int $end, array $children = [], int $smin, int $smax, $suffix_link = null)
public function __construct(int $start, int $end, int $smin, int $smax, array $children = [], $suffix_link = null)
{
if ($suffix_link !== null && $suffix_link->getSuffixIdx() !== -1) {
throw new \Exception("Trying to link non-internal/root node.");
Expand Down
18 changes: 8 additions & 10 deletions tests/Unit/SuffixTreeTest.php → tests/Unit/FlowTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Shrink0r\SuffixTree\Builder\SuffixTreeBuilder;
use Shrink0r\SuffixTree\Tests\Unit\TestCase;

class SuffixTreeTest extends TestCase
class FlowTest extends TestCase
{
private $tree_builder;

Expand All @@ -17,22 +17,17 @@ protected function setUp()
/**
* @dataProvider provideFlowFixtures
*/
public function testOverallFlow(string $s, string $lrs, array $suffix, array $substring)
public function testOverallFlow(string $s, string $lrs, string $lrs_no, array $suffix, array $substring)
{
$suffix_tree = $this->tree_builder->build($s);
$this->assertEquals($lrs, $suffix_tree->findLongestRepetition());
$this->assertEquals($lrs, $suffix_tree->findLrs());
$this->assertEquals($lrs_no, $suffix_tree->findNonOverlappingLrs());
$this->assertTrue($suffix_tree->hasSuffix($suffix['true']));
$this->assertFalse($suffix_tree->hasSuffix($suffix['false']));
$this->assertTrue($suffix_tree->hasSubstring($substring['true']));
$this->assertFalse($suffix_tree->hasSubstring($substring['false']));
}

public function testGetLongestRepetition()
{
$suffix_tree = $this->tree_builder->build('mississippi$');
$this->assertEquals('issi', $suffix_tree->findLongestRepetition(true));
}

/**
* @codeCoverageIgnore
*/
Expand All @@ -41,19 +36,22 @@ public static function provideFlowFixtures()
return [
[
's' => 'mississippi$',
'lrs' => 'iss',
'lrs' => 'issi',
'lrs_no' => 'ssi',
'suffix' => [ 'true' => 'sippi$', 'false' => 'miss$' ],
'substring' => [ 'true' => 'iss', 'false' => 'issm' ]
],
[
's' => 'GEEKSFORGEEKS$',
'lrs' => 'GEEKS',
'lrs_no' => 'GEEKS',
'suffix' => [ 'true' => 'EKS$', 'false' => 'GE$' ],
'substring' => [ 'true' => 'EEK', 'false' => 'SKG' ]
],
[
's' => 'xabxac$',
'lrs' => 'xa',
'lrs_no' => 'xa',
'suffix' => [ 'true' => 'ac$', 'false' => 'xa$' ],
'substring' => [ 'true' => 'bxa', 'false' => 'cba' ]
]
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/InternalNodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class InternalNodeTest extends TestCase

protected function setUp()
{
$this->internal_node = new InternalNode(3, 5);
$this->internal_node = new InternalNode(3, 5, 7, 8);
}

public function testGetSuffixLink()
Expand Down

0 comments on commit f7497ef

Please sign in to comment.