view m-toolbox/classes/tests/@Assert/objectEquals.m @ 3:960fe1aa1c10 database-connection-manager

Add LTPDADatabaseConnectionManager implementation. Java code
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Mon, 05 Dec 2011 16:20:06 +0100
parents f0afece42f48
children
line wrap: on
line source

% OBJECTEQUALS Assert that two ltpda_obj objects are equal.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% DESCRIPTION: Assert that two ltpda_obj objects are equal.
%              objectEquals(A, B) throws an AssertionFailed exception if A
%              and B are not equal. A and B must have the same class and
%              the same length.
%
% COMMAND:     Assert.objectEquals(val1, val2)
%              Assert.objectEquals(val1, val2, message)
%
% VERSION:     $Id: objectEquals.m,v 1.1 2011/06/20 16:32:56 ingo Exp $
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function objectEquals(val1, val2, varargin)
  
  % Check class of the input arguments
  if ~strcmp(class(val1), class(val2))
    Assert.fail('The input arguments must be from the same class.');
  end
  
  % Check class of the input arguments
  if ~isa(val1, 'ltpda_obj')
    Assert.fail('The input arguments must be derived from the ltpda_obj class.');
  end
  
  % Check the length of the inputs
  if numel(val1) ~= numel(val2)
    Assert.fail('The input arguments don''t have the same length.');
  end
  
  if ~eq(val1, val2)
    Assert.fail(varargin{:});
  end
  
end