Home > matpower6.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 %   Copyright (c) 2004-2016, Power Systems Engineering Research Center (PSERC)
0024 %   by Ray Zimmerman, PSERC Cornell
0025 %
0026 %   This file is part of MATPOWER.
0027 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0028 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0029 
0030 global t_quiet;
0031 global t_counter;
0032 global t_ok_cnt;
0033 global t_not_ok_cnt;
0034 
0035 if nargin < 2 || strcmp(msg, '')
0036     msg = '';
0037 else
0038     msg = [' - ', msg];
0039 end
0040 if cond
0041     t_ok_cnt = t_ok_cnt + 1;
0042 else
0043     t_not_ok_cnt = t_not_ok_cnt + 1;
0044     if ~t_quiet
0045         fprintf('not ');
0046     end
0047 end
0048 if ~t_quiet
0049     fprintf('ok %d%s\n', t_counter, msg);
0050 end
0051 t_counter = t_counter + 1;
0052 if nargout
0053     ok = cond;
0054 end

Generated on Fri 16-Dec-2016 12:45:37 by m2html © 2005