TestDivisorsCase.php 512 B

1234567891011121314151617181920212223
  1. <?php
  2. use PHPUnit\Framework\TestCase;
  3. require_once __DIR__ . "/countthedivisors.php";
  4. class TestDivisorsCase extends TestCase {
  5. public function testCountTheDivisors() {
  6. $checks = [
  7. [1, 1], // 1
  8. [4, 3], // 1, 2, 4
  9. [12, 6], // 1, 2, 3, 4, 6, 12
  10. [30, 8], // 1, 2, 3, 5, 6, 10, 15, 30
  11. [500000, 42],
  12. ];
  13. foreach ($checks as $check) {
  14. $expected = $check[1];
  15. $actual = divisors($check[0]);
  16. $this->assertEquals($expected, $actual, $check[0]);
  17. }
  18. }
  19. }