<?php
declare(strict_types=1);

use PHPUnit\Framework\TestCase;

require_once __DIR__ . "/aretheythesame.php";

class Check {

  /**
   * @var string
   */
  public $name;

  /**
   * @var array
   */
  public $one;

  /**
   * @var array
   */
  public $two;

  /**
   * @var bool
   */
  public $expected;

  public function __construct(string $name, array $a, $b, bool $expected) {
    $this->one = $a;
    $this->two = $b;
    $this->expected = $expected;
    $this->name = $name;
  }
}

class TestCompCase extends TestCase {

  function testComp() {
    $checks = [
      new Check(
        "Good",
        [121, 144, 19, 161, 19, 144, 19, 11],
        [121, 14641, 20736, 361, 25921, 361, 20736, 361],
        true
      ),
      new Check(
        "132 is not 11^2",
        [121, 144, 19, 161, 19, 144, 19, 11],
        [132, 14641, 20736, 361, 25921, 361, 20736, 361],
        false
      ),
      new Check(
        "36100 is not the square of any member of a",
        [121, 144, 19, 161, 19, 144, 19, 11],
        [121, 14641, 20736, 36100, 25921, 361, 20736, 361],
        false
      ),
      new Check(
        "Bad pair",
        [4, 4],
        [1, 31],
        false
      ),
      new Check(
        "Empty and null",
        [],
        NULL,
        false
      )
    ];

    /** @var \Check $check */
    foreach ($checks as $check) {
      $actual = comp($check->one, $check->two);
    }
    $this->assertEquals($check->expected, $actual, $check->name);
  }
}