Krinkle has uploaded a new change for review. https://gerrit.wikimedia.org/r/297103
Change subject: tests: Increase coverage for getVariance() and merge() ...................................................................... tests: Increase coverage for getVariance() and merge() https://integration.wikimedia.org/cover/RunningStat/ Change-Id: Ia66b55a90eebe6b50110858cb46071e999689f0c --- M tests/RunningStatTest.php 1 file changed, 56 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/RunningStat refs/changes/03/297103/1 diff --git a/tests/RunningStatTest.php b/tests/RunningStatTest.php index d3b64da..e0eb6bf 100644 --- a/tests/RunningStatTest.php +++ b/tests/RunningStatTest.php @@ -25,6 +25,9 @@ use RunningStat\RunningStat; +/** + * @covers RunningStat\RunningStat + */ class RunningStatTest extends \PHPUnit_Framework_TestCase { public $points = array( @@ -59,13 +62,26 @@ } /** + * @covers RunningStat\RunningStat::getVariance + */ + public function testGetVariance() { + $rstat = new RunningStat(); + $this->assertTrue( is_nan( $rstat->getVariance() ), 'Empty set' ); + + $rstat = new RunningStat(); + $rstat->addObservation( 7 ); + $this->assertEquals( $rstat->getVariance(), 0.0, 'One value' ); + } + + /** * When one RunningStat instance is merged into another, the state of the * target RunningInstance should have the state that it would have had if * all the data had been accumulated by it alone. + * + * @covers RunningStat\RunningStat::merge */ - public function testRunningStatMerge() { + public function testMergeTwo() { $expected = new RunningStat(); - foreach ( $this->points as $point ) { $expected->addObservation( $point ); } @@ -91,4 +107,42 @@ $this->assertEquals( $first->getCount(), count( $this->points ) ); $this->assertEquals( $first, $expected ); } + + /** + * @covers RunningStat\RunningStat::merge + */ + public function testMergeOne() { + $expected = new RunningStat(); + foreach ( $this->points as $point ) { + $expected->addObservation( $point ); + } + + // Empty target + $first = new RunningStat(); + + $second = new RunningStat(); + foreach ( $this->points as $point ) { + $second->addObservation( $point ); + } + + $first->merge( $second ); + + $this->assertEquals( $first->getCount(), count( $this->points ) ); + $this->assertEquals( $first, $expected ); + } + + /** + * @covers RunningStat\RunningStat::merge + */ + public function testMergeEmpty() { + $expected = new RunningStat(); + + // Empty target and subject + $first = new RunningStat(); + $second = new RunningStat(); + $first->merge( $second ); + + $this->assertEquals( $first->getCount(), 0 ); + $this->assertEquals( $first, $expected ); + } } -- To view, visit https://gerrit.wikimedia.org/r/297103 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia66b55a90eebe6b50110858cb46071e999689f0c Gerrit-PatchSet: 1 Gerrit-Project: RunningStat Gerrit-Branch: master Gerrit-Owner: Krinkle <krinklem...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits