Example #1
0
 /**
  * @dataProvider getAdapters
  */
 public function testStrictIntegerReturnValues(MathAdapterInterface $math)
 {
     $x = 10;
     $y = 4;
     $mod = $math->mod($x, $y);
     $this->assertTrue(is_string($mod) && !is_resource($mod));
     $add = $math->add($x, $y);
     $this->assertTrue(is_string($add) && !is_resource($add));
     $sub = $math->sub($add, $y);
     $this->assertTrue(is_string($sub) && !is_resource($sub));
     $mul = $math->mul($x, $y);
     $this->assertTrue(is_string($mul) && !is_resource($mul));
     $div = $math->div($mul, $y);
     $this->assertTrue(is_string($div) && !is_resource($div));
     $pow = $math->pow($x, $y);
     $this->assertTrue(is_string($pow) && !is_resource($div));
     $powmod = $math->powmod($x, $y, $y);
     $this->assertTrue(is_string($powmod) && !is_resource($powmod));
     $bitwiseand = $math->bitwiseAnd($x, $y);
     $this->assertTrue(is_string($bitwiseand) && !is_resource($bitwiseand));
     $hexdec = $math->decHex($x);
     $this->assertTrue(is_string($hexdec) && !is_resource($hexdec));
     $dechex = $math->hexDec($hexdec);
     $this->assertTrue(is_string($dechex) && !is_resource($dechex));
 }
Example #2
0
 /**
  * @dataProvider getAdapters
  */
 public function testSqrtDataWithRoots(MathAdapterInterface $adapter)
 {
     $theory = $adapter->getNumberTheory();
     foreach ($this->sqrt_data->has_root as $r) {
         $root1 = $theory->squareRootModP($r->a, $r->p);
         $root2 = $adapter->sub($r->p, $root1);
         $this->assertTrue(in_array($root1, $r->res));
         $this->assertTrue(in_array($root2, $r->res));
     }
 }
Example #3
0
 /**
  * @param $bitSize
  * @return int|string
  */
 private function fixSize($bitSize)
 {
     return $this->math->sub($bitSize, 1);
 }