0001 function t_feval_w_path(quiet)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 if nargin < 1
0013 quiet = 0;
0014 end
0015
0016 n_tests = 20;
0017
0018 t_begin(n_tests, quiet);
0019
0020 t = '$MATPOWER/t/t_feval_w_path must not be in path';
0021 t_ok(exist('rithmaticker') ~= 2, t);
0022
0023
0024 cwd = pwd;
0025 [p, n, e] = fileparts(which('t_feval_w_path'));
0026
0027 t = 'ab = feval_w_path(<absolute path>, fname, a, b)';
0028 rv = feval_w_path(fullfile(p, 't_feval_w_path'), 'rithmaticker', 3, 4);
0029 t_ok(strcmp(cwd, pwd), [t ' : cwd unchanged']);
0030 t_is(rv, 12, 15, t);
0031
0032 t = 'abc = feval_w_path(<absolute path>, fname, a, b, c)';
0033 rv = feval_w_path(fullfile(p, 't_feval_w_path'), 'rithmaticker', 3, 4, 5);
0034 t_ok(strcmp(cwd, pwd), [t ' : cwd unchanged']);
0035 t_is(rv, 60, 15, t);
0036
0037 t = 'abcd = feval_w_path(<absolute path>, fname, a, b, c, d)';
0038 rv = feval_w_path(fullfile(p, 't_feval_w_path'), 'rithmaticker', 3, 4, 5, 6);
0039 t_ok(strcmp(cwd, pwd), [t ' : cwd unchanged']);
0040 t_is(rv, 360, 15, t);
0041
0042 t = '[ab, a_b] = feval_w_path(<absolute path>, fname, a, b)';
0043 [rv, rv2] = feval_w_path(fullfile(p, 't_feval_w_path'), 'rithmaticker', 3, 4);
0044 t_ok(strcmp(cwd, pwd), [t ' : cwd unchanged']);
0045 t_is(rv, 12, 15, t);
0046 t_is(rv2, 7, 15, t);
0047
0048
0049 cd(p);
0050 cwd2 = pwd;
0051
0052 t = 'ab = feval_w_path(<relative path>, fname, a, b)';
0053 rv = feval_w_path('t_feval_w_path', 'rithmaticker', 3, 4);
0054 t_ok(strcmp(cwd2, pwd), [t ' : cwd unchanged']);
0055 t_is(rv, 12, 15, t);
0056
0057 t = 'abc = feval_w_path(<relative path>, fname, a, b, c)';
0058 rv = feval_w_path('t_feval_w_path', 'rithmaticker', 3, 4, 5);
0059 t_ok(strcmp(cwd2, pwd), [t ' : cwd unchanged']);
0060 t_is(rv, 60, 15, t);
0061
0062 t = 'abcd = feval_w_path(<relative path>, fname, a, b, c, d)';
0063 rv = feval_w_path('t_feval_w_path', 'rithmaticker', 3, 4, 5, 6);
0064 t_ok(strcmp(cwd2, pwd), [t ' : cwd unchanged']);
0065 t_is(rv, 360, 15, t);
0066
0067 t = '[ab, a_b] = feval_w_path(<relative path>, fname, a, b)';
0068 [rv, rv2] = feval_w_path('t_feval_w_path', 'rithmaticker', 3, 4);
0069 t_ok(strcmp(cwd2, pwd), [t ' : cwd unchanged']);
0070 t_is(rv, 12, 15, t);
0071 t_is(rv2, 7, 15, t);
0072
0073
0074 cd(cwd);
0075 t = 'successful switch to original working directory';
0076 t_ok(strcmp(cwd, pwd), t);
0077
0078 t_end;