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

Generated on Fri 20-Mar-2015 18:23:34 by m2html © 2005