From: <sla...@us...> - 2012-03-13 23:19:51
|
Revision: 9876 http://octave.svn.sourceforge.net/octave/?rev=9876&view=rev Author: slackydeb Date: 2012-03-13 23:19:45 +0000 (Tue, 13 Mar 2012) Log Message: ----------- ga: review unit tests of rastriginsfcn Modified Paths: -------------- trunk/octave-forge/main/ga/inst/ga_test.m trunk/octave-forge/main/ga/inst/rastriginsfcn.m Modified: trunk/octave-forge/main/ga/inst/ga_test.m =================================================================== --- trunk/octave-forge/main/ga/inst/ga_test.m 2012-03-13 22:47:05 UTC (rev 9875) +++ trunk/octave-forge/main/ga/inst/ga_test.m 2012-03-13 23:19:45 UTC (rev 9876) @@ -45,5 +45,5 @@ test ga ## TODO: split performance tests -## TODO: review all unit tests -## TODO: write missing unit tests, or write pre-function TODOs +## TODO: review all unit tests (DONE: rastriginsfcn) +## TODO: write missing unit tests, or write per-function TODOs Modified: trunk/octave-forge/main/ga/inst/rastriginsfcn.m =================================================================== --- trunk/octave-forge/main/ga/inst/rastriginsfcn.m 2012-03-13 22:47:05 UTC (rev 9875) +++ trunk/octave-forge/main/ga/inst/rastriginsfcn.m 2012-03-13 23:19:45 UTC (rev 9876) @@ -14,15 +14,16 @@ ## along with this program; If not, see <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn{Function File} {} rastriginsfcn (@var{x}) +## @deftypefn{Function File} {@var{y} =} rastriginsfcn (@var{x}) ## Rastrigin's function. ## @end deftypefn ## Author: Luca Favatella <sla...@gm...> -## Version: 1.4 +## Version: 2.0 function retval = rastriginsfcn (x) - if (nargout != 1) + if ((nargin != 1) || (nargout != 1) || + (columns (x) != 2)) print_usage (); else x1 = x(:, 1); @@ -33,8 +34,15 @@ endfunction -%!error rastriginsfcn () -%!error rastriginsfcn ([0, 0], "other argument") +## number of arguments +%!error y = rastriginsfcn () +%!error y = rastriginsfcn ([0, 0], "other argument") +%!error [y1, y2] = rastriginsfcn ([0, 0]) +## type of arguments +%!error y = rastriginsfcn ([0; 0]) +%!error y = rastriginsfcn (zeros (2, 3)) # TODO: document size of x + %!assert (rastriginsfcn ([0, 0]), 0) -%!assert (rastriginsfcn ([0, 0; 0, 0]), [0; 0]) \ No newline at end of file +%!assert (rastriginsfcn ([0, 0; 0, 0]), [0; 0]) +%!assert (rastriginsfcn (zeros (3, 2)), [0; 0; 0]) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |