-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathBinaryTreeMaximumPathSumTest.php
49 lines (42 loc) · 1.19 KB
/
BinaryTreeMaximumPathSumTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
declare(strict_types=1);
namespace leetcode\tests;
use leetcode\BinaryTreeMaximumPathSum;
use leetcode\util\TreeNode;
use PHPUnit\Framework\TestCase;
class BinaryTreeMaximumPathSumTest extends TestCase
{
private array $items;
protected function setUp(): void
{
$this->items = [
[new TreeNode(1, new TreeNode(2), new TreeNode(3)), 6],
[
new TreeNode(
-10,
new TreeNode(9),
new TreeNode(
20,
new TreeNode(15),
new TreeNode(7)
)
),
42
],
[new TreeNode(-2, new TreeNode(-1)), -1],
[new TreeNode(1, new TreeNode(2)), 3]
];
}
public function testMaxPathSum(): void
{
foreach ($this->items as $item) {
self::assertSame($item[1], BinaryTreeMaximumPathSum::maxPathSum($item[0]));
}
}
public function testMaxPathSum2(): void
{
foreach ($this->items as $item) {
self::assertSame($item[1], BinaryTreeMaximumPathSum::maxPathSum2($item[0]));
}
}
}