-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b9bac97
commit 01b1b07
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
use PHPUnit\Framework\TestCase; | ||
|
||
require __DIR__ . '/../src/php/AreaChecker.php'; | ||
|
||
class AreaCheckerTest extends TestCase | ||
{ | ||
|
||
public static function providerForAreaCheck() | ||
{ | ||
return [ | ||
// Points in the top-right quadrant (triangle check) | ||
'TopRight Inside Triangle Top' => [0.5, 1, 2, true], | ||
'TopRight Inside Triangle Right' => [1, 1, 4, true], | ||
'TopRight Outside Triangle Right' => [2, 1, 2, false], | ||
'TopRight Outside Triangle Top' => [0.6, 1, 2, false], | ||
|
||
// Points in the top-left quadrant (rectangle check) | ||
'TopLeft Inside Rect Top' => [-0.5, 0.5, 2, true], | ||
'TopLeft Inside Rect Left' => [-1, 1, 2, true], | ||
'TopLeft Outside Rect Left' => [-1.1, 1, 2, false], | ||
'TopLeft Outside Rect Top' => [-1, 2.1, 2, false], | ||
|
||
// Points in the bottom-right quadrant (circle check) | ||
'BottomRight Inside Circle' => [1, -1, 2, true], | ||
'BottomRight Outside Circle' => [2, -2, 2, false], | ||
|
||
// Points in the bottom-left quadrant (always outside) | ||
'BottomLeft Always Outside' => [-0.5, -0.5, 2, false] | ||
]; | ||
} | ||
|
||
/** | ||
* @dataProvider providerForAreaCheck | ||
*/ | ||
public function testIsInArea($x, $y, $r, $expected) | ||
{ | ||
$this->assertSame($expected, AreaChecker::isInArea($x, $y, $r)); | ||
} | ||
} |