Split up tests

This commit is contained in:
Dennis Eichhorn 2019-04-18 22:56:08 +02:00
parent 65b9c41dbf
commit 492430ea8a
2 changed files with 39 additions and 3 deletions

View File

@ -16,9 +16,15 @@ namespace phpOMS\tests\Math\Matrix;
use phpOMS\Math\Matrix\Matrix; use phpOMS\Math\Matrix\Matrix;
use phpOMS\Math\Matrix\SingularValueDecomposition; use phpOMS\Math\Matrix\SingularValueDecomposition;
/**
* @testdox phpOMS\tests\Math\Matrix\SingularValueDecompositionTest: Singular Value Decomposition
*/
class SingularValueDecompositionTest extends \PHPUnit\Framework\TestCase class SingularValueDecompositionTest extends \PHPUnit\Framework\TestCase
{ {
public function testDecomposition() : void /**
* @testdox Test the correct rank calculation
*/
public function testRankCalculation() : void
{ {
$A = new Matrix(); $A = new Matrix();
$A->setMatrix([ $A->setMatrix([
@ -29,6 +35,20 @@ class SingularValueDecompositionTest extends \PHPUnit\Framework\TestCase
$svd = new SingularValueDecomposition($A); $svd = new SingularValueDecomposition($A);
self::assertEquals(2, $svd->rank()); 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([ self::assertEquals([
[-0.3092, -0.9510], [-0.3092, -0.9510],
@ -48,6 +68,9 @@ class SingularValueDecompositionTest extends \PHPUnit\Framework\TestCase
], $svd->getV()->toArray(), '', 0.2); ], $svd->getV()->toArray(), '', 0.2);
} }
/**
* @testdox Test A = S * U * V'
*/
public function testComposition() : void public function testComposition() : void
{ {
$A = new Matrix(); $A = new Matrix();

View File

@ -17,12 +17,17 @@ use phpOMS\System\SystemUtils;
require_once __DIR__ . '/../Autoloader.php'; require_once __DIR__ . '/../Autoloader.php';
/**
* @testdox phpOMS\System\SystemUtils: System information
*/
class SystemUtilsTest extends \PHPUnit\Framework\TestCase 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::getRAM());
self::assertGreaterThan(0, SystemUtils::getCpuUsage());
if (\stristr(PHP_OS, 'WIN')) { if (\stristr(PHP_OS, 'WIN')) {
self::assertEquals(0, SystemUtils::getRAMUsage()); self::assertEquals(0, SystemUtils::getRAMUsage());
@ -32,4 +37,12 @@ class SystemUtilsTest extends \PHPUnit\Framework\TestCase
self::assertGreaterThan(0, SystemUtils::getRAMUsage()); 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());
}
} }