Skip to content

Commit 26f876c

Browse files
committed
Add tests with 100% coverage for Algorithm\Symmetric
1 parent e8e12cb commit 26f876c

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

tests/SymmetricTest.php

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
3+
use Fhaculty\Graph\Algorithm\Symmetric as AlgorithmSymmetric;
4+
use Fhaculty\Graph\Graph;
5+
6+
class SymmetricTest extends TestCase
7+
{
8+
public function testGraphEmpty()
9+
{
10+
$graph = new Graph();
11+
12+
$alg = new AlgorithmSymmetric($graph);
13+
14+
$this->assertTrue($alg->isSymmetric());
15+
}
16+
17+
public function testGraphIsolated()
18+
{
19+
$graph = new Graph();
20+
$graph->createVertex(1);
21+
$graph->createVertex(2);
22+
23+
$alg = new AlgorithmSymmetric($graph);
24+
25+
$this->assertTrue($alg->isSymmetric());
26+
}
27+
28+
public function testGraphSingleArcIsNotSymmetricr()
29+
{
30+
// 1 -> 2
31+
$graph = new Graph();
32+
$graph->createVertex(1)->createEdgeTo($graph->createVertex(2));
33+
34+
$alg = new AlgorithmSymmetric($graph);
35+
36+
$this->assertFalse($alg->isSymmetric());
37+
}
38+
39+
public function testGraphAntiparallelIsSymmetricr()
40+
{
41+
// 1 -> 2 -> 1
42+
$graph = new Graph();
43+
$graph->createVertex(1)->createEdgeTo($graph->createVertex(2));
44+
$graph->getVertex(2)->createEdgeTo($graph->getVertex(1));
45+
46+
$alg = new AlgorithmSymmetric($graph);
47+
48+
$this->assertTrue($alg->isSymmetric());
49+
}
50+
51+
public function testGraphSingleUndirectedIsSymmetricr()
52+
{
53+
// 1 -- 2
54+
$graph = new Graph();
55+
$graph->createVertex(1)->createEdge($graph->createVertex(2));
56+
57+
$alg = new AlgorithmSymmetric($graph);
58+
59+
$this->assertTrue($alg->isSymmetric());
60+
}
61+
}

0 commit comments

Comments
 (0)