help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

automated testing


From: Bart Vandewoestyne
Subject: automated testing
Date: Wed, 30 Jul 2008 13:18:40 +0200
User-agent: Mutt/1.5.13 (2006-08-11)

Dear list,

I am currently converting a Fortran 95 package to Octave/Matlab.
I would like to add some kind of automated testing to my
Octave code without giving up Matlab compatibility.

I found out that there exists an 'assert' and 'test' command in
Octave.  The use of the assert command is quite straightforward, but I am
a bit confused about how to use the 'test' command.  The
documentation in my version of Octave only mentions:

"Perform tests from the first file in the loadpath matching NAME."

It does not explain how the tests in the to-be-tested file should be setup.

I looked at the code of factorial.m and at the end I find stuff
like

%!assert (factorial(5), prod(1:5))
%!assert (factorial([1,2;3,4]), [1,2;6,24])
%!assert (factorial(70), exp(sum(log(1:70))), -128*eps)
%!fail ('factorial(5.5)', "must all be nonnegative integers")
%!fail ('factorial(-3)', "must all be nonnegative integers")

Is this the proper way to setup automated testing for .m files?  Namely by
using assert and fail commands at the end of an .m file?  Are there other
things that are interesting to know when it comes to automated testing for
.m files?

I tried to find documentation on this subject using Google, but i didn't really
find something useful.  If somebody can point me in the right direction by
giving me a link where the testing-mechanism is explained, that would be nice.

Kind regards,
Bart

-- 
        "Share what you know.  Learn what you don't."


reply via email to

[Prev in Thread] Current Thread [Next in Thread]