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 -->
9
10function test_string(safe)
11    ilib_verbose(0);
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/string_test.c",pathconvert(TMPDIR+"/api_c/" + safe + "/string_test.c",%F));
15
16    cflags = "";
17    if safe == "unsafe" then
18        cflags = "-D__API_SCILAB_UNSAFE__";
19    end
20
21    ilib_build("libstring" + safe,["string_test","sci_string_test", "csci6"],"string_test.c",[],"","",cflags);
22    exec("loader.sce");
23
24    in1 = ["one.one", "one.two", "one.three", "one.four"; "two.one", "two.two", "two.three", "two.four"; "three.one", "three.two", "three.three", "three.four"];
25    in2 = "IBM©";
26
27    [out1, out2] = string_test(in1, in2);
28    ref(:,:,1) = in1 + ".one";
29    ref(:,:,2) = in1 + ".two";
30    assert_checkequal(out1, ref);
31    assert_checkequal(out2, "HAL©");
32    disp("OK");
33endfunction
34
35test_string("safe");
36test_string("unsafe");
37