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
8// <-- CLI SHELL MODE -->
9ilib_verbose(0);
10
11function test_int(safe)
12    mkdir(pathconvert(TMPDIR+"/api_c/" + safe));
13    cd(pathconvert(TMPDIR+"/api_c/" + safe));
14    copyfile(SCI+"/modules/api_scilab/tests/unit_tests/api_c/int_test.c",pathconvert(TMPDIR+"/api_c/" + safe + "/int_test.c",%F));
15
16    cflags = "";
17    if safe == "unsafe" then
18        cflags = "-D__API_SCILAB_UNSAFE__";
19    end
20
21    ilib_build("libint" + safe,["int_test","sci_int_test", "csci6"],"int_test.c",[],"","",cflags);
22    exec("loader.sce");
23
24    in1 = int32(rand(3,4) *1000);
25    in2 = int32(rand() * 1000);
26
27    [out1, out2, out3] = int_test(in1, in2);
28
29    assert_checkequal(out1, in1 * 10);
30    ref(:,:, 1) = in1 * 10;
31    ref(:,:, 2) = in1 * 100;
32    assert_checkequal(out2, ref);
33    assert_checkequal(out3, in2 * 1000);
34    disp("OK");
35endfunction
36
37test_int("safe");
38test_int("unsafe");
39