octave-maintainers
[Top][All Lists]
Advanced

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

Re: Writing tests for data.cc


From: Dag
Subject: Re: Writing tests for data.cc
Date: Mon, 16 May 2016 11:30:33 -0700 (PDT)

Mike Miller-4 wrote
> Not seen below. Perhaps you posted on nabble, which is notoriously bad
> at mirroring verbatim blocks of code for some reason?

Yeah, I posted on nabble. Trying again, this is my example of how tests for
iscomplex() could look like.

/*
%!assert (iscomplex (1+i), true)
%!assert (iscomplex (1), false)
%!assert (iscomplex (single(1+i)), true)
%!assert (iscomplex (single(1)), false)
%!assert (iscomplex (double(1+i)), true)
%!assert (iscomplex (double(1)), false)

%!assert (iscomplex (NaN), false)
%!assert (iscomplex (NA), false)
%!assert (iscomplex (Inf), false)
%!assert (iscomplex (-Inf), false)
%!assert (iscomplex (Inf+i), true)

%!assert (iscomplex (true), false)
%!assert (iscomplex (int8(1)), false)
%!assert (iscomplex (uint8(1)), false)
%!assert (iscomplex (int16(1)), false)
%!assert (iscomplex (uint16(1)), false)
%!assert (iscomplex (int32(1)), false)
%!assert (iscomplex (uint32(1)), false)
%!assert (iscomplex (int64(1)), false)
%!assert (iscomplex (uint64(1)), false)
%!assert (iscomplex (int8(1)), false)
%!assert (iscomplex ("1"), false)

%!assert (iscomplex ([1, 2]), false)
%!assert (iscomplex ([1+i, 2]), true)
%!assert (iscomplex ([]), false)
%!assert (iscomplex (sparse([1+i, 2])), true)
%!assert (iscomplex (sparse([1, 2])), false)

%!assert (iscomplex (struct("one", {1})), false)
%!assert (iscomplex (cell(1)), false)
*/


Mike Miller-4 wrote
> Please check the tests/*.tst files also. Many functions are tested there
> rather than in a source file. For example, many functions defined in
> syscalls.cc are tested in test/system.tst.

data.cc and file-io.cc look most interesting, so I will attempt to write
code for those two files first.

When it comes to functions such as fopen() and fclose(), it is sensible to
create a dummy file on the hard drive before running the test. Is it
possible to run a script that does that? The script test language is Octave.
Is it possible to run, e.g., a shell script that cleans up after finishing?

Some functions are already tested in the files *.tst. It is best to avoid
duplicates where possible.



--
View this message in context: 
http://octave.1599824.n4.nabble.com/Writing-tests-for-data-cc-tp4676989p4677011.html
Sent from the Octave - Maintainers mailing list archive at Nabble.com.



reply via email to

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