1// =============================================================================
2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3// Copyright (C) 2015 - Scilab Enterprises - Antoine ELIAS
4//
5//  This file is distributed under the same license as the Scilab package.
6// =============================================================================
7// <-- CLI SHELL MODE -->
8function test_polynomial(safe)
9    ilib_verbose(0);
10    mkdir(pathconvert(TMPDIR+"/api_c/" + safe));
11    cd(pathconvert(TMPDIR+"/api_c/" + safe));
12    copyfile(SCI+"/modules/api_scilab/tests/unit_tests/api_c/polynomial_test.c",pathconvert(TMPDIR+"/api_c/" + safe + "/polynomial_test.c",%F));
13    cflags = "";
14    if safe == "unsafe" then
15        cflags = "-D__API_SCILAB_UNSAFE__";
16    end
17    ilib_build("libpolynomial" + safe,["polynomial_test","sci_polynomial_test", "csci6"],"polynomial_test.c",[],"","",cflags);
18    exec("loader.sce");
19    in1 = [10, 4*%s + 8, -5 + 6*%s - 7*%s**2;10, 4*%s + 8, -5 + 6*%s - 7*%s**2],
20    in2 = 1-%s**2;
21    [out1, out2] = polynomial_test(in1, in2);
22    assert_checkequal(out1, in1 *%s);
23    assert_checkequal(out2, -in2);
24    disp("OK");
25endfunction
26test_polynomial("safe");
27  "OK"
28test_polynomial("unsafe");
29  "OK"
30