summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKore Nordmann <github@kore-nordmann.de>2007-01-24 12:22:57 +0000
committerKore Nordmann <github@kore-nordmann.de>2007-01-24 12:22:57 +0000
commit80e1738a8474b9761036b73a4cc0180e6cee080c (patch)
tree97748bfef9deed057c42504a9056f60fbd1a5757 /tests
parent937d04f2094624af45c0241bc75f3cbef4182c70 (diff)
downloadzetacomponents-graph-80e1738a8474b9761036b73a4cc0180e6cee080c.zip
zetacomponents-graph-80e1738a8474b9761036b73a4cc0180e6cee080c.tar.gz
- Fixed issue #9950: Improved ezcGraphPolynom::__toString method for more
exact output # Based on a patch by Matthew Carroll
Diffstat (limited to 'tests')
-rw-r--r--tests/dataset_average_test.php14
-rw-r--r--tests/matrix_test.php2
-rw-r--r--tests/polynom_test.php54
3 files changed, 60 insertions, 10 deletions
diff --git a/tests/dataset_average_test.php b/tests/dataset_average_test.php
index 5cea07f..6de8821 100644
--- a/tests/dataset_average_test.php
+++ b/tests/dataset_average_test.php
@@ -68,7 +68,7 @@ class ezcGraphDataSetAverageTest extends ezcGraphTestCase
$polynom = $averageDataSet->getPolynom();
$this->assertEquals(
- 'x^2 + 1.00',
+ 'x^2 + 1',
$polynom->__toString()
);
}
@@ -90,7 +90,7 @@ class ezcGraphDataSetAverageTest extends ezcGraphTestCase
$polynom = $averageDataSet->getPolynom();
$this->assertEquals(
- '0.00 * x^2 + -1.85 * x + 1044430783.35',
+ '8.21e-10 x^2 - 1.85 x + 1.04e+9',
$polynom->__toString()
);
}
@@ -109,7 +109,7 @@ class ezcGraphDataSetAverageTest extends ezcGraphTestCase
$polynom = $averageDataSet->getPolynom();
$this->assertEquals(
- '1.00 * x^3 + -6.21 * x^2 + 13.04 * x + -11.69',
+ 'x^3 - 6.21 x^2 + 13.0 x - 11.7',
$polynom->__toString()
);
}
@@ -128,7 +128,7 @@ class ezcGraphDataSetAverageTest extends ezcGraphTestCase
$polynom = $averageDataSet->getPolynom();
$this->assertEquals(
- 'x^3 + -0.21 * x^2 + 0.20 * x + -2.45',
+ 'x^3 - 2.10e-1 x^2 + 2.00e-1 x - 2.45',
$polynom->__toString()
);
}
@@ -143,7 +143,7 @@ class ezcGraphDataSetAverageTest extends ezcGraphTestCase
$polynom = $averageDataSet->getPolynom();
$this->assertEquals(
- '2.00 * x + 2.67',
+ '2.00 x + 2.67',
$polynom->__toString()
);
}
@@ -158,7 +158,7 @@ class ezcGraphDataSetAverageTest extends ezcGraphTestCase
$polynom = $averageDataSet->getPolynom();
$this->assertEquals(
- 'x^2 + 1.00',
+ 'x^2 + 1',
$polynom->__toString()
);
}
@@ -171,7 +171,7 @@ class ezcGraphDataSetAverageTest extends ezcGraphTestCase
$polynom = $averageDataSet->getPolynom();
$this->assertEquals(
- 'x^2 + 1.00',
+ 'x^2 + 1',
$polynom->__toString()
);
}
diff --git a/tests/matrix_test.php b/tests/matrix_test.php
index 7c94209..ec54772 100644
--- a/tests/matrix_test.php
+++ b/tests/matrix_test.php
@@ -315,7 +315,7 @@ class ezcGraphMatrixTest extends ezcTestCase
$polynom = $a->solveNonlinearEquatation( $b );
$this->assertEquals(
- '-0.12 * x^2 + 0.02 * x + 0.35',
+ '-1.15e-1 x^2 + 1.92e-2 x + 3.46e-1',
$polynom->__toString()
);
}
diff --git a/tests/polynom_test.php b/tests/polynom_test.php
index 0af6f92..a492a31 100644
--- a/tests/polynom_test.php
+++ b/tests/polynom_test.php
@@ -49,7 +49,7 @@ class ezcGraphPolynomTest extends ezcTestCase
$polynom = new ezcGraphPolynom( array( 2 => .5, 1 => 3, 0 => -4.5 ) );
$this->assertEquals(
- '0.50 * x^2 + 3.00 * x + -4.50',
+ '5.00e-1 x^2 + 3.00 x - 4.50',
$polynom->__toString()
);
}
@@ -70,7 +70,7 @@ class ezcGraphPolynomTest extends ezcTestCase
$polynom->add( new ezcGraphPolynom( array( 2 => 1 ) ) );
$this->assertEquals(
- '1.50 * x^2 + 3.00 * x + -4.50',
+ '1.50 x^2 + 3.00 x - 4.50',
$polynom->__toString()
);
}
@@ -110,6 +110,56 @@ class ezcGraphPolynomTest extends ezcTestCase
.1
);
}
+
+ public function testPolynomToString1()
+ {
+ $polynom = new ezcGraphPolynom( array(
+ -109384,
+ -19322,
+ -9032,
+ -984.2,
+ -32.65,
+ -5.613,
+ -1,
+ -.9345,
+ -.0,
+ -.03245,
+ -.002346,
+ -.0001326,
+ -.00008327,
+ -.000008437,
+ ) );
+
+ $this->assertEquals(
+ '-8.44e-6 x^13 - 8.33e-5 x^12 - 1.33e-4 x^11 - 2.35e-3 x^10 - 3.25e-2 x^9 - 9.35e-1 x^7 - x^6 - 5.61 x^5 - 32.6 x^4 - 984 x^3 - 9.03e+3 x^2 - 1.93e+4 x - 1.09e+5',
+ $polynom->__toString()
+ );
+ }
+
+ public function testPolynomToString2()
+ {
+ $polynom = new ezcGraphPolynom( array(
+ 109384,
+ 19322,
+ 9032,
+ 984.2,
+ 32.65,
+ 5.613,
+ 1,
+ .9345,
+ .0,
+ .03245,
+ .002346,
+ .0001326,
+ .00008327,
+ .000008437,
+ ) );
+
+ $this->assertEquals(
+ '8.44e-6 x^13 + 8.33e-5 x^12 + 1.33e-4 x^11 + 2.35e-3 x^10 + 3.25e-2 x^9 + 9.35e-1 x^7 + x^6 + 5.61 x^5 + 32.6 x^4 + 984 x^3 + 9.03e+3 x^2 + 1.93e+4 x + 1.09e+5',
+ $polynom->__toString()
+ );
+ }
}
?>
OpenPOWER on IntegriCloud