47 lines
918 B
PHP
47 lines
918 B
PHP
--TEST--
|
|
Test save/load for `Arma\Mat`.
|
|
--SKIPIF--
|
|
<?php
|
|
require_once 'includes/loaded.php';
|
|
require_once 'includes/supports.php';
|
|
if (is_php_arma_loaded()) {
|
|
supports_stream_resource();
|
|
}
|
|
?>
|
|
--ENV--
|
|
TMP_FILE=/tmp/php_arma_test.tmp
|
|
--FILE--
|
|
<?php
|
|
|
|
require_once 'includes/assert.php';
|
|
|
|
$file_name = getenv('TMP_FILE');
|
|
|
|
$mat = Arma\CxDMat::fromString('(1,2) (3,4); (5,6) (7,8)');
|
|
batch_assert('saving of `Arma\\Mat`',
|
|
[true, $mat->save($file_name, Arma\FileType::ARMA_BINARY)]
|
|
);
|
|
|
|
$mat1 = Arma\CxDMat::init();
|
|
$handle = fopen($file_name, 'r');
|
|
batch_assert('loading of `Arma\\Mat`',
|
|
[true, $mat1->load($handle, Arma\FileType::ARMA_BINARY)]
|
|
);
|
|
fclose($handle);
|
|
|
|
$eq_mat = $mat->equals($mat1);
|
|
batch_assert('loading of `Arma\\Mat`',
|
|
[1, $eq_mat->min()],
|
|
[1, $eq_mat->max()]
|
|
);
|
|
|
|
?>
|
|
--CLEAN--
|
|
<?php
|
|
$file_name = getenv('TMP_FILE');
|
|
if (file_exists($file_name)) {
|
|
unlink($file_name);
|
|
}
|
|
?>
|
|
--EXPECT--
|