comparison testing/utp_1.1/generic_utps/check_aop_errors.m @ 44:409a22968d5e default

Add unit tests
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Tue, 06 Dec 2011 18:42:11 +0100
parents
children
comparison
equal deleted inserted replaced
43:bc767aaa99a8 44:409a22968d5e
1 %
2 % DESCRIPTION: Generic check for a arithmetic operator unit test which
3 % checks the y-errors for a single inputs.
4 %
5 % CALL: atest = check_aop_errors(fcn, in1, in2, out);
6 %
7 % VERSION: $Id: check_aop_errors.m,v 1.2 2010/09/21 16:50:14 ingo Exp $
8 %
9
10 function atest = check_aop_errors(fcn, in1, in2, out)
11 if ~isempty(in1.dy) || ~isempty(in2.dy)
12
13 din1 = in1.dy;
14 din2 = in2.dy;
15
16 if isempty(din1)
17 din1 = zeros(size(in1.y));
18 end
19 if isempty(din2)
20 din2 = zeros(size(in2.y));
21 end
22
23 switch func2str(fcn)
24 case {'plus', 'minus'}
25 dy = sqrt(din1.^2 + din2.^2);
26 case {'times', 'mtimes'}
27 dy = sqrt( (din1./in1.y).^2 + (din2./in2.y).^2 ) .* abs(in1.y.*in2.y);
28 case {'rdivide', 'mrdivide'}
29 dy = sqrt( (din1./in1.y).^2 + (din2./in2.y).^2 ) .* abs(in1.y./in2.y);
30 otherwise
31 dy = [];
32 end
33
34 else
35 dy = [];
36 end
37
38 atest = isequal(out.dy, dy);
39
40 end