1
0
mirror of https://github.com/danog/math.git synced 2024-11-27 04:14:40 +01:00
math/tests/AbstractTestCase.php
Benjamin Morel 1b8b3e43bb Add basic arithmetic operations to BigNumber
- BigInteger::dividedBy() previous implementation is now quotient()
- BigDecimal::dividedBy() previous implementation is now dividedByWithRounding()
2015-06-26 00:36:19 +02:00

55 lines
1.5 KiB
PHP

<?php
namespace Brick\Math\Tests;
use Brick\Math\BigDecimal;
use Brick\Math\BigInteger;
use Brick\Math\BigRational;
/**
* Base class for BigInteger and BigDecimal test cases.
*/
abstract class AbstractTestCase extends \PHPUnit_Framework_TestCase
{
/**
* @param string $expected The expected value as a string.
* @param BigInteger $actual The BigInteger instance to test.
*/
final protected function assertBigIntegerEquals($expected, BigInteger $actual)
{
$this->assertSame($expected, (string) $actual);
}
/**
* @param string $unscaledValue The expected unscaled value.
* @param int $scale The expected scale.
* @param BigDecimal $actual The BigDecimal instance to test.
*/
final protected function assertBigDecimalEquals($unscaledValue, $scale, BigDecimal $actual)
{
$this->assertSame($unscaledValue, $actual->getUnscaledValue());
$this->assertSame($scale, $actual->getScale());
}
/**
* @param string $numerator
* @param string $denominator
* @param BigRational $actual
*/
final protected function assertBigRationalEquals($numerator, $denominator, BigRational $actual)
{
$this->assertSame($numerator, (string) $actual->getNumerator());
$this->assertSame($denominator, (string) $actual->getDenominator());
}
/**
* @param string $name
*
* @return bool
*/
final protected function isException($name)
{
return substr($name, -9) === 'Exception';
}
}