scilab: new test scilab_li_matrix for matrix.i library

This commit is contained in:
Simon Marchetto 2014-02-20 17:46:31 +01:00
commit fc99562eff
4 changed files with 168 additions and 11 deletions

View file

@ -14,6 +14,9 @@ C_TEST_CASES += \
scilab_enums \
scilab_consts \
CPP_TEST_CASES += \
scilab_li_matrix \
CPP_STD_TEST_CASES += \
primitive_types \
inout \

View file

@ -0,0 +1,47 @@
// test matrix.i library
exec("swigtest.start", -1);
// test matrix passed as output argument from fonction
function test_out_matrix(value_type, expected_out_matrix)
cmd = msprintf("out_matrix = out_%s_matrix_func();", value_type);
ierr = execstr(cmd, "errcatch");
if ierr <> 0 then swigtesterror(); end
disp(out_matrix);
if ~isdef('expected_out_matrix') | out_matrix <> expected_out_matrix then swigtesterror(); end
endfunction
// test matrix passed as input argument of fonction
function test_in_matrix(value_type, in_matrix, expected_ret_value)
cmd = msprintf("ret_value = in_%s_matrix_func(in_matrix);", value_type);
ierr = execstr(cmd, "errcatch");
if ierr <> 0 then swigtesterror(); end
if ~isdef('ret_value') | ret_value <> expected_ret_value then swigtesterror(); end
endfunction
// test matrixes passed as input and output arguments of fonction
function test_inout_matrix(value_type, in_matrix, expected_out_matrix)
cmd = msprintf("out_matrix = inout_%s_matrix_func(in_matrix);", value_type);
ierr = execstr(cmd, "errcatch");
if ierr <> 0 then swigtesterror(); end
if ~isdef('out_matrix') | out_matrix <> expected_out_matrix then swigtesterror(); end
endfunction
function test_matrix_typemaps(value_type, expected_out_matrix, expected_ret_value, expected_out_matrix2)
test_out_matrix(value_type, expected_out_matrix);
test_in_matrix(value_type, expected_out_matrix, expected_ret_value);
test_inout_matrix(value_type, expected_out_matrix, expected_out_matrix2);
endfunction
m = [0 3; 1 4; 2 5];
test_matrix_typemaps("int", m, sum(m), m .* m);
test_matrix_typemaps("int", int32(m), sum(m), m .* m);
test_matrix_typemaps("double", m, sum(m), m .* m);
//m = ["0" "3"; "1" "4"; "2" "5"]
//test_matrix_typemaps("charptr", m, strcat(m), m + m);
exec("swigtest.quit", -1);