fix and add test cases for cpySize()
.
This commit is contained in:
parent
cb593e3a39
commit
aeba61a787
|
@ -41,16 +41,18 @@ namespace php_arma
|
|||
Z_PARAM_ZVAL(other)
|
||||
ZEND_PARSE_PARAMETERS_END();
|
||||
|
||||
if (UNEXPECTED(Z_TYPE_P(other) != IS_OBJECT || instanceof_function(Z_OBJCE_P(other), base_ce))) {
|
||||
if (UNEXPECTED(Z_TYPE_P(other) != IS_OBJECT || !instanceof_function(Z_OBJCE_P(other), base_ce))) {
|
||||
ex_bad_type(ZSTR_VAL(base_ce->name), zval_get_type_name(other));
|
||||
return;
|
||||
}
|
||||
|
||||
std::variant<ds::base*, ds::subview*, ds::diagview*> other_native_v;
|
||||
if (instanceof_function(Z_OBJCE_P(other), subview_ce)) {
|
||||
if (instanceof_function(Z_OBJCE_P(other), diagonal_ce)) {
|
||||
other_native_v = to_native_object<ds::diagview>(Z_OBJ_P(other));
|
||||
} else if (instanceof_function(Z_OBJCE_P(other), subview_ce)) {
|
||||
} else {
|
||||
other_native_v = to_native_object<ds::subview>(Z_OBJ_P(other));
|
||||
}
|
||||
} else {
|
||||
other_native_v = to_native_object<ds::base>(Z_OBJ_P(other));
|
||||
}
|
||||
|
|
25
tests/020-copy-size.phpt
Normal file
25
tests/020-copy-size.phpt
Normal file
|
@ -0,0 +1,25 @@
|
|||
--TEST--
|
||||
Test for method `copySize()`
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once 'includes/loaded.php';
|
||||
is_php_arma_loaded();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once 'includes/assert.php';
|
||||
|
||||
$imat = Arma\IMat::init(3, 3);
|
||||
$dmat = Arma\DMat::init(2, 5);
|
||||
$dmat->copySize($dmat->submat(0, 1, 1, 3));
|
||||
$imat->copySize($imat->diag());
|
||||
batch_assert('method `copySize()`',
|
||||
[$dmat->nRows(), 2],
|
||||
[$dmat->nCols(), 3],
|
||||
[$imat->nRows(), 3],
|
||||
[$imat->nCols(), 1]
|
||||
);
|
||||
|
||||
?>
|
||||
--EXPECT--
|
Reference in New Issue
Block a user