octave-maintainers
[Top][All Lists]
Advanced

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

Re: missing tests


From: John W. Eaton
Subject: Re: missing tests
Date: Thu, 16 Jan 2014 10:54:14 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20131005 Icedove/17.0.9

On 01/15/2014 10:31 PM, mike sander wrote:
i chose a function from http://wiki.octave.org/FilesMissingTests:
miscellaneous/cast.m

the following is what i have so far.   Looking for some feedback before
i continue.  Do the tests look sensible?  Is there a class of testing
related to cast to int8 (& other types) that i am missing?  I have tried
to follow formatting/style from other tests.

Thanks in advance for any comments/suggestions.


<code>
%% Test input validation
%!error cast (1)
%!error <cast: expecting TYPE name as second argument> cast (1,1)
%!error <cast: type name 'int' is not a built-in type> cast (1,"int")

## Test int8 cast.  input values will be limited to int8 range -128 to
127 after cast.  input values within range unchanged.
%!assert (cast (int8 (-128), "int8"), int8 (-128))
%!assert (cast (int8 (0), "int8"), int8 (0))
%!assert (cast (int8 (127), "int8"), int8 (127))
%!assert (cast (uint8 (0), "int8"), int8 (0))
%!assert (cast (uint8 (255), "int8"), int8 (127))
%!assert (cast (int16 (-1000), "int8"), int8 (-128))
%!assert (cast (int16 (0), "int8"), int8 (0))
%!assert (cast (int16 (1000), "int8"), int8 (127))
%!assert (cast (uint16 (0), "int8"), int8 (0))
%!assert (cast (uint16 (1000), "int8"), int8 (127))
%!assert (cast (int32 (-1000), "int8"), int8 (-128))
%!assert (cast (int32 (0), "int8"), int8 (0))
%!assert (cast (int32 (1000), "int8"), int8 (127))
%!assert (cast (uint32 (0), "int8"), int8 (0))
%!assert (cast (uint32 (1000), "int8"), int8 (127))
%!assert (cast (int64 (-1000), "int8"), int8 (-128))
%!assert (cast (int64 (0), "int8"), int8 (0))
%!assert (cast (int64 (1000), "int8"), int8 (127))
%!assert (cast (uint64 (0), "int8"), int8 (0))
%!assert (cast (uint64 (1000), "int8"), int8 (127))
%!assert (cast (double (-1000), "int8"), int8 (-128))
%!assert (cast (double (0), "int8"), int8 (0))
%!assert (cast (double (1000), "int8"), int8 (127))
%!assert (cast (single (-1000), "int8"), int8 (-128))
%!assert (cast (single (0), "int8"), int8 (0))
%!assert (cast (single (1000), "int8"), int8 (127))
%!assert (cast (logical (true), "int8"), int8 (1))
%!assert (cast (logical (false), "int8"), int8 (0))
%!assert (cast (char ("A"), "int8"), int8 (65))

## Test int16 cast.  values will be limited to range -32,768 to 32,767
## more to come ...
</code>

For repetitive tests like this, it makes sense to me that they would be generated instead of written by hand.

jwe



reply via email to

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