Add test for `save()` and `load()` of `Mat`.

This commit is contained in:
CismonX 2019-05-30 12:55:59 +08:00
parent 37da00eb75
commit 57a3d1871d
1 changed files with 39 additions and 0 deletions

View File

@ -0,0 +1,39 @@
--TEST--
Test save/load for `Arma\Mat`.
--SKIPIF--
<?php
require_once 'includes/loaded.php';
is_php_arma_loaded();
?>
--FILE--
<?php
require_once 'includes/assert.php';
$file_name = 'test_mat_data';
$mat = Arma\CxDMat::fromString('(1 2) (3 4); (5 6) (7 8)');
batch_assert('saving/loading of `Arma\\Mat`',
[true, $mat->save($file_name, Arma\FileType::ARMA_BINARY)]
);
$mat1 = Arma\CxDMat::init();
$handle = fopen($file_name, 'r');
batch_assert('saving/loading of `Arma\\Mat`',
[true, $mat1->load($handle, Arma\FileType::ARMA_BINARY)]
);
$eq_mat = $mat->equals($mat1);
batch_assert('saving/loading of `Arma\\Mat`',
[1, $eq_mat->min()],
[1, $eq_mat->max()]
);
?>
--CLEAN--
<?php
if (file_exists($file_name)) {
unlink($file_name);
}
?>
--EXPECT--