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 = 23;
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
0028 t = 'ab = feval_w_path(<empty path>, fname, a, b)';
0029 rv = feval_w_path('', 't_ok', 1, 'true');
0030 t_ok(strcmp(cwd, pwd), [t ' : cwd unchanged']);
0031 t_is(rv, 1, 15, t);
0032
0033
0034 t = 'ab = feval_w_path(<absolute path>, fname, a, b)';
0035 rv = feval_w_path(fullfile(p, 't_feval_w_path'), 'rithmaticker', 3, 4);
0036 t_ok(strcmp(cwd, pwd), [t ' : cwd unchanged']);
0037 t_is(rv, 12, 15, t);
0038
0039 t = 'abc = feval_w_path(<absolute path>, fname, a, b, c)';
0040 rv = feval_w_path(fullfile(p, 't_feval_w_path'), 'rithmaticker', 3, 4, 5);
0041 t_ok(strcmp(cwd, pwd), [t ' : cwd unchanged']);
0042 t_is(rv, 60, 15, t);
0043
0044 t = 'abcd = feval_w_path(<absolute path>, fname, a, b, c, d)';
0045 rv = feval_w_path(fullfile(p, 't_feval_w_path'), 'rithmaticker', 3, 4, 5, 6);
0046 t_ok(strcmp(cwd, pwd), [t ' : cwd unchanged']);
0047 t_is(rv, 360, 15, t);
0048
0049 t = '[ab, a_b] = feval_w_path(<absolute path>, fname, a, b)';
0050 [rv, rv2] = feval_w_path(fullfile(p, 't_feval_w_path'), 'rithmaticker', 3, 4);
0051 t_ok(strcmp(cwd, pwd), [t ' : cwd unchanged']);
0052 t_is(rv, 12, 15, t);
0053 t_is(rv2, 7, 15, t);
0054
0055
0056 cd(p);
0057 cwd2 = pwd;
0058
0059
0060 t = 'ab = feval_w_path(<relative path>, fname, a, b)';
0061 rv = feval_w_path('t_feval_w_path', 'rithmaticker', 3, 4);
0062 t_ok(strcmp(cwd2, pwd), [t ' : cwd unchanged']);
0063 t_is(rv, 12, 15, t);
0064
0065 t = 'abc = feval_w_path(<relative path>, fname, a, b, c)';
0066 rv = feval_w_path('t_feval_w_path', 'rithmaticker', 3, 4, 5);
0067 t_ok(strcmp(cwd2, pwd), [t ' : cwd unchanged']);
0068 t_is(rv, 60, 15, t);
0069
0070 t = 'abcd = feval_w_path(<relative path>, fname, a, b, c, d)';
0071 rv = feval_w_path('t_feval_w_path', 'rithmaticker', 3, 4, 5, 6);
0072 t_ok(strcmp(cwd2, pwd), [t ' : cwd unchanged']);
0073 t_is(rv, 360, 15, t);
0074
0075 t = '[ab, a_b] = feval_w_path(<relative path>, fname, a, b)';
0076 [rv, rv2] = feval_w_path('t_feval_w_path', 'rithmaticker', 3, 4);
0077 t_ok(strcmp(cwd2, pwd), [t ' : cwd unchanged']);
0078 t_is(rv, 12, 15, t);
0079 t_is(rv2, 7, 15, t);
0080
0081 cd(cwd);
0082 t = 'successful switch to original working directory';
0083 t_ok(strcmp(cwd, pwd), t);
0084
0085 t_end;