0001 function t_test_fcns(quiet)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 if nargin < 1
0013 quiet = 0;
0014 end
0015
0016 ntests = 1;
0017 npass = 8;
0018 nfail = 11;
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
0149 t_begin(ntests, quiet);
0150
0151 t = 'passes and fails all as expected';
0152 t_is(g, e, tol, t);
0153
0154 t_end;