Home > matpower5.0 > t > t_ok.m

t_ok

PURPOSE ^

T_OK Tests if a condition is true.

SYNOPSIS ^

function ok = t_ok(cond, msg)

DESCRIPTION ^

T_OK  Tests if a condition is true.
   T_OK(EXPR, MSG) increments the global test count and if the EXPR
   is true it increments the passed tests count, otherwise increments
   the failed tests count. Prints 'ok' or 'not ok' followed by the
   MSG, unless the global variable t_quiet is true. Intended to be
   called between calls to T_BEGIN and T_END.

   Optionally returns a true or false value indicating whether or
   not the test succeeded.

   Example:
       quiet = 0;
       t_begin(5, quiet);
       t_ok(pi > 3, 'size of pi');
       t_skip(3, 'not yet written');
       t_is(2+2, 4, 12, '2+2 still equals 4');
       t_end;

   See also T_IS, T_SKIP, T_BEGIN, T_END, T_RUN_TESTS.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function ok = t_ok(cond, msg)
0002 %T_OK  Tests if a condition is true.
0003 %   T_OK(EXPR, MSG) increments the global test count and if the EXPR
0004 %   is true it increments the passed tests count, otherwise increments
0005 %   the failed tests count. Prints 'ok' or 'not ok' followed by the
0006 %   MSG, unless the global variable t_quiet is true. Intended to be
0007 %   called between calls to T_BEGIN and T_END.
0008 %
0009 %   Optionally returns a true or false value indicating whether or
0010 %   not the test succeeded.
0011 %
0012 %   Example:
0013 %       quiet = 0;
0014 %       t_begin(5, quiet);
0015 %       t_ok(pi > 3, 'size of pi');
0016 %       t_skip(3, 'not yet written');
0017 %       t_is(2+2, 4, 12, '2+2 still equals 4');
0018 %       t_end;
0019 %
0020 %   See also T_IS, T_SKIP, T_BEGIN, T_END, T_RUN_TESTS.
0021 
0022 %   MATPOWER
0023 %   $Id: t_ok.m 2374 2014-08-11 15:16:35Z ray $
0024 %   by Ray Zimmerman, PSERC Cornell
0025 %   Copyright (c) 2004-2014 by Power System Engineering Research Center (PSERC)
0026 %
0027 %   This file is part of MATPOWER.
0028 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0029 %
0030 %   MATPOWER is free software: you can redistribute it and/or modify
0031 %   it under the terms of the GNU General Public License as published
0032 %   by the Free Software Foundation, either version 3 of the License,
0033 %   or (at your option) any later version.
0034 %
0035 %   MATPOWER is distributed in the hope that it will be useful,
0036 %   but WITHOUT ANY WARRANTY; without even the implied warranty of
0037 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0038 %   GNU General Public License for more details.
0039 %
0040 %   You should have received a copy of the GNU General Public License
0041 %   along with MATPOWER. If not, see <http://www.gnu.org/licenses/>.
0042 %
0043 %   Additional permission under GNU GPL version 3 section 7
0044 %
0045 %   If you modify MATPOWER, or any covered work, to interface with
0046 %   other modules (such as MATLAB code and MEX-files) available in a
0047 %   MATLAB(R) or comparable environment containing parts covered
0048 %   under other licensing terms, the licensors of MATPOWER grant
0049 %   you additional permission to convey the resulting work.
0050 
0051 global t_quiet;
0052 global t_counter;
0053 global t_ok_cnt;
0054 global t_not_ok_cnt;
0055 
0056 if nargin < 2 || strcmp(msg, '')
0057     msg = '';
0058 else
0059     msg = [' - ', msg];
0060 end
0061 if cond
0062     t_ok_cnt = t_ok_cnt + 1;
0063 else
0064     t_not_ok_cnt = t_not_ok_cnt + 1;
0065     if ~t_quiet
0066         fprintf('not ');
0067     end
0068 end
0069 if ~t_quiet
0070     fprintf('ok %d%s\n', t_counter, msg);
0071 end
0072 t_counter = t_counter + 1;
0073 if nargout
0074     ok = cond;
0075 end

Generated on Mon 26-Jan-2015 15:21:31 by m2html © 2005