naushad-rahman / ellipsoids

Automatically exported from code.google.com/p/ellipsoids
0 stars 0 forks source link

Cover @linsys class with unit tests #25

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
You should crete elltool.core.test.mlunit package, 
it would be located in 
<YourWorkingCopy>\products\+elltool\+linsys\+test\+mlunit. 

In this package you should create LinSysTestCase MLUNITEXT test class, the name 
of the file would 
be  <YourWorkingCopy>\products\+elltool\+linsys\+test\+mlunit\LinSysTestCase.m

Along with this class you should 
 # create run_tests function in <YourWorkingCopy>\products\+elltool\+linsys\+test folder which 
would put it into elltool.linsys.test packet
 # Modify elltool.test.run_tests function so that it calls 
your newly created elltool.linsys.test.run_tests function in the way described 
in 
item 3 on 

http://code.google.com/p/ellipsoids/wiki/MLUNITEXT_unit_testing_framework_descri
ption 

Wiki page

Once all this is done you need to write unit tests for ALL the methods of 
@linsys class. This is a simple class 
so it should not be too hard. Please

The idea of a unit test is that you think of an analytical example where the 
output is known in advance and compare this 
expected output with the output produced by the function or/and method. 

Original issue reported on code.google.com by heartofm...@gmail.com on 19 Oct 2012 at 6:34

GoogleCodeExporter commented 9 years ago
1. If one passes a cell-vector containing t as control bounds, the 
corresponding value in constantbounds vector will still be 1. Consider the 
following example:

ls = linsys(eye(2),eye(2),{'t','t'}');

The same remains true for noise and disturbance bounds. Is that the correct 
behavior? 

2. Everywhere in that class binary AND and OR are used instead of their logical 
counterparts, should I fix that? 

3. Should I replace double with boolean when it's appropriate?

Original comment by ivan.v.menshikov on 27 Oct 2012 at 11:33

GoogleCodeExporter commented 9 years ago

Original comment by ivan.v.menshikov on 27 Oct 2012 at 11:35

GoogleCodeExporter commented 9 years ago
1) This seems to be a bug both in the source and documentation and the latter 
doesn't say that U can be a cell-array. So could you please fix that in the 
source code and update the documentaiton?

2) Absolutely, use && and || instead of & and | for scalars.

3) Internally - yes, all internal variables should be logical where 
appropriate. However, when it comes to the function input and output parameters 
- let us just leave them as is for now - we need to keep the backward 
compatibility. So if function returns a variable that has double valus 1 and 0 
(which you could replace with a logical variable) - don't change that for now. 

Original comment by heartofm...@gmail.com on 28 Oct 2012 at 3:45

GoogleCodeExporter commented 9 years ago
Currently, hasdisturbance method of linsys class returns 1 if and only if the 
following condition holds (V is the object passed to the linsys constructor):
~(isempty(V)) && ~(iscell(V)) && ~(isa(V, 'double'))
That is, 1 is returned if and only if V is an object of ellipsoid class or V is 
a structure describing ellipsoid that depends on time. But there is two more 
possibilities for V. If V is a constant or cell vector, hasdisturbance returns 
0. What should I do about that?

Original comment by ivan.v.menshikov on 30 Oct 2012 at 7:03

GoogleCodeExporter commented 9 years ago
Good observation, just make it work as it should and write a test. Thanks.

Original comment by heartofm...@gmail.com on 30 Oct 2012 at 7:30

GoogleCodeExporter commented 9 years ago
Should I write a test for display method? It doesn't make much sense to me, 
because every tiny change, an extra space, for example, will result in failure.

Original comment by ivan.v.menshikov on 31 Oct 2012 at 5:35

GoogleCodeExporter commented 9 years ago
Just write a simple test like that 

resStr=evalc('display(ellObj)');
isOk=~isempty(strfind(resStr,'Center'));
isOk=~isempty(strfind(resStr,'Shape Matrix'))&&isOk;
mlunitext.assert(isOk);

Original comment by heartofm...@gmail.com on 31 Oct 2012 at 5:40

GoogleCodeExporter commented 9 years ago
How do I write a test that succeeds if there were no errors during it's 
execution? Is there a method for doing that? 

success = true;
try
   % ... 
catch e
   success = false;
end
mlunit.assert_equals(success, true);

Original comment by ivan.v.menshikov on 31 Oct 2012 at 7:46

GoogleCodeExporter commented 9 years ago
Well, you do not need anything special, just call the method. If it crashes - 
you get a test error. If not - test passes. A presence of assertions is not 
necessary.

Original comment by heartofm...@gmail.com on 31 Oct 2012 at 7:55

GoogleCodeExporter commented 9 years ago
You can start the reintegration process, please strictly follow the procedure 
described at 
http://code.google.com/p/ellipsoids/wiki/Issues_workflow_and_branching_policy 
(bottom of the page).

Original comment by heartofm...@gmail.com on 31 Oct 2012 at 9:56

GoogleCodeExporter commented 9 years ago
Issue is fixed, please delete the branch.

Original comment by heartofm...@gmail.com on 1 Nov 2012 at 7:08