Mercurial > octave-antonio
changeset 19146:a84f0182f912
bitfcns.cc: add tests for bitwise operators (some of them failing).
author | Carnë Draug <carandraug@octave.org> |
---|---|
date | Sun, 21 Sep 2014 22:22:46 +0100 |
parents | b5c03bcc640a |
children | 8b2a919d24bc |
files | libinterp/corefcn/bitfcns.cc |
diffstat | 1 files changed, 34 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/bitfcns.cc Sun Sep 21 16:33:08 2014 -0400 +++ b/libinterp/corefcn/bitfcns.cc Sun Sep 21 22:22:46 2014 +0100 @@ -377,6 +377,27 @@ return bitop ("bitxor", args); } +/* +%!assert (bitand (true, false), false) +%!assert (bitor (true, false), true) +%!assert (bitxor (true, false), true) + +%!assert (bitand (true, true), true) +%!assert (bitor (true, true), true) +%!assert (bitxor (true, true), false) + +%!assert (bitand (true, 5), 1) + +%!assert (bitand (true, false), false) +%!assert (bitand (true, true), true) +%!assert (bitand (true, false), false) +%!assert (bitand (true, false), false) + +## Test idx_arg.length () == 0 +%!error <size of X and Y must match> bitand ([0 0 0], [1 0]) +%!error <size of X and Y must match> bitand ([0; 0; 0], [0 0 0]) +*/ + template <typename T> static int64_t max_mantissa_value () @@ -621,6 +642,19 @@ return retval; } +/* +%!assert (bitshift (uint8 (16), 1), uint8 ( 32)) +%!assert (bitshift (uint16 (16), 2), uint16 ( 64)) +%!assert (bitshift (uint32 (16), 3), uint32 (128)) +%!assert (bitshift (uint64 (16), 4), uint64 (256)) +%!assert (bitshift (uint8 (255), 1), uint8 (254)) + +%!error <expecting integer as second argument> bitshift (16, 1.5) +%!error bitshift (16, {1}) +%!error <N must be a scalar integer> bitshift (10, [-2 -1 0 1 2], [1 1 1 1 1]) +%!error <N must be positive> bitshift (10, [-2 -1 0 1 2], -1) +*/ + DEFUN (bitmax, args, , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} bitmax ()\n\