42 lines
1.5 KiB
PHP
42 lines
1.5 KiB
PHP
|
<?php
|
||
|
|
||
|
declare(strict_types=1);
|
||
|
|
||
|
namespace App\Tests;
|
||
|
|
||
|
use PHPUnit\Framework\TestCase;
|
||
|
use PHPUnit\Framework\Attributes\CoversClass;
|
||
|
use CodingTests\Numerical;
|
||
|
|
||
|
#[CoversClass(Numerical::class)]
|
||
|
final class NumericalTest extends TestCase
|
||
|
{
|
||
|
public function testisPandigital(): void
|
||
|
{
|
||
|
$this->assertTrue(Numerical::isPandigital(123456789));
|
||
|
$this->assertTrue(Numerical::isPandigital(987654321));
|
||
|
$this->assertTrue(Numerical::isPandigital(789456123));
|
||
|
$this->assertTrue(Numerical::isPandigital(321654987));
|
||
|
|
||
|
$this->assertFalse(Numerical::isPandigital(0));
|
||
|
$this->assertFalse(Numerical::isPandigital(1));
|
||
|
$this->assertFalse(Numerical::isPandigital(111111111));
|
||
|
$this->assertFalse(Numerical::isPandigital(999999999));
|
||
|
$this->assertFalse(Numerical::isPandigital(1234567890));
|
||
|
}
|
||
|
|
||
|
public function testisPandigitalWithZero(): void
|
||
|
{
|
||
|
$this->assertTrue(Numerical::isPandigitalWithZero(1234567890));
|
||
|
$this->assertTrue(Numerical::isPandigitalWithZero(9876543210));
|
||
|
$this->assertTrue(Numerical::isPandigitalWithZero(7894561230));
|
||
|
$this->assertTrue(Numerical::isPandigitalWithZero(3216549870));
|
||
|
|
||
|
$this->assertFalse(Numerical::isPandigitalWithZero(123456780));
|
||
|
$this->assertFalse(Numerical::isPandigitalWithZero(123456789));
|
||
|
$this->assertFalse(Numerical::isPandigitalWithZero(987654321));
|
||
|
$this->assertFalse(Numerical::isPandigitalWithZero(789456123));
|
||
|
$this->assertFalse(Numerical::isPandigitalWithZero(321654987));
|
||
|
}
|
||
|
}
|