octave-maintainers
[Top][All Lists]
Advanced

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

missing tests


From: mike sander
Subject: missing tests
Date: Wed, 15 Jan 2014 22:31:27 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0

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>


reply via email to

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