mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 09:48:40 +00:00
51 lines
1.4 KiB
PHP
51 lines
1.4 KiB
PHP
<?php
|
|
/**
|
|
* Jingga
|
|
*
|
|
* PHP Version 8.2
|
|
*
|
|
* @package tests
|
|
* @copyright Dennis Eichhorn
|
|
* @license OMS License 2.0
|
|
* @version 1.0.0
|
|
* @link https://jingga.app
|
|
*/
|
|
declare(strict_types=1);
|
|
|
|
namespace phpOMS\tests\Math\Geometry\ConvexHull;
|
|
|
|
include_once __DIR__ . '/../../../Autoloader.php';
|
|
|
|
use phpOMS\Math\Geometry\ConvexHull\GrahamScan;
|
|
|
|
/**
|
|
* @internal
|
|
*/
|
|
#[\PHPUnit\Framework\Attributes\CoversClass(\phpOMS\Math\Geometry\ConvexHull\GrahamScan::class)]
|
|
#[\PHPUnit\Framework\Attributes\TestDox('phpOMS\tests\Math\Geometry\ConvexHull\GrahamScanTest: Monotone chain')]
|
|
final class GrahamScanTest extends \PHPUnit\Framework\TestCase
|
|
{
|
|
#[\PHPUnit\Framework\Attributes\Group('framework')]
|
|
#[\PHPUnit\Framework\Attributes\TestDox('A convex hull can be formed from multiple points on a plane')]
|
|
public function testGrahamScan() : void
|
|
{
|
|
self::assertEquals([['x' => 9, 'y' => 0]], GrahamScan::createConvexHull([['x' => 9, 'y' => 0]]));
|
|
|
|
$points = [];
|
|
for ($i = 0; $i < 10; ++$i) {
|
|
for ($j = 0; $j < 10; ++$j) {
|
|
$points[] = ['x' => $i, 'y' => $j];
|
|
}
|
|
}
|
|
|
|
self::assertEquals([
|
|
['x' => 0, 'y' => 0],
|
|
['x' => 9, 'y' => 0],
|
|
['x' => 9, 'y' => 9],
|
|
['x' => 0, 'y' => 9],
|
|
],
|
|
GrahamScan::createConvexHull($points)
|
|
);
|
|
}
|
|
}
|