1
0
mirror of https://github.com/danog/math.git synced 2024-12-12 09:19:53 +01:00
math/tests/AbstractTestCase.php

45 lines
1.4 KiB
PHP
Raw Normal View History

2014-08-31 14:13:46 +02:00
<?php
namespace Brick\Math\Tests;
2014-08-31 14:13:46 +02:00
use Brick\Math\BigDecimal;
use Brick\Math\BigInteger;
use Brick\Math\BigRational;
2014-08-31 14:13:46 +02:00
/**
* 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.
*/
protected function assertBigIntegerEquals($expected, BigInteger $actual)
{
2015-06-12 01:17:42 +02:00
$this->assertSame($expected, (string) $actual);
2014-08-31 14:13:46 +02:00
}
/**
* @param string $unscaledValue The expected unscaled value.
* @param int $scale The expected scale.
2014-08-31 14:13:46 +02:00
* @param BigDecimal $actual The BigDecimal instance to test.
*/
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
*/
protected function assertBigRationalEquals($numerator, $denominator, BigRational $actual)
{
$this->assertSame($numerator, (string) $actual->getNumerator());
$this->assertSame($denominator, (string) $actual->getDenominator());
}
2014-08-31 14:13:46 +02:00
}