11function test_suite = test_setTargetPositionInSequence % #ok<*STOUT>
2-
2+
33 initEnv();
4-
4+
55 try % assignment of 'localfunctions' is necessary in Matlab >= 2016
66 test_functions = localfunctions(); % #ok<*NASGU>
77 catch % no problem; early Matlab versions can use initTestSuite fine
1010end
1111
1212function test_setTargetPositionInSequenceBasic()
13-
13+
1414 seqLength = 12 ;
1515 nbTarget = 3 ;
1616 forbiddenPos = [1 5 10 ];
17-
17+
1818 % Create a hundred draws of targer positiona and ensure that
1919 % - the forbidden position are never drawn
2020 % - the interval between target is superior to 1
2121 for i = 1 : 100
2222 chosenPositions(i , : ) = setTargetPositionInSequence(seqLength , nbTarget , forbiddenPos );
2323 end
24-
24+
2525 assertFalse(any(ismember(chosenPositions(: ), forbiddenPos )));
26-
26+
2727 interval = abs(diff(chosenPositions , [], 2 ));
2828 assertTrue(all(interval(: ) > 1 ));
29-
29+
3030end
3131
3232function initEnv
33-
33+
3434 installlist = {' io' , ' statistics' };
35-
35+
3636 if isOctave
37-
37+
3838 for ii = 1 : length(installlist )
39-
39+
4040 packageName = installlist{ii };
41-
41+
4242 try
4343 % Try loading Octave packages
4444 disp([' loading ' packageName ]);
4545 pkg(' load' , packageName );
46-
46+
4747 catch
4848 tryInstallFromForge(packageName );
4949 end
5050 end
51-
51+
5252 end
53-
53+
5454end
5555
5656function tryInstallFromForge(packageName )
57-
57+
5858 errorcount = 1 ;
5959 while errorcount % Attempt twice in case installation fails
6060 try
@@ -68,5 +68,5 @@ function tryInstallFromForge(packageName)
6868 end
6969 end
7070 end
71-
71+
7272end
0 commit comments