Mercurial > hg > ltpda
comparison testing/utp_1.1/generic_utps/utp_901.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 model <MODEL> has a meaningful name. | |
4 % | |
5 % </TestDescription> | |
6 % | |
7 % $Id: utp_901.m,v 1.3 2010/07/27 07:37:28 hewitson Exp $ | |
8 % | |
9 | |
10 function result = utp_901(cl, model_name, pl) | |
11 | |
12 % <SyntaxDescription> | |
13 % | |
14 % Test that the model <MODEL> has a meaningful name. | |
15 % | |
16 % </SyntaxDescription> | |
17 | |
18 try | |
19 | |
20 % <SyntaxCode> | |
21 pl = combine(pl, plist('built-in', model_name)); | |
22 mdl = feval(cl, pl); | |
23 % </SyntaxCode> | |
24 stest = true; | |
25 catch err | |
26 disp(err.message) | |
27 msg = [err.message ' - ' err.stack(1).name ' - line ' num2str(err.stack(1).line)]; | |
28 stest = false; | |
29 end | |
30 | |
31 % <AlgoDescription> | |
32 % | |
33 % 1) Check that the name of the object is not empty and not equal to 'none' | |
34 % | |
35 % </AlgoDescription> | |
36 | |
37 atest = true; | |
38 if stest | |
39 msg = ''; | |
40 % <AlgoCode> | |
41 % check the model produces an object of the correct class | |
42 if ~isa(mdl, cl) | |
43 atest = false; | |
44 msg = sprintf('The model produced by %s is not a %s model', model_name, cl); | |
45 end | |
46 % check the name | |
47 if strcmpi(mdl.name, 'none') | |
48 atest = false; | |
49 msg = sprintf('The model %s gives an object with the name ''none''', model_name); | |
50 end | |
51 % check empty | |
52 if isempty(mdl.name) | |
53 atest = false; | |
54 msg = sprintf('The model %s gives an object with an empty name', model_name); | |
55 end | |
56 | |
57 % </AlgoCode> | |
58 else | |
59 atest = false; | |
60 end | |
61 | |
62 % Return a result structure | |
63 dd = dbstack; | |
64 mfilename = dd(2).file(1:end-2); | |
65 result = utp_prepare_result(atest, stest, dbstack, mfilename, msg); | |
66 end % END UTP_901 |