Example #1
0
 /**
  * @covers Moontoast\Math\BigNumber::baseConvert
  */
 public function testBaseConvert()
 {
     $fromBase = array(2, 8, 10, 16, 36);
     $toBase = array(2, 8, 10, 16, 36);
     $convertValues = array(10, 27, 39, 03, 0x5f, '10', '27', '39', '5F', '5f', '3XYZ', '3xyz', '5f$@');
     foreach ($fromBase as $from) {
         foreach ($toBase as $to) {
             foreach ($convertValues as $val) {
                 // Test that our baseConvert matches PHP's base_convert
                 $phpRes = base_convert($val, $from, $to);
                 $bnRes = BigNumber::baseConvert($val, $from, $to);
                 $this->assertEquals($phpRes, $bnRes, "from base is {$from}, to base is {$to}, value is {$val}, baseConvert result is {$bnRes}");
             }
         }
     }
 }