Home > matpower7.0 > mptest > lib > t > t_test_fcns.m

t_test_fcns

PURPOSE ^

T_TEST_FCNS Test T_OK and T_IS and manually check output of failed tests.

SYNOPSIS ^

function t_test_fcns(quiet)

DESCRIPTION ^

T_TEST_FCNS  Test T_OK and T_IS and manually check output of failed tests.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function t_test_fcns(quiet)
0002 %T_TEST_FCNS  Test T_OK and T_IS and manually check output of failed tests.
0003 
0004 %   MP-Test
0005 %   Copyright (c) 2015, Power Systems Engineering Research Center (PSERC)
0006 %   by Ray Zimmerman, PSERC Cornell
0007 %
0008 %   This file is part of MP-Test.
0009 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0010 %   See https://github.com/MATPOWER/mptest for more info.
0011 
0012 if nargin < 1
0013     quiet = 0;
0014 end
0015 
0016 ntests = 5;
0017 npass = 9;
0018 nfail = 12;
0019 
0020 g = [];
0021 e = [];
0022 
0023 tol = 12;
0024 k = 0;
0025 str = {'EXPECT FAIL'; 'EXPECT PASS'};
0026 f = @(s) str{s+1};
0027 
0028 t_begin(npass+nfail, quiet);
0029 
0030 k = k + 1; e(k) = 1;
0031 t = sprintf('%s : t_ok(1, ...)', f(e(k)));
0032 g(k) = t_ok(1, t);
0033 
0034 k = k + 1; e(k) = 0;
0035 t = sprintf('%s : t_ok(0, ...)', f(e(k)));
0036 g(k) = t_ok(0, t);
0037 
0038 k = k + 1; e(k) = 1;
0039 t = sprintf('%s : t_is([], [], ...)', f(e(k)));
0040 expected = [];
0041 got = [];
0042 g(k) = t_is(got, expected, tol, t);
0043 
0044 k = k + 1; e(k) = 0;
0045 t = sprintf('%s : t_is(1, [], ...)', f(e(k)));
0046 expected = [];
0047 got = 1;
0048 g(k) = t_is(got, expected, tol, t);
0049 
0050 k = k + 1; e(k) = 1;
0051 t = sprintf('%s : t_is(3, 3, ...)', f(e(k)));
0052 expected = 3;
0053 got = 3;
0054 g(k) = t_is(got, expected, tol, t);
0055 
0056 k = k + 1; e(k) = 0;
0057 t = sprintf('%s : t_is(1, 3, ...)', f(e(k)));
0058 expected = 3;
0059 got = 1;
0060 g(k) = t_is(got, expected, tol, t);
0061 
0062 k = k + 1; e(k) = 1;
0063 t = sprintf('%s : t_is([3 3; 3 3], 3, ...)', f(e(k)));
0064 expected = 3;
0065 got = [3 3; 3 3];
0066 g(k) = t_is(got, expected, tol, t);
0067 
0068 k = k + 1; e(k) = 0;
0069 t = sprintf('%s : t_is([3 4; 3 3], 3, ...)', f(e(k)));
0070 expected = 3;
0071 got = [3 4; 3 3];
0072 g(k) = t_is(got, expected, tol, t);
0073 
0074 k = k + 1; e(k) = 1;
0075 t = sprintf('%s : t_is([3 3; 4 3], [3 3; 4 3], ...)', f(e(k)));
0076 expected = [3 3; 4 3];
0077 got = [3 3; 4 3];
0078 g(k) = t_is(got, expected, tol, t);
0079 
0080 k = k + 1; e(k) = 0;
0081 t = sprintf('%s : t_is([3 4; 3 3], [3 3; 4 3], ...)', f(e(k)));
0082 expected = [3 3; 4 3];
0083 got = [3 4; 3 3];
0084 g(k) = t_is(got, expected, tol, t);
0085 
0086 k = k + 1; e(k) = 1;
0087 t = sprintf('%s : t_is(ones(2,4,3), ones(2,4,3), ...)', f(e(k)));
0088 expected = ones(2,4,3);
0089 got = ones(2,4,3);
0090 g(k) = t_is(got, expected, tol, t);
0091 
0092 k = k + 1; e(k) = 0;
0093 t = sprintf('%s : t_is(ones(2,4), ones(2,4,3), ...)', f(e(k)));
0094 expected = ones(2,4,3);
0095 got = ones(2,4);
0096 g(k) = t_is(got, expected, tol, t);
0097 
0098 k = k + 1; e(k) = 0;
0099 t = sprintf('%s : t_is(ones(2,4,3), <one-elem-different> > tol, ...)', f(e(k)));
0100 expected = ones(2,4,3);
0101 got = ones(2,4,3);
0102 got(2,3,2) = 1.0005;
0103 g(k) = t_is(got, expected, 4, t);
0104 
0105 k = k + 1; e(k) = 1;
0106 t = sprintf('%s : t_is(ones(2,4,3), <one-elem-different> < tol, ...)', f(e(k)));
0107 expected = ones(2,4,3);
0108 got = ones(2,4,3);
0109 got(2,3,2) = 1.0005;
0110 g(k) = t_is(got, expected, 3, t);
0111 
0112 k = k + 1; e(k) = 1;
0113 t = sprintf('%s : t_is(NaN, NaN, ...)', f(e(k)));
0114 expected = NaN;
0115 got = NaN;
0116 g(k) = t_is(got, expected, tol, t);
0117 
0118 k = k + 1; e(k) = 0;
0119 t = sprintf('%s : t_is([], NaN, ...)', f(e(k)));
0120 expected = NaN;
0121 got = [];
0122 g(k) = t_is(got, expected, tol, t);
0123 
0124 k = k + 1; e(k) = 0;
0125 t = sprintf('%s : t_is(NaN, [], ...)', f(e(k)));
0126 expected = [];
0127 got = NaN;
0128 g(k) = t_is(got, expected, tol, t);
0129 
0130 k = k + 1; e(k) = 0;
0131 t = sprintf('%s : t_is(1, NaN, ...)', f(e(k)));
0132 expected = NaN;
0133 got = 1;
0134 g(k) = t_is(got, expected, tol, t);
0135 
0136 k = k + 1; e(k) = 0;
0137 t = sprintf('%s : t_is(NaN, 3, ...)', f(e(k)));
0138 expected = 3;
0139 got = NaN;
0140 g(k) = t_is(got, expected, tol, t);
0141 
0142 k = k + 1; e(k) = 1;
0143 t = sprintf('%s : t_is(NaN(3,2), NaN, ...)', f(e(k)));
0144 expected = NaN;
0145 got = NaN(3,2);
0146 g(k) = t_is(got, expected, tol, t);
0147 
0148 k = k + 1; e(k) = 0;
0149 t = sprintf('%s : t_is(int32(0.6), 1.0, ...)', f(e(k)));
0150 expected = 0.6;
0151 got = int32(1.0);
0152 g(k) = t_is(got, expected, tol, t);
0153 
0154 %%-----  reset tests, if this test passes, everything is as expected  -----
0155 t_begin(ntests, quiet);
0156 
0157 t = 'number of tests as expected';
0158 t_is(length(g), npass+nfail, tol, t);
0159 t_is(length(e), npass+nfail, tol, t);
0160 
0161 t = 'verify test consistency';
0162 t_is(sum( e), npass, tol, t);
0163 t_is(sum(~e), nfail, tol, t);
0164 
0165 t = 'passes and fails all as expected';
0166 t_is(g, e, tol, t);
0167 
0168 t_end;

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