diff options
author | Kore Nordmann <github@kore-nordmann.de> | 2007-03-01 14:13:42 +0000 |
---|---|---|
committer | Kore Nordmann <github@kore-nordmann.de> | 2007-03-01 14:13:42 +0000 |
commit | 5ccc6648a4832f3343305fc0074bf86709baad14 (patch) | |
tree | 80a9cbc57ac042f21c077dc1f231edb6d180556d /tests | |
parent | 76010f9f5aa62a1f1925b122a6e15e826f7f5564 (diff) | |
download | zetacomponents-graph-5ccc6648a4832f3343305fc0074bf86709baad14.zip zetacomponents-graph-5ccc6648a4832f3343305fc0074bf86709baad14.tar.gz |
- Fixed issue #10246: sprintf output modification in PHP 5.2.1
Diffstat (limited to 'tests')
-rw-r--r-- | tests/dataset_average_test.php | 61 | ||||
-rw-r--r-- | tests/matrix_test.php | 29 | ||||
-rw-r--r-- | tests/polynom_test.php | 94 |
3 files changed, 182 insertions, 2 deletions
diff --git a/tests/dataset_average_test.php b/tests/dataset_average_test.php index 6de8821..883192f 100644 --- a/tests/dataset_average_test.php +++ b/tests/dataset_average_test.php @@ -73,8 +73,40 @@ class ezcGraphDataSetAverageTest extends ezcGraphTestCase ); } + public function testCreateDatasetFromDataset3_52() + { + if ( version_compare( phpversion(), '5.2.0', '>' ) ) + { + $this->markTestSkipped( "This test is only for PHP prior 5.2.1. See PHP bug #40482." ); + } + + date_default_timezone_set( 'MET' ); + $arrayDataSet = new ezcGraphArrayDataSet( array( + strtotime( 'Jun 2006' ) => 1300000, + strtotime( 'May 2006' ) => 1200000, + strtotime( 'Apr 2006' ) => 1100000, + strtotime( 'Mar 2006' ) => 1100000, + strtotime( 'Feb 2006' ) => 1000000, + strtotime( 'Jan 2006' ) => 965000, + ) ); + + $averageDataSet = new ezcGraphDataSetAveragePolynom( $arrayDataSet, 2 ); + + $polynom = $averageDataSet->getPolynom(); + + $this->assertEquals( + '8.2e-10 x^2 - 1.85 x + 1.0e+9', + $polynom->__toString() + ); + } + public function testCreateDatasetFromDataset3() { + if ( version_compare( phpversion(), '5.2.1', '<' ) ) + { + $this->markTestSkipped( "This test is only for PHP after 5.2.1. See PHP bug #40482." ); + } + date_default_timezone_set( 'MET' ); $arrayDataSet = new ezcGraphArrayDataSet( array( strtotime( 'Jun 2006' ) => 1300000, @@ -114,8 +146,37 @@ class ezcGraphDataSetAverageTest extends ezcGraphTestCase ); } + public function testCreateDatasetFromDataset5_52() + { + if ( version_compare( phpversion(), '5.2.0', '>' ) ) + { + $this->markTestSkipped( "This test is only for PHP prior 5.2.1. See PHP bug #40482." ); + } + + $points = array(); + for ( $x = -3; $x <= 3; ++$x ) + { + $points[$x] = pow( $x, 3 ) - .21 * pow( $x, 2 ) + .2 * $x - 2.45; + } + + $arrayDataSet = new ezcGraphArrayDataSet( $points ); + + $averageDataSet = new ezcGraphDataSetAveragePolynom( $arrayDataSet, 3 ); + $polynom = $averageDataSet->getPolynom(); + + $this->assertEquals( + 'x^3 - 2.1e-1 x^2 + 2.0e-1 x - 2.45', + $polynom->__toString() + ); + } + public function testCreateDatasetFromDataset5() { + if ( version_compare( phpversion(), '5.2.1', '<' ) ) + { + $this->markTestSkipped( "This test is only for PHP after 5.2.1. See PHP bug #40482." ); + } + $points = array(); for ( $x = -3; $x <= 3; ++$x ) { diff --git a/tests/matrix_test.php b/tests/matrix_test.php index ec54772..53848de 100644 --- a/tests/matrix_test.php +++ b/tests/matrix_test.php @@ -301,8 +301,37 @@ class ezcGraphMatrixTest extends ezcTestCase ); } + public function testSolveNonlinearEquatation_52() + { + if ( version_compare( phpversion(), '5.2.0', '>' ) ) + { + $this->markTestSkipped( "This test is only for PHP prior 5.2.1. See PHP bug #40482." ); + } + + $a = new ezcGraphMatrix( 3, 3, array( + array( 5, 4, 7 ), + array( 2, 12, 8 ), + array( 3, 6, 10 ), + ) ); + $b = new ezcGraphMatrix( 3, 1, array( + array( 1, 2, 3 ), + ) ); + + $polynom = $a->solveNonlinearEquatation( $b ); + + $this->assertEquals( + '-1.2e-1 x^2 + 1.9e-2 x + 3.5e-1', + $polynom->__toString() + ); + } + public function testSolveNonlinearEquatation() { + if ( version_compare( phpversion(), '5.2.1', '<' ) ) + { + $this->markTestSkipped( "This test is only for PHP after 5.2.1. See PHP bug #40482." ); + } + $a = new ezcGraphMatrix( 3, 3, array( array( 5, 4, 7 ), array( 2, 12, 8 ), diff --git a/tests/polynom_test.php b/tests/polynom_test.php index a492a31..bef73fc 100644 --- a/tests/polynom_test.php +++ b/tests/polynom_test.php @@ -44,8 +44,28 @@ class ezcGraphPolynomTest extends ezcTestCase ); } + public function testCreatePolynom2_52() + { + if ( version_compare( phpversion(), '5.2.0', '>' ) ) + { + $this->markTestSkipped( "This test is only for PHP prior 5.2.1. See PHP bug #40482." ); + } + + $polynom = new ezcGraphPolynom( array( 2 => .5, 1 => 3, 0 => -4.5 ) ); + + $this->assertEquals( + '5.0e-1 x^2 + 3.00 x - 4.50', + $polynom->__toString() + ); + } + public function testCreatePolynom2() { + if ( version_compare( phpversion(), '5.2.1', '<' ) ) + { + $this->markTestSkipped( "This test is only for PHP after 5.2.1. See PHP bug #40482." ); + } + $polynom = new ezcGraphPolynom( array( 2 => .5, 1 => 3, 0 => -4.5 ) ); $this->assertEquals( @@ -111,8 +131,43 @@ class ezcGraphPolynomTest extends ezcTestCase ); } + public function testPolynomToString1_52() + { + if ( version_compare( phpversion(), '5.2.0', '>' ) ) + { + $this->markTestSkipped( "This test is only for PHP prior 5.2.1. See PHP bug #40482." ); + } + + $polynom = new ezcGraphPolynom( array( + -109384, + -19322, + -9032, + -984.2, + -32.65, + -5.613, + -1, + -.9345, + -.0, + -.03245, + -.002346, + -.0001326, + -.00008327, + -.000008437, + ) ); + + $this->assertEquals( + '-8.4e-6 x^13 - 8.3e-5 x^12 - 1.3e-4 x^11 - 2.3e-3 x^10 - 3.2e-2 x^9 - 9.3e-1 x^7 - x^6 - 5.61 x^5 - 32.6 x^4 - 984 x^3 - 9.0e+3 x^2 - 1.9e+4 x - 1.1e+5', + $polynom->__toString() + ); + } + public function testPolynomToString1() { + if ( version_compare( phpversion(), '5.2.1', '<' ) ) + { + $this->markTestSkipped( "This test is only for PHP after 5.2.1. See PHP bug #40482." ); + } + $polynom = new ezcGraphPolynom( array( -109384, -19322, @@ -131,13 +186,48 @@ class ezcGraphPolynomTest extends ezcTestCase ) ); $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', + '-8.44e-6 x^13 - 8.33e-5 x^12 - 1.33e-4 x^11 - 2.35e-3 x^10 - 3.24e-2 x^9 - 9.34e-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_52() + { + if ( version_compare( phpversion(), '5.2.0', '>' ) ) + { + $this->markTestSkipped( "This test is only for PHP prior 5.2.1. See PHP bug #40482." ); + } + + $polynom = new ezcGraphPolynom( array( + 109384, + 19322, + 9032, + 984.2, + 32.65, + 5.613, + 1, + .9345, + .0, + .03245, + .002346, + .0001326, + .00008327, + .000008437, + ) ); + + $this->assertEquals( + '8.4e-6 x^13 + 8.3e-5 x^12 + 1.3e-4 x^11 + 2.3e-3 x^10 + 3.2e-2 x^9 + 9.3e-1 x^7 + x^6 + 5.61 x^5 + 32.6 x^4 + 984 x^3 + 9.0e+3 x^2 + 1.9e+4 x + 1.1e+5', $polynom->__toString() ); } public function testPolynomToString2() { + if ( version_compare( phpversion(), '5.2.1', '<' ) ) + { + $this->markTestSkipped( "This test is only for PHP after 5.2.1. See PHP bug #40482." ); + } + $polynom = new ezcGraphPolynom( array( 109384, 19322, @@ -156,7 +246,7 @@ class ezcGraphPolynomTest extends ezcTestCase ) ); $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', + '8.44e-6 x^13 + 8.33e-5 x^12 + 1.33e-4 x^11 + 2.35e-3 x^10 + 3.24e-2 x^9 + 9.34e-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() ); } |