Home > matpower7.0 > lib > t > t_feval_w_path.m

t_feval_w_path

PURPOSE ^

T_FEVAL_W_PATH Tests for FEVAL_W_PATH.

SYNOPSIS ^

function t_feval_w_path(quiet)

DESCRIPTION ^

T_FEVAL_W_PATH  Tests for FEVAL_W_PATH.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function t_feval_w_path(quiet)
0002 %T_FEVAL_W_PATH  Tests for FEVAL_W_PATH.
0003 
0004 %   MATPOWER
0005 %   Copyright (c) 2016, Power Systems Engineering Research Center (PSERC)
0006 %   by Ray Zimmerman, PSERC Cornell
0007 %
0008 %   This file is part of MATPOWER.
0009 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0010 %   See https://matpower.org for more info.
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 %% find path to this test file
0024 cwd = pwd;
0025 [p, n, e] = fileparts(which('t_feval_w_path'));
0026 
0027 %% test with empty path (do NOT cd anywhere)
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 %% test with absolute path
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 %% switch dir to be able to use relative path
0056 cd(p);
0057 cwd2 = pwd;
0058 
0059 %% test with relative path
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;

Generated on Mon 24-Jun-2019 15:58:45 by m2html © 2005