Source for file PolynomialTest.php
Documentation is available at PolynomialTest.php
require_once '../Polynomial.php';
//require_once 'Math/PolynomialOp.php';
require_once '../PolynomialOp.php';
require_once 'PHPUnit.php';
class Math_PolynomialTest extends PHPUnit_TestCase
function Math_PolynomialTest ($name)
$this->PHPUnit_TestCase ($name);
function testObjectConstructor ()
$this->assertTrue ($p->toString () == $q->toString ());
$this->assertTrue ($str == $p->toString ());
$this->assertEquals ('4x^2 + 5x + 2', $res->toString ());
$this->assertEquals ('x^2 - 4x + 1', $res->toString ());
$this->assertEquals ($res->toString (), '12x^3 + 10x^2 + 5x + 1');
$this->assertEquals ('1.33333333333x^3 - 0.444444444444x + 0.666666666667', $res->toString ());
function testFirstDerivative ()
$this->assertEquals ('36x^2 + 12x + 2', $first_der->toString ());
function testSecondDerivative ()
$this->assertEquals ('72x + 12', $der->toString ());
function testAntiDerivative ()
$this->assertTrue ($anti_der->toString () == $p->toString ());
$this->assertEquals ('x^3 - 9x', $p->toString ());
function testGetRootsLinear ()
$this->assertEquals (array (-2 ), $roots);
function testGetRootsQuadratic ()
$this->assertEquals (array (0.5 , -4 ), $roots);
function testGetRootsCubic ()
$this->assertEquals (array (6 , -1 , 3 ), $roots);
function testRootsQuartic ()
$this->assertEquals (array (5 , 3 , -4 , -6 ), $roots);
function testLocalMaximums ()
$this->assertEquals (array (0.796920717957544155751747894100844860076904296875 ), $maxs);
function testLocalMinimums ()
$this->assertEquals (array (33.9319316690521048940354376100003719329833984375 , -1.7288523870096472734303461038507521152496337890625 ), $maxs);
$this->assertEquals ('4.5025x - 1.68475', $tangent->toString ());
$this->assertEquals ('6x + 3', $secant->toString ());
function testParamConstness ()
$this->assertEquals ('4x^2 + 2x + 1', $p2);
header('Content-type: text/plain');
$suite = new PHPUnit_TestSuite ('Math_PolynomialTest');
$result = PHPUnit ::run ($suite);
print ($result -> toString ());
Documentation generated on Mon, 11 Mar 2019 14:38:25 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|