2021-02-26 16:16:17 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Class PolynomialTest
|
|
|
|
*
|
|
|
|
* @filesource PolynomialTest.php
|
|
|
|
* @created 09.02.2016
|
|
|
|
* @package chillerlan\QRCodeTest\Helpers
|
|
|
|
* @author Smiley <smiley@chillerlan.net>
|
|
|
|
* @copyright 2015 Smiley
|
|
|
|
* @license MIT
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace chillerlan\QRCodeTest\Helpers;
|
|
|
|
|
|
|
|
use chillerlan\QRCode\Helpers\Polynomial;
|
|
|
|
use chillerlan\QRCode\QRCodeException;
|
2022-07-02 14:01:51 +00:00
|
|
|
use PHPUnit\Framework\TestCase;
|
2021-02-26 16:16:17 +00:00
|
|
|
|
2022-07-02 14:01:51 +00:00
|
|
|
/**
|
|
|
|
* Polynomial coverage test
|
|
|
|
*/
|
|
|
|
final class PolynomialTest extends TestCase{
|
2021-02-26 16:16:17 +00:00
|
|
|
|
2022-07-02 14:01:51 +00:00
|
|
|
protected Polynomial $polynomial;
|
2021-02-26 16:16:17 +00:00
|
|
|
|
|
|
|
protected function setUp():void{
|
|
|
|
$this->polynomial = new Polynomial;
|
|
|
|
}
|
|
|
|
|
2022-07-02 14:01:51 +00:00
|
|
|
public function testGexp():void{
|
|
|
|
$this::assertSame(142, $this->polynomial->gexp(-1));
|
|
|
|
$this::assertSame(133, $this->polynomial->gexp(128));
|
|
|
|
$this::assertSame(2, $this->polynomial->gexp(256));
|
2021-02-26 16:16:17 +00:00
|
|
|
}
|
|
|
|
|
2022-07-02 14:01:51 +00:00
|
|
|
public function testGlogException():void{
|
2021-02-26 16:16:17 +00:00
|
|
|
$this->expectException(QRCodeException::class);
|
|
|
|
$this->expectExceptionMessage('log(0)');
|
|
|
|
|
|
|
|
$this->polynomial->glog(0);
|
|
|
|
}
|
|
|
|
}
|