summaryrefslogtreecommitdiff
path: root/modules/polynomials/tests/unit_tests/pol2str.tst
blob: 4ac003f252979d513973d2b1153bc972251f82dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// =============================================================================
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) 2011 - DIGITEO - Allan CORNET
//
//  This file is distributed under the same license as the Scilab package.
// =============================================================================

// <-- CLI SHELL MODE -->

assert_checkequal(pol2str(%z), "z");
assert_checkequal(pol2str([%z %z]), ["z", "z"]);

p = poly ([1, 2, 3], "x","coeff");
P = [p, p ,p ; p, p, p];
R = pol2str(P);
REF = ["1+2*x+3*x^2", "1+2*x+3*x^2", "1+2*x+3*x^2";
"1+2*x+3*x^2", "1+2*x+3*x^2", "1+2*x+3*x^2"];

assert_checkequal(R, REF);

msgerror = msprintf(gettext("%s: Wrong type for input argument #%d: Polynomial expected.\n"), "pol2str", 1);
assert_checkerror("pol2str(1)", msgerror);

assert_checkequal(pol2str(%i*%z),"%i*z");
ref = hypermat([1 1 2], ["1+0.8497452*z";"1+0.685731*z"]);
assert_checktrue(and(pol2str(1+hypermat([1 1 2], [0.8497452;0.6857310])*%z) == ref));