comparison testing/utp_1.1/generic_utps/check_aop_units.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-units for a single inputs.
4 %
5 % CALL: atest = check_aop_units(fcn, in1, in2, out);
6 %
7 % VERSION: $Id: check_aop_units.m,v 1.3 2010/09/23 18:19:21 ingo Exp $
8 %
9
10 function atest = check_aop_units(fcn, in1, in2, out)
11 if utils.helper.ismember(func2str(fcn), {'plus', 'minus'})
12 % return the first non-empty
13 if ~isempty(in1.data.yunits.strs)
14 uo = in1.data.yunits;
15 else
16 uo = in2.data.yunits;
17 end
18 elseif utils.helper.ismember(func2str(fcn), {'or', 'and', 'xor'})
19 uo = unit();
20 else
21 % For other operators we need to apply the operator
22 uo = fcn(in1.data.yunits, in2.data.yunits);
23 end
24
25 atest = eq(uo, out.yunits);
26
27 end
28