Add a error message when get_function_path has not input argument and fix test win... 18/11018/2
Adeline CARNIS [Tue, 26 Mar 2013 13:27:55 +0000 (14:27 +0100)]
Change-Id: I5ac0fc19f4b1c8a8be02f49d1a7b672851db0e4c

scilab/modules/functions/macros/get_function_path.sci
scilab/modules/functions/tests/unit_tests/get_function_path.dia.ref
scilab/modules/functions/tests/unit_tests/get_function_path.tst

index cc43e56..8baf8e9 100644 (file)
@@ -1,6 +1,7 @@
 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
 // Copyright (C) INRIA
 // Copyright (C) DIGITEO - 2009-2010 - Allan CORNET
+// Copyright (C) 2013 - Scilab Enterprises - Adeline CARNIS
 //
 // This file must be used under the terms of the CeCILL.
 // This source file is licensed as described in the file COPYING, which
 function path = get_function_path(name)
 
   path = [];
+  rhs = argn(2);
+  
+  if rhs == 0 then
+      error(msprintf(gettext("%s: Wrong number of input argument: %d expected.\n"), "get_function_path", 1));
+  end
 
   if type(name) <> 10 then
     error(999,msprintf(_("%s: Wrong type for input argument #%d: A string expected.\n"),"get_function_path",1));
index 36f896d..b74d5b4 100644 (file)
@@ -7,14 +7,18 @@
 // <-- CLI SHELL MODE -->
 // unit tests for get_function_path() function
 // =============================================================================
-assert_checkequal(get_function_path('abcd'),SCI+'/modules/cacsd/macros/abcd.sci');
-assert_checkequal(get_function_path('dae'),SCI+'/modules/differential_equations/macros/dae.sci');
-assert_checkequal(get_function_path('acosd'),SCI+'/modules/elementary_functions/macros/acosd.sci');
-assert_checkequal(get_function_path('dir'),SCI+'/modules/fileio/macros/dir.sci');
-assert_checkequal(get_function_path('get_function_path'),SCI+'/modules/functions/macros/get_function_path.sci');
-assert_checkequal(get_function_path('get_param'),SCI+'/modules/parameters/macros/get_param.sci');
-assert_checkequal(get_function_path('median'),SCI+'/modules/statistics/macros/median.sci');
-assert_checkequal(get_function_path('calendar'),SCI+'/modules/time/macros/calendar.sci');
+assert_checkequal(get_function_path('abcd'), pathconvert(getlongpathname(SCI+'/modules/cacsd/macros/abcd.sci'), %f));
+assert_checkequal(get_function_path('dae'), pathconvert(getlongpathname(SCI+'/modules/differential_equations/macros/dae.sci'), %f));
+assert_checkequal(get_function_path('acosd'), pathconvert(getlongpathname(SCI+'/modules/elementary_functions/macros/acosd.sci'), %f));
+assert_checkequal(get_function_path('dir'), pathconvert(getlongpathname(SCI+'/modules/fileio/macros/dir.sci'), %f));
+assert_checkequal(get_function_path('get_function_path'), pathconvert(getlongpathname(SCI+'/modules/functions/macros/get_function_path.sci'), %f));
+assert_checkequal(get_function_path('get_param'), pathconvert(getlongpathname(SCI+'/modules/parameters/macros/get_param.sci'), %f));
+assert_checkequal(get_function_path('median'), pathconvert(getlongpathname(SCI+'/modules/statistics/macros/median.sci'), %f));
+assert_checkequal(get_function_path('calendar'), pathconvert(getlongpathname(SCI+'/modules/time/macros/calendar.sci'), %f));
 assert_checkequal(get_function_path('eigs.sci'),[]);
 assert_checkfalse(execstr("get_function_path()","errcatch")==0);
+refMsg = msprintf(_("%s: Wrong number of input argument: %d expected.\n"), "get_function_path", 1);
+assert_checkerror("get_function_path()", refMsg);
 assert_checkfalse(execstr("get_function_path(eigs)","errcatch")==0);
+refMsg = msprintf(_("%s: Wrong type for input argument #%d: A string expected.\n"),"get_function_path",1);
+assert_checkerror("get_function_path(eigs)", refMsg);
index 6813419..4487077 100644 (file)
 // unit tests for get_function_path() function
 // =============================================================================
 
-assert_checkequal(get_function_path('abcd'),SCI+'/modules/cacsd/macros/abcd.sci');
-assert_checkequal(get_function_path('dae'),SCI+'/modules/differential_equations/macros/dae.sci');
-assert_checkequal(get_function_path('acosd'),SCI+'/modules/elementary_functions/macros/acosd.sci');
-assert_checkequal(get_function_path('dir'),SCI+'/modules/fileio/macros/dir.sci');
-assert_checkequal(get_function_path('get_function_path'),SCI+'/modules/functions/macros/get_function_path.sci');
-assert_checkequal(get_function_path('get_param'),SCI+'/modules/parameters/macros/get_param.sci');
-assert_checkequal(get_function_path('median'),SCI+'/modules/statistics/macros/median.sci');
-assert_checkequal(get_function_path('calendar'),SCI+'/modules/time/macros/calendar.sci');
+assert_checkequal(get_function_path('abcd'), pathconvert(getlongpathname(SCI+'/modules/cacsd/macros/abcd.sci'), %f));
+assert_checkequal(get_function_path('dae'), pathconvert(getlongpathname(SCI+'/modules/differential_equations/macros/dae.sci'), %f));
+assert_checkequal(get_function_path('acosd'), pathconvert(getlongpathname(SCI+'/modules/elementary_functions/macros/acosd.sci'), %f));
+assert_checkequal(get_function_path('dir'), pathconvert(getlongpathname(SCI+'/modules/fileio/macros/dir.sci'), %f));
+assert_checkequal(get_function_path('get_function_path'), pathconvert(getlongpathname(SCI+'/modules/functions/macros/get_function_path.sci'), %f));
+assert_checkequal(get_function_path('get_param'), pathconvert(getlongpathname(SCI+'/modules/parameters/macros/get_param.sci'), %f));
+assert_checkequal(get_function_path('median'), pathconvert(getlongpathname(SCI+'/modules/statistics/macros/median.sci'), %f));
+assert_checkequal(get_function_path('calendar'), pathconvert(getlongpathname(SCI+'/modules/time/macros/calendar.sci'), %f));
 
 assert_checkequal(get_function_path('eigs.sci'),[]);
 assert_checkfalse(execstr("get_function_path()","errcatch")==0);
+refMsg = msprintf(_("%s: Wrong number of input argument: %d expected.\n"), "get_function_path", 1);
+assert_checkerror("get_function_path()", refMsg);
 assert_checkfalse(execstr("get_function_path(eigs)","errcatch")==0);
+refMsg = msprintf(_("%s: Wrong type for input argument #%d: A string expected.\n"),"get_function_path",1);
+assert_checkerror("get_function_path(eigs)", refMsg);