Mercurial > hg > ltpda
comparison testing/utp_1.1/generic_utps/utp_genericAnyShapeInternal.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 % <TestDescription> | |
2 % | |
3 % Tests that the internal call of general setter method works with any | |
4 % shape of objects as input. | |
5 % | |
6 % </TestDescription> | |
7 function result = utp_genericAnyShapeInternal(method, objs, values, algo) | |
8 | |
9 % <SyntaxDescription> | |
10 % | |
11 % Test that the internal call of a general setter method works with any | |
12 % shape of objects as input. | |
13 % | |
14 % </SyntaxDescription> | |
15 | |
16 try | |
17 % <SyntaxCode> | |
18 out = testCallerIsMethod(str2func(method), objs, values); | |
19 % </SyntaxCode> | |
20 stest = true; | |
21 catch err | |
22 disp(err.message) | |
23 stest = false; | |
24 end | |
25 | |
26 % <AlgoDescription> | |
27 % | |
28 % 1) Check that the number of elements in 'out' is the same as in 'objs' | |
29 % 2) Check that each output object contains the correct data. | |
30 % | |
31 % </AlgoDescription> | |
32 | |
33 atest = true; | |
34 if stest | |
35 % <AlgoCode> | |
36 % Check we have the correct number of outputs | |
37 if ~isequal(size(out), size(objs)), atest = false; end | |
38 % Check each output against the correct value | |
39 for kk=1:numel(out) | |
40 atest = algo(objs, out, kk, values); | |
41 if ~atest | |
42 break; | |
43 end | |
44 end | |
45 | |
46 % </AlgoCode> | |
47 else | |
48 atest = false; | |
49 end | |
50 | |
51 % Return a result structure | |
52 stack = dbstack; | |
53 if numel(objs) > 1 | |
54 stack(1).name = sprintf('%s %dx%d', stack(1).name, size(objs)); | |
55 end | |
56 result = utp_prepare_result(atest, stest, stack, ['utp_' class(objs) '_' method]); | |
57 end |