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 -->
8ilib_verbose(0);
9function test_cell(safe)
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/cell_test.c",pathconvert(TMPDIR+"/api_c/" + safe + "/cell_test.c",%F));
13    cflags = "";
14    if safe == "unsafe" then
15        cflags = "-D__API_SCILAB_UNSAFE__";
16    end
17    ilib_build("libcell" + safe,["cell_test","sci_cell_test", "csci6"],"cell_test.c",[],"","",cflags);
18    exec("loader.sce");
19    data = list(1, "2", %t, %s, list(1,2,3), {1,2;3,4});
20    c = cell_test([2 3], data);
21    assert_checkequal(typeof(c), "ce");
22    assert_checkequal(c{1, 1}, 1);
23    assert_checkequal(c{2, 1}, "2");
24    assert_checkequal(c{1, 2}, %t);
25    assert_checkequal(c{2, 2}, %s);
26    assert_checkequal(c{1, 3}, list(1,2,3));
27    assert_checkequal(c{2, 3}, {1,2;3,4});
28    disp("OK");
29endfunction
30test_cell("safe");
31  "OK"
32test_cell("unsafe");
33  "OK"
34