From 492430ea8a17eaa99019c931cf633ba26a36021e Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Thu, 18 Apr 2019 22:56:08 +0200 Subject: [PATCH] Split up tests --- .../Matrix/SingularValueDecompositionTest.php | 25 ++++++++++++++++++- tests/System/SystemUtilsTest.php | 17 +++++++++++-- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/tests/Math/Matrix/SingularValueDecompositionTest.php b/tests/Math/Matrix/SingularValueDecompositionTest.php index 3b417c72b..cb6a78dac 100644 --- a/tests/Math/Matrix/SingularValueDecompositionTest.php +++ b/tests/Math/Matrix/SingularValueDecompositionTest.php @@ -16,9 +16,15 @@ namespace phpOMS\tests\Math\Matrix; use phpOMS\Math\Matrix\Matrix; use phpOMS\Math\Matrix\SingularValueDecomposition; +/** + * @testdox phpOMS\tests\Math\Matrix\SingularValueDecompositionTest: Singular Value Decomposition + */ class SingularValueDecompositionTest extends \PHPUnit\Framework\TestCase { - public function testDecomposition() : void + /** + * @testdox Test the correct rank calculation + */ + public function testRankCalculation() : void { $A = new Matrix(); $A->setMatrix([ @@ -29,6 +35,20 @@ class SingularValueDecompositionTest extends \PHPUnit\Framework\TestCase $svd = new SingularValueDecomposition($A); self::assertEquals(2, $svd->rank()); + } + + /** + * @testdox Test the correct calculation of U, S and V + */ + public function testSUVCalculation() : void + { + $A = new Matrix(); + $A->setMatrix([ + [2, -2, 1], + [5, 1, 4], + ]); + + $svd = new SingularValueDecomposition($A); self::assertEquals([ [-0.3092, -0.9510], @@ -48,6 +68,9 @@ class SingularValueDecompositionTest extends \PHPUnit\Framework\TestCase ], $svd->getV()->toArray(), '', 0.2); } + /** + * @testdox Test A = S * U * V' + */ public function testComposition() : void { $A = new Matrix(); diff --git a/tests/System/SystemUtilsTest.php b/tests/System/SystemUtilsTest.php index 8cc80abe7..2d4428b14 100644 --- a/tests/System/SystemUtilsTest.php +++ b/tests/System/SystemUtilsTest.php @@ -17,12 +17,17 @@ use phpOMS\System\SystemUtils; require_once __DIR__ . '/../Autoloader.php'; +/** + * @testdox phpOMS\System\SystemUtils: System information + */ class SystemUtilsTest extends \PHPUnit\Framework\TestCase { - public function testSystem() : void + /** + * @testdox Test if it is possible to get information about the available RAM and usage (on Windows) + */ + public function testRAM() : void { self::assertGreaterThan(0, SystemUtils::getRAM()); - self::assertGreaterThan(0, SystemUtils::getCpuUsage()); if (\stristr(PHP_OS, 'WIN')) { self::assertEquals(0, SystemUtils::getRAMUsage()); @@ -32,4 +37,12 @@ class SystemUtilsTest extends \PHPUnit\Framework\TestCase self::assertGreaterThan(0, SystemUtils::getRAMUsage()); } } + + /** + * @testdox Test if it is possible to get information about the CPU usage + */ + public function testCPUUsage() : void + { + self::assertGreaterThan(0, SystemUtils::getCpuUsage()); + } }