diff m-toolbox/classes/tests/@Assert/doubleEquals.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m-toolbox/classes/tests/@Assert/doubleEquals.m	Wed Nov 23 19:22:13 2011 +0100
@@ -0,0 +1,31 @@
+% DOUBLEEQUALS Assert that two doubles are equal.
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% DESCRIPTION: Assert that two doubles are equal.
+%              doubleEquals(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.doubleEquals(val1, val2)
+%              Assert.doubleEquals(val1, val2, message)
+%
+% VERSION:     $Id: doubleEquals.m,v 1.1 2011/06/20 16:32:56 ingo Exp $
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+function doubleEquals(val1, val2, varargin)
+  
+  % Check class of the input arguments
+  if ~isnumeric(val1) || ~isnumeric(val2)
+    Assert.fail('The input arguments must be two double.');
+  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 (val1 ~= val2)
+    Assert.fail(varargin{:});
+  end
+  
+end