Mercurial > hg > ltpda
comparison m-toolbox/classes/tests/@Assert/objectEquals.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f0afece42f48 |
---|---|
1 % OBJECTEQUALS Assert that two ltpda_obj objects are equal. | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: Assert that two ltpda_obj objects are equal. | |
5 % objectEquals(A, B) throws an AssertionFailed exception if A | |
6 % and B are not equal. A and B must have the same class and | |
7 % the same length. | |
8 % | |
9 % COMMAND: Assert.objectEquals(val1, val2) | |
10 % Assert.objectEquals(val1, val2, message) | |
11 % | |
12 % VERSION: $Id: objectEquals.m,v 1.1 2011/06/20 16:32:56 ingo Exp $ | |
13 % | |
14 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
15 function objectEquals(val1, val2, varargin) | |
16 | |
17 % Check class of the input arguments | |
18 if ~strcmp(class(val1), class(val2)) | |
19 Assert.fail('The input arguments must be from the same class.'); | |
20 end | |
21 | |
22 % Check class of the input arguments | |
23 if ~isa(val1, 'ltpda_obj') | |
24 Assert.fail('The input arguments must be derived from the ltpda_obj class.'); | |
25 end | |
26 | |
27 % Check the length of the inputs | |
28 if numel(val1) ~= numel(val2) | |
29 Assert.fail('The input arguments don''t have the same length.'); | |
30 end | |
31 | |
32 if ~eq(val1, val2) | |
33 Assert.fail(varargin{:}); | |
34 end | |
35 | |
36 end |