Attachment 'assert_equal.m'
Download 1 %ASSERT_EQUAL Compares two matrices and prints an error message if
2 %necessary
3 %
4 %Function compares the first two parameters, which can be any type
5 %of matrix, vector or scalar of same type and prints the error message in
6 %the third parameter if they differ too much. An optional fourth parameter
7 %can be passed which has to be a message which will be printed on success.
8 %
9 %synopsis
10 % ASSERT_EQUAL(A, B, error)
11 % ASSERT_EQUAL(A, B, error, success)
12 %
13 %arguments
14 % A: correct result
15 % B: asserted result
16 % error: error message to be shown if A is not equal to B
17 % success: (optional) message to be shown if A is equal to B
18 %
19 %usage
20 % ASSERT_EQUAL(A, B, 'error message')
21 %
22 %author
23 % saputra@cs.tu-berlin.de
24
25 function [] = assert_equal(A, B, error, success)
26
27 if max(max(abs(A - B))) > 1e-10
28 %keyboard;
29 fprintf(['Error: ' error '\n']);
30 else
31 if nargin > 3
32 fprintf(['OK: ' success '\n']);
33 end
34 end
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.